From 03e3982ef3f754edc5ec46107d76cf0c5dfe41dd Mon Sep 17 00:00:00 2001 From: Anthony Gargiulo Date: Sat, 23 Jun 2012 15:49:34 -0400 Subject: [PATCH] the process_repo function works --- github-backup.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/github-backup.py b/github-backup.py index bf16258..53a9c87 100755 --- a/github-backup.py +++ b/github-backup.py @@ -35,6 +35,21 @@ def init_parser(): return parser +def process_repo(repo, args): + if args.cron: + git_args = "-q" + else: + git_args = "" + + if not args.cron: + print("Processing repo: {}".format(repo.full_name)) + + if os.access('{}/{}/.git'.format(args.backupdir,repo.name),os.F_OK): + if not args.cron: + print("Repo already exists, let's try to update it instead") + os.system('cd {}/{};git pull {}'.format(args.backupdir, repo.name, git_args)) + else: # Repo doesn't exist, let's clone it + os.system('git clone {} {} {}/{}'.format(git_args, repo.git_url, args.backupdir, repo.name)) if __name__ == "__main__": main()