Skip to content

Instantly share code, notes, and snippets.

@bendikro
Last active August 29, 2015 14:28
Show Gist options
  • Save bendikro/ef432ac0d48c56e0d56a to your computer and use it in GitHub Desktop.
Save bendikro/ef432ac0d48c56e0d56a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import argparse
import sh
def check_result(ret):
if ret.exit_code != 0:
print "Command returned with value:", ret.exit_code
return False
return True
def update(from_remote, to_remotes, branches, **kw):
print "Using repo %s" % kw["repo_dir"]
git = sh.git.bake(_cwd=kw["repo_dir"])
print "Status:", git.status()
ret = git.remote("update")
if not check_result(ret):
return
for branch in branches:
ret = git.checkout(branch)
if not check_result(ret):
return
ret = git.merge("%s/%s" % (from_remote, branch))
if not check_result(ret):
return
for remote in to_remotes:
ret = git.push(remote, branch)
if not check_result(ret):
return
conf = {"git": "/usr/local/bin/git",
"repo_dir": "/home/bro/programmer/deluge/auto_update_repo/deluge_cron_update",
}
update("deluge", ["deluge-github", "github"], ["develop", "1.3-stable"], **conf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment