Skip to content
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

Extension fails to detect PR branch when using gh co <PR> #6378

Open
xmatthias opened this issue Oct 23, 2024 · 5 comments
Open

Extension fails to detect PR branch when using gh co <PR> #6378

xmatthias opened this issue Oct 23, 2024 · 5 comments
Assignees
Labels
info-needed Issue requires more information from poster

Comments

@xmatthias
Copy link

xmatthias commented Oct 23, 2024

  • Extension version:v0.99.2024101604 (pre-release)
  • VSCode Version: Version: 1.94.2
  • OS: linux
  • Repository Clone Configuration (single repository/fork of an upstream repository):
  • Github Product (Github.com/Github Enterprise version x.x.x): github.com

the Github Pull Requests extension fails to properly detect pull request branches created by gh co <prnr>.
This breaks flow - as i like the github cli to interact with the repo - but need the extension for the review (where it's great).

I know i could check out via extension, but i very often forget this - so i need to go back to the main branch, checkout the PR branch via extension - just to have the extension realize that this is a pull request branch.

Steps to Reproduce:

  1. have any repository with an open pull request
  2. be logged into the github cli
  3. open terminal
  4. run gh pr list to get a Pull request number
  5. run gh co <prnr> (your repository will now have a different branch checked out)
  6. refresh "github pull requests" view (i also tried refreshing the SCM view to no avail)
  7. Notice it's not recognizing the pull request

In my memory (might be wrong?) this used to work a few months ago - but then stopped working. (i'm opening this issue only now as i hoped that someone else would report this so i don't have to 😆 )

@alexr00 alexr00 self-assigned this Oct 24, 2024
@alexr00 alexr00 added the bug Issue identified by VS Code Team member as probable bug label Oct 24, 2024
@alexr00 alexr00 added this to the November 2024 milestone Oct 24, 2024
@alexr00 alexr00 added info-needed Issue requires more information from poster and removed bug Issue identified by VS Code Team member as probable bug labels Oct 30, 2024
@alexr00 alexr00 removed this from the November 2024 milestone Oct 30, 2024
@alexr00
Copy link
Member

alexr00 commented Oct 30, 2024

I'm not able to repro. Can you share the following:

  • Is your repo a fork?
  • Are you trying to check out a PR that's from the fork to the upstream?
  • What is the local name of the branch after gh co?
  • What is the name of that branch on the remote?

@xmatthias
Copy link
Author

xmatthias commented Oct 30, 2024

The Repo is not a fork - it's freqtrade/freqtrade (though i do have a fork - the Pull request is not against a fork - but from a fork).

on that repo - i tried gh co 10860 - which yields a branch fix-test-download-data-timerange.

it's a random repro using the very latest PR at this point (one i'm sure i haven't had checked out before).

Image

After clicking the "reload" button several times:

Image

with git branch -vv - it shows as follows:

fix-test-download-data-timerange     a8516ff0f [xzmeng/fix-test-download-data-timerange] tests: fix failure when local timezone is not utc
  

If i do the checkout via the extension (rightclick on the PR line - Checkout Pull Request) - i get the branch name pr/xzmeng/10860.
This branch is then detected correctly by the extension

@alexr00
Copy link
Member

alexr00 commented Oct 31, 2024

Thanks that was helpful in narrowing down where the issue might be. I'm still not able to repro though. Can you try the following:

  1. Do your gh co with VS Code open.
  2. Confirm that the PR isn't recognized by the extension.
  3. In your terminal run git remote -v and share the output. Also share your local branch and remote branch again.
  4. Also share all githubPullRequests settings you have set.

@xmatthias
Copy link
Author

xmatthias commented Oct 31, 2024

The only 2 settings i've got set (different from default) are the following two (the latter of which i've tried to remove now - to no avail).
testing now with vscode 1.95.0 ...

    "githubPullRequests.fileListLayout": "tree",
    "githubPullRequests.pullBranch": "never",   // <-- this one i removed now
[xmatt@x1 freqtrade(fix-test-download-data-timerange)] $ git remote -v
[...]
origin  [email protected]:freqtrade/freqtrade.git (fetch)
origin  [email protected]:freqtrade/freqtrade.git (push)
[...]
xmatt   [email protected]:xmatthias/freqtrade.git (fetch)
xmatt   [email protected]:xmatthias/freqtrade.git (push)
xzmeng  [email protected]:xzmeng/freqtrade (fetch)
xzmeng  [email protected]:xzmeng/freqtrade (push)

the interesting part is - if i run into this - and then run "restart extension hots" - then it detects the PR.
if i check out the main branch - and then back to the "gh co" branch (via git checkout) it'll work.

deleting that same branch - and doing the checkout again - i'm again stuck with the extension not detecting this.

gh co 10860 
# Branch name is fix-test-download-data-timerange
# Click refresh button in extension - not showing the PR
# command palette > Restart extension hots
# once the extension loads - it detects the pr
git checkout develop
# PR view is gone (obviously) 
git checkout fix-test-download-data-timerange
# The extension does recognize the PR

# Revert back to develop branch
git checkout develop
# Delete the branch to simulate a new checkout
git branch -D fix-test-download-data-timerange

# gh co again
gh co 10860 

# Click refresh button in extension - not showing the PR
# repeat from above . . . 
Potentially interesting log

starts at the "git checkout fix-test-download-data-timerange" - as far as i can tell

2024-10-31 14:36:56.192 [info] Review+0> Found matching pull request metadata for current branch fix-test-download-data-timerange. Repo: freqtrade/freqtrade PR: 10860
2024-10-31 14:36:56.192 [info] Review+0> current branch fix-test-download-data-timerange is associated with pull request #10860
2024-10-31 14:36:56.192 [info] Review+0> Resolving pull request
2024-10-31 14:36:56.192 [info] FolderRepositoryManager+0> Found GitHub repo for pr #10860: yes
2024-10-31 14:36:57.576 [info] FolderRepositoryManager+0> Found GitHub pr repo for pr #10860: yes
2024-10-31 14:36:57.576 [info] GitHubRepository+0> Fetch branch develop - enter
2024-10-31 14:36:57.883 [info] GitHubRepository+0> Fetch branch develop - done: true
2024-10-31 14:36:57.884 [info] Review+0> Resolved PR #10860, state is 0
2024-10-31 14:36:57.884 [info] Review+0> Fetching pull request data
2024-10-31 14:36:57.884 [info] PullRequestTree> Adding PR #10860 to tree
2024-10-31 14:36:57.994 [info] Review+0> Register comments provider
2024-10-31 14:36:57.994 [info] Review+0> Register in memory content provider
2024-10-31 14:36:59.170 [info] Review+0> Display pull request status bar indicator.
2024-10-31 14:36:59.170 [info] Review+0> Using focus mode = true.
2024-10-31 14:36:59.170 [info] Review+0> State validation silent = true.
2024-10-31 14:36:59.170 [info] Review+0> PR show should show = false.
2024-10-31 14:38:01.158 [info] Review+0> Validate state in progress
2024-10-31 14:38:01.158 [info] Review+0> Validating state...
2024-10-31 14:38:01.240 [info] Found GitHub remote for folder /home/xmatt/devel/cryptos/freqtrade
2024-10-31 14:38:01.248 [info] Using in-memory cached mentionable users.
2024-10-31 14:38:01.248 [info] Using in-memory cached assignable users.
2024-10-31 14:38:01.281 [info] Review+0> No matching pull request metadata found locally for current branch develop
2024-10-31 14:38:02.002 [info] Review+0> No matching pull request metadata found on GitHub for current branch develop
2024-10-31 14:38:02.002 [info] PullRequestTree> Removing PR #10860 from tree
2024-10-31 14:38:06.267 [info] Review+0> Validate state in progress
2024-10-31 14:38:06.267 [info] Review+0> Validating state...
2024-10-31 14:38:06.320 [info] Found GitHub remote for folder /home/xmatt/devel/cryptos/freqtrade
2024-10-31 14:38:06.326 [info] Using in-memory cached assignable users.
2024-10-31 14:38:06.371 [info] Review+0> No matching pull request metadata found locally for current branch fix-test-download-data-timerange
2024-10-31 14:38:06.371 [info] Review+0> No matching pull request metadata found on GitHub for current branch fix-test-download-data-timerange

It's interesting that it first knows "ah, this branch is PR xxx" - and then "no metadata ... no clue what this is" (at the last 2-3 lines).

@xmatthias
Copy link
Author

xmatthias commented Nov 11, 2024

An additional point to notice:
if the Pull request is from the main repo (e.g. a dependabot PR) - the extension does recognize the "gh co " immediately - suggesting that it's a problem with other repos only (which are either not properly added as remote - or not properly linked to the branch).

Additional logs from the extension output

2024-11-11 07:09:13.745 [info] Review+0> Validate state in progress
2024-11-11 07:09:13.745 [info] Review+0> Validating state...
2024-11-11 07:09:13.896 [info] Found GitHub remote for folder /home/xmatt/devel/cryptos/freqtrade
2024-11-11 07:09:13.903 [info] Trying to use globalState for mentionableUsers.
2024-11-11 07:09:13.903 [info] Using in-memory cached assignable users.
2024-11-11 07:09:13.939 [info] Review+0> Found matching pull request metadata for current branch dependabot/pip/develop/websockets-14.0. Repo: freqtrade/freqtrade PR: 10910
2024-11-11 07:09:13.939 [info] Review+0> current branch dependabot/pip/develop/websockets-14.0 is associated with pull request #10910
2024-11-11 07:09:13.939 [info] Review+0> Resolving pull request
2024-11-11 07:09:13.939 [info] FolderRepositoryManager+0> Found GitHub repo for pr #10910: yes
2024-11-11 07:09:14.059 [info] Using globalState mentionableUsers for 2.
2024-11-11 07:09:14.790 [info] FolderRepositoryManager+0> Found GitHub pr repo for pr #10910: yes
2024-11-11 07:09:14.790 [info] GitHubRepository+0> Fetch branch develop - enter
2024-11-11 07:09:15.223 [info] GitHubRepository+0> Fetch branch develop - done: true
2024-11-11 07:09:15.223 [info] Review+0> Resolved PR #10910, state is 0
2024-11-11 07:09:16.847 [info] Review+0> Validate state in progress
2024-11-11 07:09:16.847 [info] Review+0> Validating state...
2024-11-11 07:09:16.998 [info] Found GitHub remote for folder /home/xmatt/devel/cryptos/freqtrade
2024-11-11 07:09:17.007 [info] Using in-memory cached mentionable users.
2024-11-11 07:09:17.007 [info] Using in-memory cached assignable users.
2024-11-11 07:09:17.037 [info] Review+0> Found matching pull request metadata for current branch dependabot/pip/develop/websockets-14.0. Repo: freqtrade/freqtrade PR: 10910
2024-11-11 07:09:17.037 [info] Review+0> current branch dependabot/pip/develop/websockets-14.0 is associated with pull request #10910
2024-11-11 07:09:17.037 [info] Review+0> Resolving pull request
2024-11-11 07:09:17.037 [info] FolderRepositoryManager+0> Found GitHub repo for pr #10910: yes
2024-11-11 07:09:17.752 [info] FolderRepositoryManager+0> Found GitHub pr repo for pr #10910: yes
2024-11-11 07:09:17.752 [info] GitHubRepository+0> Fetch branch develop - enter
2024-11-11 07:09:18.086 [info] GitHubRepository+0> Fetch branch develop - done: true
2024-11-11 07:09:18.086 [info] Review+0> Resolved PR #10910, state is 0
2024-11-11 07:09:18.086 [info] Review+0> Fetching pull request data
2024-11-11 07:09:18.086 [info] PullRequestTree> Adding PR #10910 to tree
2024-11-11 07:09:18.086 [info] PullRequestTree> PR #10910 already exists in tree
2024-11-11 07:09:18.087 [info] Review+0> Register comments provider
2024-11-11 07:09:18.117 [info] Review+0> Register in memory content provider
2024-11-11 07:09:18.117 [info] FolderRepositoryManager+0> Found GitHub repo for pr #10910: yes
2024-11-11 07:09:18.445 [error] GitHubRepository+0> Error querying GraphQL API: GraphQL error: Fragment ReviewComment was used, but not defined. useAndDefineFragment
2024-11-11 07:09:18.751 [error] GitHubRepository+0> Error querying GraphQL API: GraphQL error: Fragment ReviewComment was used, but not defined. useAndDefineFragment
2024-11-11 07:09:18.751 [error] PullRequestModel> Failed to get pull request review comments: Error: GraphQL error: Fragment ReviewComment was used, but not defined
2024-11-11 07:09:18.805 [info] Review+0> Display pull request status bar indicator.
2024-11-11 07:09:18.805 [info] Review+0> Using focus mode = true.
2024-11-11 07:09:18.805 [info] Review+0> State validation silent = true.
2024-11-11 07:09:18.805 [info] Review+0> PR show should show = false.
2024-11-11 07:09:18.985 [info] FolderRepositoryManager+0> Found GitHub pr repo for pr #10910: yes
2024-11-11 07:09:19.128 [error] GitHubRepository+0> Error querying GraphQL API: GraphQL error: Fragment ReviewComment was used, but not defined. useAndDefineFragment
2024-11-11 07:09:19.406 [error] GitHubRepository+0> Error querying GraphQL API: GraphQL error: Fragment ReviewComment was used, but not defined. useAndDefineFragment
2024-11-11 07:09:19.406 [error] PullRequestModel> Failed to get pull request review comments: Error: GraphQL error: Fragment ReviewComment was used, but not defined
2024-11-11 07:09:52.238 [info] FolderRepositoryManager+0> Found GitHub repo for pr #10910: yes
2024-11-11 07:09:52.811 [info] FolderRepositoryManager+0> Found GitHub pr repo for pr #10910: yes
2024-11-11 07:09:53.978 [error] GitHubRepository+0> Error querying GraphQL API: GraphQL error: Fragment ReviewComment was used, but not defined. useAndDefineFragment
2024-11-11 07:09:54.285 [error] GitHubRepository+0> Error querying GraphQL API: GraphQL error: Fragment ReviewComment was used, but not defined. useAndDefineFragment
2024-11-11 07:09:54.286 [error] PullRequestModel> Failed to get pull request review comments: Error: GraphQL error: Fragment ReviewComment was used, but not defined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants