Skip to content

Add an option to choose oldest associated PR with a commit vs newest #1913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ian-h-chamberlain opened this issue Mar 16, 2022 · 3 comments
Milestone

Comments

@ian-h-chamberlain
Copy link
Contributor

  • GitLens Version: v12.0.4
  • Git Version: 2.32.0
  • VSCode Version: 1.65.2; c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1; x64
  • OS Version: macOS 11.6.2

First, let me set some context – my organization maintains a number of active branches for backporting fixes to older versions of software. In most cases, the fix is delivered to an old branch, then merged forward in a later pull request. I believe this is part of the root cause of the problem.

Steps to Reproduce:

  1. Find a commit that is associated with multiple GitHub pull requests – perhaps a cherry-pick from one branch to another or something like that
  2. Open File At Revision From... and choose the branch the first PR was originally targeted to (maybe not necessary? just how I reproduce it)
  3. Hover on line blame and observe the via PR# message.

In my case, the resulting PR number seemed to the be the second-lowest numbered PR associated with the commit, but that might just be change. I think it would be preferable to use the lowest-numbered PR associated with the commit, although perhaps others would prefer something else, so maybe this would need to be configurable if there is a use-case for higher numbered PRs?

Alternatively, show all the PRs associated with a commit, but that seems more difficult to integrate in the UI etc., and is probably not very helpful anyway.

Unfortunately, the repo I saw this in is private, but please let me know if there's anything else I can provide to help. If necessary I can probably reproduce in a new public repository as well.

@ian-h-chamberlain ian-h-chamberlain added potential-bug triage Needs to be looked at labels Mar 16, 2022
@eamodio
Copy link
Member

eamodio commented Mar 16, 2022

GitLens currently asks GitHub for the two most recently updated PRs, and if there is more than one result, then it sorts them first by matching repo owner (to deal with PRs on forks), then open PRs first, and then by updated date/time.

The goal is to return the most recently updated PR. Are you looking for the oldest PR?

@eamodio eamodio added needs-more-info Needs further information, steps, details, etc. and removed triage Needs to be looked at labels Mar 16, 2022
@ian-h-chamberlain
Copy link
Contributor Author

Ok, sounds like some though has been put into it already, so maybe my opinion / use case is a bit unusual.

The goal is to return the most recently updated PR. Are you looking for the oldest PR?

Yeah, I guess so – usually, I'm interested in reading the PR description and/or finding related issues, which in my org are found most easily by the original (oldest) PR where the change was first proposed + merged.

Also worth noting is that, in cases where I'm using Open File At Revision From... for an old branch, then opening the PR, the most recently updated PR may not even be targeted to that branch, making it irrelevant (and I would rather see the PR where it was delivered to the selected branch instead).

Based on your description of the issue, it sounds like maybe a configuration option would make sense, since perhaps my preferred heuristic for linking a PR is different from other users'.

@eamodio
Copy link
Member

eamodio commented Mar 17, 2022

Interesting -- I'll have to look a bit more into this scenario to better understand what I can do here. I'm not sure I can reasonably tell the "branch" when using the Open File At Revision From... (since I think that context will already be lost since it will now be a specific sha). GitLens currently just asking GitHub to give me the PRs associated with a commit sha.

But as for picking the oldest vs the newest, I think it makes sense to offer an option here.

@eamodio eamodio added feature and removed needs-more-info Needs further information, steps, details, etc. potential-bug labels Mar 17, 2022
@eamodio eamodio added this to the Backlog milestone Mar 17, 2022
@eamodio eamodio changed the title Incorrect GitHub PR number associated with change delivered to multiple branches Add an option to choose oldest associated PR with a commit vs newest Mar 17, 2022
aaron-skydio added a commit to aaron-skydio/vscode-gitlens that referenced this issue Nov 18, 2023
aaron-skydio added a commit to aaron-skydio/vscode-gitlens that referenced this issue Nov 18, 2023
…given commit

Currently, the pull request selected for a commit is the most recently
updated one.  As mentioned in gitkraken#1913, this is not always desired, for
example when a feature merges to one branch, and then that branch is
merged into additional branches.

This adds a setting to order by updated or created time, ascending or
descending.  It preserves the other behavior, of preference based
on owner and merged status.
aaron-skydio added a commit to aaron-skydio/vscode-gitlens that referenced this issue Nov 18, 2023
…given commit

Currently, the pull request selected for a commit is the most recently
updated one.  As mentioned in gitkraken#1913, this is not always desired, for
example when a feature merges to one branch, and then that branch is
merged into additional branches.

This adds a setting to order by updated or created time, ascending or
descending.  It preserves the other behavior, of preference based
on owner and merged status.
aaron-skydio added a commit to aaron-skydio/vscode-gitlens that referenced this issue Nov 18, 2023
…given commit

Currently, the pull request selected for a commit is the most recently
updated one.  As mentioned in gitkraken#1913, this is not always desired, for
example when a feature merges to one branch, and then that branch is
merged into additional branches.

This adds a setting to order by updated or created time, ascending or
descending.  It preserves the other behavior, of preference based
on owner and merged status.
aaron-skydio added a commit to aaron-skydio/vscode-gitlens that referenced this issue Nov 18, 2023
…given commit

Currently, the pull request selected for a commit is the most recently
updated one.  As mentioned in gitkraken#1913, this is not always desired, for
example when a feature merges to one branch, and then that branch is
merged into additional branches.

This adds a setting to order by updated or created time, ascending or
descending.  It preserves the other behavior, of preference based
on owner and merged status.
@d13 d13 removed the feature label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants