diff --git a/pagure/internal/__init__.py b/pagure/internal/__init__.py index ed939e6..b07e6c0 100644 --- a/pagure/internal/__init__.py +++ b/pagure/internal/__init__.py @@ -316,6 +316,14 @@ def get_pull_request_ready_branch(): break branch_commits.append(branch_commit.hex) + # If master is ahead of branch, we need to remove the commits + # that are already in master + branch_commits = [ + com + for com in branch_commits + if com.oid.hex not in main_commits + ] + if branch_commits: branches[branchname] = branch_commits diff --git a/pagure/lib/git.py b/pagure/lib/git.py index bcc17cf..702119a 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -1397,6 +1397,14 @@ def diff_pull_request( diff_commits.append(branch_commit) + # If master is ahead of branch, we need to remove the commits + # that are already in master + diff_commits = [ + com + for com in diff_commits + if com.oid.hex not in main_commits + ] + if request.status and diff_commits: first_commit = repo_obj[diff_commits[-1].oid.hex] # Check if we can still rely on the merge_status diff --git a/pagure/ui/fork.py b/pagure/ui/fork.py index 1e8d0ce..e8923fc 100644 --- a/pagure/ui/fork.py +++ b/pagure/ui/fork.py @@ -116,6 +116,14 @@ def _get_pr_info(repo_obj, orig_repo, branch_from, branch_to): diff_commits.append(branch_commit) + # If master is ahead of branch, we need to remove the commits + # that are already in master + diff_commits = [ + com + for com in diff_commits + if com.oid.hex not in main_commits + ] + if diff_commits: first_commit = repo_obj[diff_commits[-1].oid.hex] if len(first_commit.parents) > 0: