diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2016-06-20 07:01:17 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2016-06-20 07:01:17 +0200 |
commit | 451504f1e1aa84fb3de77adb6c554b9eb4a7d0ab (patch) | |
tree | 8ade226350b0e21c6966d5db703cce796c7ce2f3 /git | |
parent | f128ae9a37036614c1b5d44e391ba070dd4326d1 (diff) | |
download | gitpython-451504f1e1aa84fb3de77adb6c554b9eb4a7d0ab.tar.gz |
fix(remote): lazy PushInfo.old_commit initialization
We will now populate the old_commit on demand, which will
allow us to keep going even if the given commit does not
exist locally.
Fixes #461
Diffstat (limited to 'git')
-rw-r--r-- | git/remote.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/git/remote.py b/git/remote.py index 9a26deeb..c024030d 100644 --- a/git/remote.py +++ b/git/remote.py @@ -77,7 +77,6 @@ def to_progress_instance(progress): class PushInfo(object): - """ Carries information about the result of a push operation of a single head:: @@ -92,7 +91,7 @@ class PushInfo(object): # it to local_ref.commit. Will be None if an error was indicated info.summary # summary line providing human readable english text about the push """ - __slots__ = ('local_ref', 'remote_ref_string', 'flags', 'old_commit', '_remote', 'summary') + __slots__ = ('local_ref', 'remote_ref_string', 'flags', '_old_commit_sha', '_remote', 'summary') NEW_TAG, NEW_HEAD, NO_MATCH, REJECTED, REMOTE_REJECTED, REMOTE_FAILURE, DELETED, \ FORCED_UPDATE, FAST_FORWARD, UP_TO_DATE, ERROR = [1 << x for x in range(11)] @@ -112,8 +111,12 @@ class PushInfo(object): self.local_ref = local_ref self.remote_ref_string = remote_ref_string self._remote = remote - self.old_commit = old_commit + self._old_commit_sha = old_commit self.summary = summary + + @property + def old_commit(self): + return self._old_commit_sha and self._remote.repo.commit(self._old_commit_sha) or None @property def remote_ref(self): @@ -176,7 +179,7 @@ class PushInfo(object): split_token = ".." old_sha, new_sha = summary.split(' ')[0].split(split_token) # have to use constructor here as the sha usually is abbreviated - old_commit = remote.repo.commit(old_sha) + old_commit = old_sha # END message handling return PushInfo(flags, from_ref, to_ref_string, remote, old_commit, summary) |