-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetcher.py
35 lines (26 loc) · 964 Bytes
/
fetcher.py
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
import argparse
import os
def parse_args():
desc = "redmine git fetcher :: to use, you must add to crontab"
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('--git_dir', type=str, help='directory that includes .git folders', required=True)
return parser.parse_args()
def main():
args = parse_args()
if args is None:
exit()
# git_dir not exist
if not os.path.exists(args.git_dir):
print("ERROR::" + args.git_dir, " not exist!")
exit()
for root, folders, files in os.walk(args.git_dir, topdown=False):
if len(folders) == 0: # if folders length is 0, continue
continue
if all(str[-4:] != '.git' for str in folders): # if not git folder, continue
continue
for git in folders:
print(root + '/' + git)
os.chdir(root + '/' + git)
os.system('git fetch -a')
if __name__ == '__main__':
main()