-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0git
More file actions
executable file
·44 lines (31 loc) · 1.16 KB
/
0git
File metadata and controls
executable file
·44 lines (31 loc) · 1.16 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
#!/usr/bin/env python3
import sys
import subprocess
class bcolors:
OKGREEN = '\033[92m'
ENDC = '\033[0m'
def print_help():
helpmsg = " Check All SubDirectories and git something them "
helpmsg += """
help: This text
status: git status
pull: git pull
"""
print(helpmsg)
def status():
gitrepos = subprocess.run(["find", ".", "-name", ".git"], capture_output=True, universal_newlines=True)
for gitpath in gitrepos.stdout.splitlines():
print(bcolors.OKGREEN + '{}'.format(gitpath[:-4]) + bcolors.ENDC)
subprocess.run(["git", "-C", gitpath[:-4], "status"])
def pull():
gitrepos = subprocess.run(["find", ".", "-name", ".git"], capture_output=True, universal_newlines=True)
for gitpath in gitrepos.stdout.splitlines():
print(bcolors.OKGREEN + '{}'.format(gitpath[:-4]) + bcolors.ENDC)
subprocess.run(["git", "-C", gitpath[:-4], "pull"])
def main():
i = sys.argv[1] if len(sys.argv) > 1 else print_help
switcher = {"status": status, "pull": pull}
func = switcher.get(i, print_help)
return func()
if __name__ == '__main__':
main()