-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmcell_git.py
More file actions
90 lines (70 loc) · 2.36 KB
/
mcell_git.py
File metadata and controls
90 lines (70 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python3
"""
Copyright (C) 2019 by
The Salk Institute for Biological Studies and
Pittsburgh Supercomputing Center, Carnegie Mellon University
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
"""
"""
This module gehaves similarly as git, it only operates on all
relevant repositories.
Not all useful commands were implemented yet.
"""
import os
import sys
THIS_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(THIS_DIR, 'scripts'))
import repositories
from build_settings import *
from options import *
from utils import fatal_error
def print_help():
print("Usage: mcell_git [clone|checkout|pull|push|reset-hard])")
if __name__ == "__main__":
argc = len(sys.argv)
if argc == 1 or sys.argv[1] == "help":
print_help()
sys.exit(0)
a1 = sys.argv[1]
opts = Options()
opts.use_private_repos = True
if a1 == 'clone' or a1 == 'checkout':
if argc == 3:
opts.branch = sys.argv[2]
print("Cloning or updating branch " + opts.branch + ".")
repositories.get_or_update(opts)
elif a1 == 'pull':
if argc > 2:
fatal_error("Command pull does not have any extra arguments")
print("Pulling all repositories")
repositories.pull(opts)
elif a1 == 'push':
if argc > 2:
fatal_error("Command push does not have any extra arguments")
print("Pushing all repositories")
repositories.push(opts)
elif a1 == 'reset-hard':
if argc > 2:
fatal_error("Command reset-hard does not have any extra arguments")
print("Reseting all repositories")
repositories.reset_hard(opts)
elif a1 == 'tag':
if argc == 3:
# misusing branch argument for tag
opts.branch = sys.argv[2]
else:
fatal_error("Missing tag argument")
print("Tagging all repositories")
repositories.tag(opts)
elif a1 == 'merge':
if argc == 3:
opts.branch = sys.argv[2]
else:
fatal_error("Missing branch argument")
print("Merging all repositories")
repositories.merge(opts)
else:
print("Error: unknown command '" + a1 + "'")
print_help()