Commits

Mike Bayer committed 1d204da

add support for pushes to other repos

Comments (0)

Files changed (2)

publishthing/core.py

     with chdir_as(path):
         check_call(["git", "remote", "update", "--prune", origin])
 
+def git_push(path, remote):
+    with chdir_as(path):
+        check_call(["git", "push", remote])
 
 def update_hg_mirror(path):
     """Update an hg repo
     with chdir_as(path):
         check_call(["hg", "pull"])
 
+def hg_push(path, remote):
+    with chdir_as(path):
+        check_call(["hg", "push", remote])
+
+
 @contextlib.contextmanager
 def chdir_as(path):
     currdir = os.getcwd()

publishthing/dvcs_hooks.py

 from publishthing import dvcs_hooks
 
 mapping = {
-    "/bitbucket_username/bitbucket_reponame/":(
-        "/path/to/your/repo.git",
-        "origin"
-    )
+    "/bitbucket_username/bitbucket_reponame/":{
+        "local_repo": "/path/to/your/repo.git",
+        "remote": "origin",
+        "push_to": ["github", "some_server"]
+    }
 }
 
 application = dvcs_hooks.bitbucket(mapping)
         else:
             repo = message['repository']['absolute_url']
             if repo in mapping and message['repository']['scm'] == 'git':
-                path, origin = mapping[repo]
-                update_git_mirror(path, origin)
+                entry = mapping[repo]
+                update_git_mirror(entry['local_repo'], entry['remote'])
+                if 'push_to' in entry:
+                    for push_to in entry['push_to']:
+                        git_push(entry['local_repo'], push_to)
 
         res.body = "OK"
         return res(environ, start_response)