Read about our upcoming Code of Conduct on this issue

Commit 859e6baa authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Mercurial native: forbid closing of default GitLab branch

With the native mode, something pushed is pushed. In that case
if we don't want a closing changeset of the GitLab branch,
we have to prevent pushing it in the first place.

People can always change the default branch setting if needed
parent a46bd63cda3e
Pipeline #13223 passed with stage
in 38 minutes and 48 seconds
import re
from .utils import needs
from .utils.hg import LocalRepo
......@@ -33,7 +35,11 @@ def test_push_branch_then_close(test_project, tmpdir):
def test_close_default_branch(test_project, tmpdir):
"""Closing default branch shouldn't crash, and has to be ignored.
"""Closing default branch behaves according to project's VCS type
- On `hg-git` projects, it shouldn't crash, and has no consequences on
- on native projects, it must be refused by Heptapod
repo_path = tmpdir.join('repo1')
......@@ -49,8 +55,12 @@ def test_close_default_branch(test_project, tmpdir):
assert test_project.api_default_branch() == 'branch/default'
repo.hg('commit', '-m', "Closing branch `default`", '--close-branch')
code, out, _ = repo.hg_unchecked('push')
if test_project.hg_native:
assert code == 255
assert'close.*default branch', out)
assert code == 0
assert test_project.api_branch_titles() == {'branch/default': 'Commit 1'}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment