Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit333786c

Browse files
authored
Merge pull request#1996 from flichtenheld/git-rev-parse
Repo.rev_parse: Handle <tag>^{commit} correctly
2 parents340044b +e4f1aa7 commit333786c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

‎git/repo/fun.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,13 @@ def rev_parse(repo: "Repo", rev: str) -> AnyGitObject:
301301

302302
# Handle type.
303303
ifoutput_type=="commit":
304-
pass# Default.
304+
obj=cast("TagObject",obj)
305+
ifobjandobj.type=="tag":
306+
obj=deref_tag(obj)
307+
else:
308+
# Cannot do anything for non-tags.
309+
pass
310+
# END handle tag
305311
elifoutput_type=="tree":
306312
try:
307313
obj=cast(AnyGitObject,obj)

‎test/test_repo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,9 +1064,9 @@ def test_rev_parse(self):
10641064
# TODO: Dereference tag into a blob 0.1.7^{blob} - quite a special one.
10651065
# Needs a tag which points to a blob.
10661066

1067-
# ref^0 returns commit being pointed to, same with ref~0, and ^{}
1067+
# ref^0 returns commit being pointed to, same with ref~0,^{},and ^{commit}
10681068
tag=rev_parse("0.1.4")
1069-
fortokenin ("~0","^0","^{}"):
1069+
fortokenin ("~0","^0","^{}","^{commit}"):
10701070
self.assertEqual(tag.object,rev_parse("0.1.4%s"%token))
10711071
# END handle multiple tokens
10721072

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp