|
15 | 15 | SymbolicReference,
|
16 | 16 | GitCommandError,
|
17 | 17 | RefLog,
|
| 18 | + GitConfigParser, |
18 | 19 | )
|
19 | 20 | from git.objects.tag import TagObject
|
20 | 21 | from test.lib import TestBase, with_rw_repo
|
@@ -172,6 +173,26 @@ def test_heads(self, rwrepo):
|
172 | 173 | assert log[0].oldhexsha == pcommit.NULL_HEX_SHA
|
173 | 174 | assert log[0].newhexsha == pcommit.hexsha
|
174 | 175 |
|
| 176 | + @with_rw_repo("HEAD", bare=False) |
| 177 | + def test_set_tracking_branch_with_import(self, rwrepo): |
| 178 | + # prepare included config file |
| 179 | + included_config = osp.join(rwrepo.git_dir, "config.include") |
| 180 | + with GitConfigParser(included_config, read_only=False) as writer: |
| 181 | + writer.set_value("test", "value", "test") |
| 182 | + assert osp.exists(included_config) |
| 183 | + |
| 184 | + with rwrepo.config_writer() as writer: |
| 185 | + writer.set_value("include", "path", included_config) |
| 186 | + |
| 187 | + for head in rwrepo.heads: |
| 188 | + head.set_tracking_branch(None) |
| 189 | + assert head.tracking_branch() is None |
| 190 | + remote_ref = rwrepo.remotes[0].refs[0] |
| 191 | + assert head.set_tracking_branch(remote_ref) is head |
| 192 | + assert head.tracking_branch() == remote_ref |
| 193 | + head.set_tracking_branch(None) |
| 194 | + assert head.tracking_branch() is None |
| 195 | + |
175 | 196 | def test_refs(self):
|
176 | 197 | types_found = set()
|
177 | 198 | for ref in self.rorepo.refs:
|
|
0 commit comments