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

Commitb65df78

Browse files
committed
Fixed a bug with branch names omitting path components.
Git allows branches to be named and organized using path components, e.g usinga branch called "refactoring/feature1", which gets stored underrefs/heads/refactoring/feature1. The previous code omitted everything but thelast path component giving the name "feature1" instead of"refactoring/feature1" for the branch. This changeset fixes that.(cherry picked from commit dc4738bc53e580754e47037e26c7eec3047aeb69)
1 parent6ffd4b0 commitb65df78

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

‎lib/git/head.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ def from_string(cls, repo, line):
104104
git.Head
105105
"""
106106
full_name,ids=line.split("\x00")
107-
name=full_name.split("/")[-1]
107+
108+
iffull_name.startswith('refs/heads/'):
109+
name=full_name[len('refs/heads/'):]
110+
else:
111+
name=full_name
112+
108113
c=commit.Commit(repo,id=ids)
109114
returnHead(name,c)
110115

72 Bytes
Binary file not shown.

‎test/git/test_head.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@ def test_repr(self, git):
2121

2222
assert_true(git.called)
2323
assert_equal(git.call_args, (('for_each_ref','refs/heads'), {'sort':'committerdate','format':'%(refname)%00%(objectname)'}))
24+
25+
@patch_object(Git,'_call_process')
26+
deftest_ref_with_path_component(self,git):
27+
git.return_value=fixture('for_each_ref_with_path_component')
28+
head=self.repo.heads[0]
29+
30+
assert_equal('refactoring/feature1',head.name)
31+
assert_true(git.called)
32+
assert_equal(git.call_args, (('for_each_ref','refs/heads'), {'sort':'committerdate','format':'%(refname)%00%(objectname)'}))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp