-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfixorigin.py
More file actions
executable file
·43 lines (35 loc) · 1.26 KB
/
fixorigin.py
File metadata and controls
executable file
·43 lines (35 loc) · 1.26 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
#!/usr/bin/env python
"""Usage:
fixorigin.py [(-v|--verbose) --test (-t ACCESS_TOKEN|-f ACCESS_TOKEN_FILE)] DIR
fixorigin.py (-h|--help)
Search for Github repositories in DIR using Github oAuth specified by ACCESS_TOKEN
or in ACCESS_TOKEN_FILE; for every git found under DIR make sure remote origin set to clone_url.
Arguments:
DIR root directory to search for gits
Options:
-h --help show this screen.
-v --verbose verbose mode
--test test mode
-t ACCESS_TOKEN specify ACCESS_TOKEN directly, takes precedence over ACCESS_TOKEN_FILE
-f ACCESS_TOKEN_FILE specify file in working directory with ACCESS_TOKEN [default: .oAuth]
"""
from docopt import docopt
if __name__ == '__main__':
config = docopt(__doc__)
rootDir = config['DIR']
TEST = config['--test']
VERBOSE = config['--verbose']
if TEST or VERBOSE:
print(config)
from githubtools import Githubtool
ght = Githubtool(VERBOSE,
TEST,
clone_dir=rootDir,
access_token_file=config['-f'],
access_token=config['-t'])
for repo in ght.local_repos:
try:
ght.set_origin(repo)
except:
if TEST or VERBOSE:
print(f"{repo.path} doesn't have an origin.")