From c80783abe47aef72319244c06e56c9066f4ad10e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 28 2017 18:54:10 +0000 Subject: [PATCH 1/2] Fix diffing the branch of a project against the target branch We used to check the local branches against the local default branch (ie most often master) but this failed in a few situation: a) when the master of the fork was lagging behind the one of the main repo (in which case it would offer a PR for things that had already been included) b) when the changes in the fork were actually in the master branch (since it skipped master to master comparison). With this commit we are now comparing the local branches to the default branch of the main repo, still skipping comparing default to default if the repo is not a fork. Fixes https://pagure.io/pagure/issue/2354 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index 48c56ed..c4637fe 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -262,10 +262,16 @@ def get_pull_request_ready_branch(): reponame = pagure.get_repo_path(repo) repo_obj = pygit2.Repository(reponame) + if repo.is_fork: + parentreponame = pagure.get_repo_path(repo.parent) + parent_repo_obj = pygit2.Repository(parentreponame) + else: + parent_repo_obj = repo_obj branches = {} if not repo_obj.is_empty and repo_obj.listall_branches() > 1: - if not repo_obj.head_is_unborn: + if not parent_repo_obj.is_empty \ + and not parent_repo_obj.head_is_unborn: compare_branch = repo_obj.head.shorthand else: compare_branch = None @@ -273,14 +279,15 @@ def get_pull_request_ready_branch(): for branchname in repo_obj.listall_branches(): # Do not compare a branch to itself - if compare_branch \ + if not repo.is_fork \ + and compare_branch \ and compare_branch == branchname: continue diff_commits = None try: _, diff_commits, _ = pagure.lib.git.get_diff_info( - repo_obj, repo_obj, branchname, compare_branch) + repo_obj, parent_repo_obj, branchname, compare_branch) except pagure.exceptions.PagureException: pass From 5894347477b10a52753cd272ed767bc834d2462f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 28 2017 18:54:10 +0000 Subject: [PATCH 2/2] Fix displaying the new PR button on the default branch Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/repo_info.html b/pagure/templates/repo_info.html index 486994e..8252a25 100644 --- a/pagure/templates/repo_info.html +++ b/pagure/templates/repo_info.html @@ -86,7 +86,7 @@ git push -u origin master
{% if head %}
-
+
{% if branchname == head %} @@ -104,7 +104,7 @@ git push -u origin master {% endif %}
-
+