| OLD | NEW |
| 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 Loading... |
| 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) |
| OLD | NEW |