diff options
Diffstat (limited to 'git/test')
-rw-r--r-- | git/test/fixtures/uncommon_branch_prefix_FETCH_HEAD | 6 | ||||
-rw-r--r-- | git/test/fixtures/uncommon_branch_prefix_stderr | 6 | ||||
-rw-r--r-- | git/test/test_docs.py | 2 | ||||
-rw-r--r-- | git/test/test_remote.py | 16 |
4 files changed, 28 insertions, 2 deletions
diff --git a/git/test/fixtures/uncommon_branch_prefix_FETCH_HEAD b/git/test/fixtures/uncommon_branch_prefix_FETCH_HEAD new file mode 100644 index 00000000..7df36f24 --- /dev/null +++ b/git/test/fixtures/uncommon_branch_prefix_FETCH_HEAD @@ -0,0 +1,6 @@ +c2e3c20affa3e2b61a05fdc9ee3061dd416d915e 'refs/pull/1/head' of http://github.com/loic-bot/testrepo +fd8695d980e2c6df62b7785f93fd6292d1e283fb 'refs/pull/1/merge' of http://github.com/loic-bot/testrepo +bb46faf089720d1a3f9e4dc3b11ed5ff77d7e764 'refs/pull/2/head' of http://github.com/loic-bot/testrepo +5faa366d58454eceea811e0e34c502bdd7b37e4b 'refs/pull/2/merge' of http://github.com/loic-bot/testrepo +b3ad3c4f1864b50d4d3e09320947a1a3c34c9ea2 'refs/pull/3/head' of http://github.com/loic-bot/testrepo +71fe57e511776042b009ed4bb281b62b0522b434 'refs/pull/3/merge' of http://github.com/loic-bot/testrepo diff --git a/git/test/fixtures/uncommon_branch_prefix_stderr b/git/test/fixtures/uncommon_branch_prefix_stderr new file mode 100644 index 00000000..5a6aca65 --- /dev/null +++ b/git/test/fixtures/uncommon_branch_prefix_stderr @@ -0,0 +1,6 @@ + = [up to date] refs/pull/1/head -> pull/1/head + = [up to date] refs/pull/1/merge -> pull/1/merge + = [up to date] refs/pull/2/head -> pull/2/head + = [up to date] refs/pull/2/merge -> pull/2/merge + = [up to date] refs/pull/3/head -> pull/3/head + = [up to date] refs/pull/3/merge -> pull/3/merge diff --git a/git/test/test_docs.py b/git/test/test_docs.py index 25566243..397641e0 100644 --- a/git/test/test_docs.py +++ b/git/test/test_docs.py @@ -181,7 +181,7 @@ class Tutorials(TestBase): def test_references_and_objects(self, rw_dir): # [1-test_references_and_objects] import git - repo = git.Repo.clone_from(self._small_repo_url(), os.path.join(rw_dir, 'repo')) + repo = git.Repo.clone_from(self._small_repo_url(), os.path.join(rw_dir, 'repo'), branch='master') heads = repo.heads master = heads.master # lists can be accessed by name for convenience diff --git a/git/test/test_remote.py b/git/test/test_remote.py index d4a92ed4..4fd78230 100644 --- a/git/test/test_remote.py +++ b/git/test/test_remote.py @@ -7,7 +7,8 @@ from git.test.lib import ( TestBase, with_rw_repo, - with_rw_and_rw_remote_repo + with_rw_and_rw_remote_repo, + fixture ) from git import ( RemoteProgress, @@ -520,3 +521,16 @@ class TestRemote(TestBase): assert type(fi.ref) is Reference assert fi.ref.path == "refs/something/branch" + + def test_uncommon_branch_names(self): + stderr_lines = fixture('uncommon_branch_prefix_stderr').decode('ascii').splitlines() + fetch_lines = fixture('uncommon_branch_prefix_FETCH_HEAD').decode('ascii').splitlines() + + # The contents of the files above must be fetched with a custom refspec: + # +refs/pull/*:refs/heads/pull/* + res = [FetchInfo._from_line('ShouldntMatterRepo', stderr, fetch_line) + for stderr, fetch_line in zip(stderr_lines, fetch_lines)] + assert len(res) + assert res[0].remote_ref_path == 'refs/pull/1/head' + assert res[0].ref.path == 'refs/heads/pull/1/head' + assert isinstance(res[0].ref, Head) |