Skip to content

Commit

Permalink
Fetch target sha after fusing
Browse files Browse the repository at this point in the history
A side effect of merging/rebasing is that we re-fetch our remotes
(origin and source). This affects the target sha as it looks at the
locally cloned repo, and doing this before we fetch means it will be
outdated.
  • Loading branch information
JaimeLennox authored and aschmolck committed Mar 7, 2018
1 parent 6d30194 commit 9a7d3c7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion marge/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,15 @@ def update_from_target_branch_and_push(
branch_updated = branch_rewritten = changes_pushed = False
try:
fuse = repo.merge if use_merge_strategy else repo.rebase
target_sha = repo.get_commit_hash('origin/' + target_branch)
rewritten_sha = updated_sha = fuse(
branch=source_branch,
new_base=target_branch,
source_repo_url=source_repo_url
)
branch_updated = True
# The fuse above fetches origin again, so we are now safe to fetch
# the sha from the remote target branch.
target_sha = repo.get_commit_hash('origin/' + target_branch)
if updated_sha == target_sha:
raise CannotMerge('these changes already exist in branch `{}`'.format(target_branch))
if reviewers is not None:
Expand Down

0 comments on commit 9a7d3c7

Please sign in to comment.