| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5a15361 commit d8a4958
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -269,6 +269,15 @@ def rev_parse(repo: "Repo", rev: str) -> AnyGitObject: | |||
| 269 | 269 | if rev[start] not in "^~:@": | |
| 270 | 270 | start += 1 | |
| 271 | 271 | continue | |
| 272 | + if rev[start] == "@": | ||
| 273 | + next_char = rev[start + 1] if start + 1 < lr else None | ||
| 274 | + if start == 0: | ||
| 275 | + if next_char not in (None, "{", "^", "~", ":"): | ||
| 276 | + start += 1 | ||
| 277 | + continue | ||
| 278 | + elif next_char != "{": | ||
| 279 | + start += 1 | ||
| 280 | + continue | ||
| 272 | 281 | # END handle start | |
| 273 | 282 | ||
| 274 | 283 | token = rev[start] | |
@@ -292,6 +301,12 @@ def rev_parse(repo: "Repo", rev: str) -> AnyGitObject: | |||
| 292 | 301 | ||
| 293 | 302 | start += 1 | |
| 294 | 303 | ||
| 304 | + if token == "@" and (start >= lr or rev[start] != "{"): | ||
| 305 | + obj = cast(AnyGitObject, ref.commit) | ||
| 306 | + ref = None | ||
| 307 | + parsed_to = start | ||
| 308 | + continue | ||
| 309 | + | ||
| 295 | 310 | # Try to parse {type}. | |
| 296 | 311 | if start < lr and rev[start] == "{": | |
| 297 | 312 | end = rev.find("}", start) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -146,6 +146,22 @@ def test_commit_from_revision(self): | |||
| 146 | 146 | self.assertEqual(commit.type, "commit") | |
| 147 | 147 | self.assertEqual(self.rorepo.commit(commit), commit) | |
| 148 | 148 | ||
| 149 | + @with_rw_directory | ||
| 150 | + def test_commit_from_tag_starting_with_at(self, rw_dir): | ||
| 151 | + repo = Repo.init(rw_dir) | ||
| 152 | + with repo.config_writer() as writer: | ||
| 153 | + writer.set_value("user", "name", "GitPython Tests") | ||
| 154 | + writer.set_value("user", "email", "gitpython@example.com") | ||
| 155 | + | ||
| 156 | + tracked_file = Path(rw_dir) / "hello.txt" | ||
| 157 | + tracked_file.write_text("hello") | ||
| 158 | + repo.index.add([str(tracked_file)]) | ||
| 159 | + commit = repo.index.commit("init") | ||
| 160 | + repo.create_tag("@foo") | ||
| 161 | + | ||
| 162 | + self.assertEqual(repo.commit("@"), commit) | ||
| 163 | + self.assertEqual(repo.commit("@foo"), commit) | ||
| 164 | + | ||
| 149 | 165 | def test_commits(self): | |
| 150 | 166 | mc = 10 | |
| 151 | 167 | commits = list(self.rorepo.iter_commits("0.1.6", max_count=mc)) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments