#5089 Get the default branch of the target repo when linking for new PR
Merged 3 years ago by pingou. Opened 3 years ago by pingou.

file modified
+5 -3
@@ -232,9 +232,7 @@ 

              )

  

  

- 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 @@ 

      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 (

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 pingou@pingoured.fr

rebased onto 07b517e

3 years ago

Since this code isn't covered by tests, I'm going to merge it directly :)

Pull-Request has been merged by pingou

3 years ago
Metadata