...
 
Commits (2)
......@@ -71,10 +71,7 @@ def test_import_small(public_project, tmpdir):
"draft non-topic changeset should not become public "
"in imported repo")
assert hg_log_set(clone) == hg_log_set(src_repo)
resp = project.owner_api_get()
assert resp.status_code == 200
assert resp.json()['default_branch'] == 'branch/default'
assert project.api_default_branch() == 'branch/default'
finally:
if project is not None:
......
......@@ -34,10 +34,10 @@ def test_push_basic(test_project, tmpdir):
assert 'remote: %r' % expected_env in out
# let's control what GitLab really sees
branches = test_project.api_branches()
assert set(branches) == {'branch/default', 'topic/default/zetop'}
assert branches['branch/default']['commit']['title'] == 'Commit 0'
assert branches['topic/default/zetop']['commit']['title'] == 'Commit 1'
assert test_project.api_branch_titles() == {
'branch/default': 'Commit 0',
'topic/default/zetop': 'Commit 1',
}
clone = LocalRepo.clone(url, tmpdir.join('repo2'))
log = clone.hg('log', '-T', '{desc}:{phase}:{topic}\n')
......@@ -126,10 +126,10 @@ def test_push_topic_permission(test_project, tmpdir):
repo.hg('push', basic_user_url)
# let's control what GitLab really sees
branches = test_project.api_branches()
assert set(branches) == {'branch/default', 'topic/default/zetop'}
assert branches['branch/default']['commit']['title'] == 'Commit 0'
assert branches['topic/default/zetop']['commit']['title'] == 'Commit 1'
assert test_project.api_branch_titles() == {
'branch/default': 'Commit 0',
'topic/default/zetop': 'Commit 1',
}
def test_push_tags_branch_heads(test_project, tmpdir):
......@@ -180,17 +180,17 @@ def test_push_branch_then_close(test_project, tmpdir):
print(repo.graphlog())
repo.hg('push')
gitlab_branches = test_project.api_branches()
assert set(gitlab_branches) == {'branch/default', 'branch/other'}
assert gitlab_branches['branch/default']['commit']['title'] == 'Commit 1'
assert gitlab_branches['branch/other']['commit']['title'] == 'Commit 2'
assert test_project.api_branch_titles() == {
'branch/default': 'Commit 1',
'branch/other': 'Commit 2',
}
repo.hg('commit', '-m', "Closing branch `other`", '--close-branch')
repo.hg('push')
gitlab_branches = test_project.api_branches()
assert set(gitlab_branches) == {'branch/default'}
assert gitlab_branches['branch/default']['commit']['title'] == 'Commit 1'
assert test_project.api_branch_titles() == {
'branch/default': 'Commit 1',
}
def test_close_default_branch(test_project, tmpdir):
......@@ -207,17 +207,12 @@ def test_close_default_branch(test_project, tmpdir):
repo.hg('commit', '-Am', "Commit 1")
repo.hg('push')
resp = test_project.owner_api_get()
assert resp.status_code == 200, "project is broken, test can't proceed"
default_branch = resp.json()['default_branch']
assert default_branch == 'branch/default' # that's the point
assert test_project.api_default_branch() == 'branch/default'
repo.hg('commit', '-m', "Closing branch `default`", '--close-branch')
repo.hg('push')
gitlab_branches = test_project.api_branches()
assert set(gitlab_branches) == {'branch/default'}
assert gitlab_branches['branch/default']['commit']['title'] == 'Commit 1'
assert test_project.api_branch_titles() == {'branch/default': 'Commit 1'}
def test_push_closed_branch(test_project, tmpdir):
......@@ -239,9 +234,9 @@ def test_push_closed_branch(test_project, tmpdir):
print(repo.graphlog())
repo.hg('push')
gitlab_branches = test_project.api_branches()
assert set(gitlab_branches) == {'branch/default'}
assert gitlab_branches['branch/default']['commit']['title'] == 'Commit 1'
assert test_project.api_branch_titles() == {
'branch/default': 'Commit 1',
}
def test_compat_closed_branch(test_project, tmpdir):
......@@ -277,10 +272,10 @@ def test_compat_closed_branch(test_project, tmpdir):
print(repo.graphlog())
repo.hg('push')
gl_branches = test_project.api_branches()
assert set(gl_branches) == {'branch/default', 'branch/other'}
assert gl_branches['branch/default']['commit']['title'] == 'Commit 1'
assert gl_branches['branch/other']['commit']['title'].startswith('Closing')
assert test_project.api_branch_titles() == {
'branch/default': 'Commit 1',
'branch/other': 'Closing branch `other`',
}
test_project.extend_hgrc('hg-git.prune-newly-closed-branches=yes')
......@@ -288,20 +283,20 @@ def test_compat_closed_branch(test_project, tmpdir):
repo_path.join('foo').write("more work on default branch")
repo.hg('commit', '-m', "More work 1")
code, out, err = repo.hg_unchecked('push')
gl_branches = test_project.api_branches()
assert set(gl_branches) == {'branch/default', 'branch/other'}
assert gl_branches['branch/default']['commit']['title'] == 'More work 1'
assert gl_branches['branch/other']['commit']['title'].startswith('Closing')
assert test_project.api_branch_titles() == {
'branch/default': 'More work 1',
'branch/other': 'Closing branch `other`',
}
test_project.extend_hgrc('hg-git.prune-previously-closed-branches=yes')
repo_path.join('foo').write("even more work on default branch")
repo.hg('commit', '-m', "More work 2")
code, out, err = repo.hg_unchecked('push')
gl_branches = test_project.api_branches()
assert set(gl_branches) == {'branch/default'}
assert gl_branches['branch/default']['commit']['title'] == 'More work 2'
assert test_project.api_branch_titles() == {
'branch/default': 'More work 2',
}
def test_push_bookmarks_default_branch(test_project, tmpdir):
......@@ -544,23 +539,19 @@ def test_topic_branch_change(test_project, tmpdir):
repo.hg('commit', '-Am', "Commit 2")
repo.hg('push', url)
branches = test_project.api_branches()
assert set(branches) == {'branch/default',
'branch/other',
'topic/other/zetop'}
assert branches['branch/default']['commit']['title'] == 'Commit 0'
assert branches['branch/other']['commit']['title'] == 'Commit 1'
assert branches['topic/other/zetop']['commit']['title'] == 'Commit 2'
assert test_project.api_branch_titles() == {
'branch/default': 'Commit 0',
'branch/other': 'Commit 1',
'topic/other/zetop': 'Commit 2',
}
repo.hg('branch', '-f', 'default')
repo.hg('amend')
repo.hg('push', url)
branches = test_project.api_branches()
# the GitLab branch for the old branch/topic combination has been pruned
assert set(branches) == {'branch/default',
'branch/other',
'topic/default/zetop'}
assert branches['branch/default']['commit']['title'] == 'Commit 0'
assert branches['branch/other']['commit']['title'] == 'Commit 1'
assert branches['topic/default/zetop']['commit']['title'] == 'Commit 2'
assert test_project.api_branch_titles() == {
'branch/default': 'Commit 0',
'branch/other': 'Commit 1',
'topic/default/zetop': 'Commit 2',
}
......@@ -209,6 +209,11 @@ class Project(object):
branches = resp.json()
return dict((branch.pop('name'), branch) for branch in branches)
def api_default_branch(self):
resp = self.owner_api_get()
assert resp.status_code == 200, "project is broken, test can't proceed"
return resp.json()['default_branch']
def api_branch_titles(self):
"""Keep only commit titles from `api_branches()`
......