diff --git a/marge/job.py b/marge/job.py index 9b33aae0..7c0cd444 100644 --- a/marge/job.py +++ b/marge/job.py @@ -28,6 +28,10 @@ def __init__(self, *, api, user, project, repo, options): def repo(self): return self._repo + @property + def project(self): + return self._project + @property def opts(self): return self._options @@ -345,8 +349,8 @@ def update_from_target_branch_and_push( # A failure to clean up probably means something is fucked with the git repo # and likely explains any previous failure, so it will better to just # raise a GitError - if source_branch != 'master': - repo.checkout_branch('master') + if source_branch != self.project.default_branch: + repo.checkout_branch(self.project.default_branch) repo.remove_branch(source_branch) if not branch_update_done: diff --git a/marge/project.py b/marge/project.py index 0ca5b63a..42996bdd 100644 --- a/marge/project.py +++ b/marge/project.py @@ -69,6 +69,10 @@ def project_seems_ok(project_info): return projects + @property + def default_branch(self): + return self.info['default_branch'] + @property def path_with_namespace(self): return self.info['path_with_namespace'] diff --git a/tests/test_project.py b/tests/test_project.py index a6190ddb..fd963e91 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -10,6 +10,7 @@ 'path_with_namespace': 'cool/project', 'ssh_url_to_repo': 'ssh://blah.com/cool/project.git', 'merge_requests_enabled': True, + 'default_branch': 'master', 'only_allow_merge_if_pipeline_succeeds': True, 'only_allow_merge_if_all_discussions_are_resolved': False, 'permissions': {