Skip to content

Commit 27769ab

Browse files
authored
Merge pull request #2351 from JROtto5/fix/fetch-info-note
fix(remote): keep the note on fetch results
2 parents fe74a6f + 7d9a2f0 commit 27769ab

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎git/remote.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class FetchInfo(IterableObj):
315315
ERROR,
316316
) = [1 << x for x in range(8)]
317317

318-
_re_fetch_result = re.compile(r"^ *(?:.{0,3})(.) (\[[\w \.$@]+\]|[\w\.$@]+) +(.+) -> ([^ ]+)( \(.*\)?$)?")
318+
_re_fetch_result = re.compile(r"^ *(?:.{0,3})(.) (\[[\w \.$@]+\]|[\w\.$@]+) +(.+) -> ([^ ]+)( \(.*\)?$)?")
319319

320320
_flag_map: Dict[flagKeyLiteral, int] = {
321321
"!": ERROR,

‎test/test_remote.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def get_info(res, remote, name):
229229
mkey = "%s/%s" % (remote, "master")
230230
master_info = res[mkey]
231231
self.assertTrue(master_info.flags & FetchInfo.FORCED_UPDATE)
232-
self.assertIsNotNone(master_info.note)
232+
self.assertEqual(master_info.note, "(forced update)")
233233

234234
# Normal fast forward - set head back to previous one.
235235
rhead.commit = remote_commit
@@ -573,6 +573,14 @@ def test_fetch_info(self):
573573
self.assertIsInstance(info.ref, ref_type)
574574
self.assertEqual(info.remote_ref_path, source)
575575
self.assertTrue(info.flags & FetchInfo.NEW_HEAD)
576+
self.assertEqual(info.note, "")
577+
info = FetchInfo._from_line(
578+
self.rorepo,
579+
"! [rejected] tag -> subdir/tag (would clobber existing tag)",
580+
["refs/tags/tag:refs/tags/subdir/tag"],
581+
)
582+
self.assertTrue(info.flags & FetchInfo.REJECTED)
583+
self.assertEqual(info.note, "(would clobber existing tag)")
576584
with self.assertRaises(ValueError):
577585
FetchInfo._from_line(self.rorepo, "= [up to date] master -> ambiguous")
578586

0 commit comments

Comments
 (0)