Skip to content

Commit

Permalink
Use default branch instead of master (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarah Mount authored Oct 13, 2021
1 parent 17d3f02 commit 70ab3c8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions marge/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions marge/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
1 change: 1 addition & 0 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down

0 comments on commit 70ab3c8

Please sign in to comment.