diff --git a/git/remote.py b/git/remote.py index a122b1a5a..ba887c2cb 100644 --- a/git/remote.py +++ b/git/remote.py @@ -315,7 +315,7 @@ class FetchInfo(IterableObj): ERROR, ) = [1 << x for x in range(8)] - _re_fetch_result = re.compile(r"^ *(?:.{0,3})(.) (\[[\w \.$@]+\]|[\w\.$@]+) +(.+) -> ([^ ]+)( \(.*\)?$)?") + _re_fetch_result = re.compile(r"^ *(?:.{0,3})(.) (\[[\w \.$@]+\]|[\w\.$@]+) +(.+) -> ([^ ]+)( \(.*\)?$)?") _flag_map: Dict[flagKeyLiteral, int] = { "!": ERROR, diff --git a/test/test_remote.py b/test/test_remote.py index aba4ddce7..d3ecbb33a 100644 --- a/test/test_remote.py +++ b/test/test_remote.py @@ -229,7 +229,7 @@ def get_info(res, remote, name): mkey = "%s/%s" % (remote, "master") master_info = res[mkey] self.assertTrue(master_info.flags & FetchInfo.FORCED_UPDATE) - self.assertIsNotNone(master_info.note) + self.assertEqual(master_info.note, "(forced update)") # Normal fast forward - set head back to previous one. rhead.commit = remote_commit @@ -573,6 +573,14 @@ def test_fetch_info(self): self.assertIsInstance(info.ref, ref_type) self.assertEqual(info.remote_ref_path, source) self.assertTrue(info.flags & FetchInfo.NEW_HEAD) + self.assertEqual(info.note, "") + info = FetchInfo._from_line( + self.rorepo, + "! [rejected] tag -> subdir/tag (would clobber existing tag)", + ["refs/tags/tag:refs/tags/subdir/tag"], + ) + self.assertTrue(info.flags & FetchInfo.REJECTED) + self.assertEqual(info.note, "(would clobber existing tag)") with self.assertRaises(ValueError): FetchInfo._from_line(self.rorepo, "= [up to date] master -> ambiguous")