Skip to content

Commit fdb1dc7

Browse files
uri-canvaByron
authored andcommitted
Parse rejected deletes.
1 parent 359a7e0 commit fdb1dc7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: git/remote.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ def _from_line(cls, remote, line):
156156
if flags & cls.DELETED:
157157
from_ref = None
158158
else:
159-
from_ref = Reference.from_path(remote.repo, from_ref_string)
159+
if from_ref_string == "(delete)":
160+
from_ref = None
161+
else:
162+
from_ref = Reference.from_path(remote.repo, from_ref_string)
160163

161164
# commit handling, could be message or commit info
162165
old_commit = None

Diff for: git/test/test_remote.py

+8
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,14 @@ def _assert_push_and_pull(self, remote, rw_repo, remote_repo):
385385
progress.make_assertion()
386386
self._do_test_push_result(res, remote)
387387

388+
# rejected stale delete
389+
force_with_lease = "%s:0000000000000000000000000000000000000000" % new_head.path
390+
res = remote.push(":%s" % new_head.path, force_with_lease=force_with_lease)
391+
self.assertTrue(res[0].flags & PushInfo.ERROR)
392+
self.assertTrue(res[0].flags & PushInfo.REJECTED)
393+
self.assertIsNone(res[0].local_ref)
394+
self._do_test_push_result(res, remote)
395+
388396
# delete new branch on the remote end and locally
389397
res = remote.push(":%s" % new_head.path)
390398
self._do_test_push_result(res, remote)

0 commit comments

Comments
 (0)