3 files changed
@@ -104,7 +104,12 @@ def from_string(cls, repo, line): | |||
| 104 | 104 | git.Head | |
| 105 | 105 | """ | |
| 106 | 106 | full_name, ids = line.split("\x00") | |
| 107 | - name = full_name.split("/")[-1] | ||
| 107 | + | ||
| 108 | + if full_name.startswith('refs/heads/'): | ||
| 109 | + name = full_name[len('refs/heads/'):] | ||
| 110 | + else: | ||
| 111 | + name = full_name | ||
| 112 | + | ||
| 108 | 113 | c = commit.Commit(repo, id=ids) | |
| 109 | 114 | return Head(name, c) | |
| 110 | 115 | ||
@@ -21,3 +21,12 @@ def test_repr(self, git): | |||
| 21 | 21 | ||
| 22 | 22 | assert_true(git.called) | |
| 23 | 23 | assert_equal(git.call_args, (('for_each_ref', 'refs/heads'), {'sort': 'committerdate', 'format': '%(refname)%00%(objectname)'})) | |
| 24 | + | ||
| 25 | + @patch_object(Git, '_call_process') | ||
| 26 | + def test_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