Merge pull request #10 from kwinczek/master
Three small changes from @kwinczek
This commit is contained in:
commit
64d69f6dfe
1 changed files with 10 additions and 3 deletions
|
@ -30,7 +30,11 @@ def main():
|
|||
gh = Github(**config)
|
||||
|
||||
# Get all of the given user's repos
|
||||
user_repos = gh.repos.list().all()
|
||||
if args.organization:
|
||||
user_repos = gh.repos.list_by_org(args.organization).all()
|
||||
else:
|
||||
user_repos = gh.repos.list().all()
|
||||
|
||||
for repo in user_repos:
|
||||
repo.user = gh.users.get(repo.owner.login)
|
||||
process_repo(repo, args)
|
||||
|
@ -50,6 +54,9 @@ def init_parser():
|
|||
parser.add_argument("-g","--git", help="Pass extra arguments to git", default="", metavar="ARGS")
|
||||
parser.add_argument("-s", "--suffix", help="Add suffix to repository directory names", default="")
|
||||
parser.add_argument("-p", "--password", help="Authenticate with Github API")
|
||||
parser.add_argument("-P","--prefix", help="Add prefix to repository directory names", default="")
|
||||
parser.add_argument("-o","--organization", help="Backup Organizational repositories")
|
||||
parser.add_argument("-S","--ssh", help="Use SSH protocol", action="store_true")
|
||||
|
||||
return parser
|
||||
|
||||
|
@ -57,7 +64,7 @@ def process_repo(repo, args):
|
|||
if not args.cron:
|
||||
print("Processing repo: %s"%(repo.full_name))
|
||||
|
||||
dir = "%s/%s"%(args.backupdir, repo.name + args.suffix)
|
||||
dir = "%s/%s"%(args.backupdir, args.prefix + repo.name + args.suffix)
|
||||
config = "%s/%s"%(dir, "config" if args.mirror else ".git/config")
|
||||
|
||||
if not os.access(config, os.F_OK):
|
||||
|
@ -75,7 +82,7 @@ def clone_repo(repo, dir, args):
|
|||
else:
|
||||
options = args.git
|
||||
|
||||
os.system('git clone %s %s %s'%(options, repo.git_url, dir))
|
||||
os.system('git clone %s %s %s'%(options, repo.ssh_url if args.ssh else repo.git_url, dir))
|
||||
|
||||
|
||||
def update_repo(repo, dir, args):
|
||||
|
|
Loading…
Add table
Reference in a new issue