From a5677e9e5e14f8c2820ec4d7ceec37fa31017e20 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: May 17 2017 10:21:25 +0000 Subject: Fix pushing merge commits to the original repo For some reason pygit2 wasn't properly creating the local reference to be pushed to the main repo. With this commit we enforce that all merge commits use a local reference that is then pushed to the target branch. Fixes https://pagure.io/pagure/issue/1190 Fixes https://pagure.io/pagure/issue/2119 Thanks to @puiterwijk for the team work on tackling this one Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 62e9ecb..dfdc4d7 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -1367,6 +1367,9 @@ def merge_pull_request( [head.hex, repo_commit.oid.hex]) _log.info(' New head: %s', commit) + local_ref = 'refs/heads/_pagure_topush' + new_repo.create_reference(local_ref, commit) + refname = '%s:refs/heads/%s' % (local_ref, request.branch) PagureRepo.push(ori_remote, refname) _log.info(' Pushing to: %s to %s', refname, ori_remote) fork_obj.run_hook(