Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: infra/libs/git2/repo.py

Issue 424423004: Push pending tag and synthesized commit in a single git push operation. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « infra/libs/git2/ref.py ('k') | infra/libs/git2/test/ref_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/libs/git2/repo.py
diff --git a/infra/libs/git2/repo.py b/infra/libs/git2/repo.py
index 1a2ffa04d202165a9ac79c693e2c9bdb6e7a8dc0..ca4e42e82d353310b799715a7e04608b7ec6edd2 100644
--- a/infra/libs/git2/repo.py
+++ b/infra/libs/git2/repo.py
@@ -136,7 +136,9 @@ class Repo(object):
process = subprocess.Popen(cmd, **kwargs)
output, errout = process.communicate(indata)
retcode = process.poll()
- self._log.debug('Finished in %.1f sec', time.time() - started)
+ dt = time.time() - started
+ if dt > 1: # pragma: no cover
+ self._log.debug('Finished in %.1f sec', dt)
if retcode not in ok_ret:
raise CalledProcessError(retcode, cmd, output, errout)
@@ -147,3 +149,21 @@ class Repo(object):
def intern(self, data, typ='blob'):
return self.run(
'hash-object', '-w', '-t', typ, '--stdin', indata=str(data)).strip()
+
+ def fast_forward_push(self, refs_and_commits):
+ """Push commits to refs on the remote, and also update refs' local copies.
+
+ Refs names are specified as refs on remote, i.e. push to
+ Ref('refs/heads/master') would update 'refs/heads/master' on remote (and on
+ local repo mirror), no ref name translation is happening.
+
+ Args:
+ refs_and_commits: dict {Ref object -> Commit to push to the ref}.
+ """
+ refspec = [
+ '%s:%s' % (c.hsh, r.ref)
+ for r, c in refs_and_commits.iteritems()
+ ]
+ self.run('push', 'origin', *refspec)
+ for r, c in refs_and_commits.iteritems():
+ r.update_to(c)
« no previous file with comments | « infra/libs/git2/ref.py ('k') | infra/libs/git2/test/ref_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698