From 07b517e2fa1f40ea872cf60eb06b92ce2cd88e09 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 14 2021 10:14:35 +0000 Subject: Get the default branch of the target repo when linking for new PR Rather than assuming the default branch is the same in the source and the target repo, we generate the new PR url using the default branch of the target repo. Fixes https://pagure.io/pagure/issue/5086 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/hooks/default.py b/pagure/hooks/default.py index e1872d0..18c97f7 100644 --- a/pagure/hooks/default.py +++ b/pagure/hooks/default.py @@ -232,9 +232,7 @@ def send_notifications( ) -def inform_pull_request_urls( - session, project, commits, refname, default_branch, username -): +def inform_pull_request_urls(session, project, commits, refname, username): """Inform the user about the URLs to open a new pull-request or visit the existing one. """ @@ -242,6 +240,10 @@ def inform_pull_request_urls( if project.is_fork: target_repo = project.parent + taget_repo_obj = pygit2.Repository(target_repo.repopath("main")) + if not taget_repo_obj.is_empty and not taget_repo_obj.head_is_unborn: + default_branch = taget_repo_obj.head.shorthand + pr_uids = [] if (