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

Side by Side Diff: infra/libs/git2/ref.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, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | infra/libs/git2/repo.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from infra.libs.git2.util import CalledProcessError 5 from infra.libs.git2.util import CalledProcessError
6 from infra.libs.git2.util import INVALID 6 from infra.libs.git2.util import INVALID
7 7
8 class Ref(object): 8 class Ref(object):
9 """Represents a single simple ref in a git Repo.""" 9 """Represents a single simple ref in a git Repo."""
10 def __init__(self, repo, ref_str): 10 def __init__(self, repo, ref_str):
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return self._repo.get_commit(val.split()[0]) 46 return self._repo.get_commit(val.split()[0])
47 47
48 # Methods 48 # Methods
49 def to(self, other): 49 def to(self, other):
50 """Generate Commit()'s which occur from `self..other`.""" 50 """Generate Commit()'s which occur from `self..other`."""
51 assert self.commit is not INVALID 51 assert self.commit is not INVALID
52 arg = '%s..%s' % (self.ref, other.ref) 52 arg = '%s..%s' % (self.ref, other.ref)
53 for hsh in self.repo.run('rev-list', '--reverse', arg).splitlines(): 53 for hsh in self.repo.run('rev-list', '--reverse', arg).splitlines():
54 yield self.repo.get_commit(hsh) 54 yield self.repo.get_commit(hsh)
55 55
56 def fast_forward_push(self, commit):
57 """Push |commit| to this ref on the remote, and update the local copy of the
58 ref to |commit|."""
59 self.repo.run('push', 'origin', '%s:%s' % (commit.hsh, self.ref))
60 self.update_to(commit)
61
62 def update_to(self, commit): 56 def update_to(self, commit):
63 """Update the local copy of the ref to |commit|.""" 57 """Update the local copy of the ref to |commit|."""
64 self.repo.run('update-ref', self.ref, commit.hsh) 58 self.repo.run('update-ref', self.ref, commit.hsh)
OLDNEW
« no previous file with comments | « no previous file | infra/libs/git2/repo.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698