vscode-pull-request-github icon indicating copy to clipboard operation
vscode-pull-request-github copied to clipboard

Don't show error "We couldn't find commit" on outdated comments

Open ggcatu opened this issue 6 years ago • 10 comments

Issue Type: Bug

Constantly getting this error, is really annoying and breaks the complete usage of the extension.

image

image

Extension version: 0.15.0 VS Code version: Code 1.44.2 (ff915844119ce9485abfe8aa9076ec76b5300ddd, 2020-04-16T16:36:23.138Z) OS version: Windows_NT x64 10.0.18363

ggcatu avatar Apr 24 '20 10:04 ggcatu

Same. I think it's related to having multiple projects in your workspace, and the wrong one getting loaded. I couldn't even get the thing to load at all until I found this workaround. https://github.com/microsoft/vscode-pull-request-github/issues/1330#issuecomment-529576350

Roughly, I think the important ingredients to recreate this should be something like:

  1. add additional projects to your vscode workspace (possibly add extension / reload at this point)
  2. create a branch locally
  3. commit/push some work to that branch
  4. apply the above workaround to get the PR panels to show up at all
  5. from the project with the new branch create a PR
  6. browse the files of the PR in the Local Pull Request Branches view of this extension (observe expected behavior)
  7. browse "Files" in "Changes in Pull Request" panel, observe expected behavior
  8. browse "Commits" in that same panel, and observe the error reported by @ggcatu and files either don't load or display diff as if the file were new

Thanks

ThomasGHenry avatar May 19 '20 15:05 ThomasGHenry

I think this has been fixed in the mean time. If you're still seeing it please ping this issue and I will reopen!

alexr00 avatar Dec 12 '22 14:12 alexr00

@alexr00 I am still seeing this quite often. Not as a result of multiple projects, but as a result of force-pushes that remove a commit from the PR branch.

For example, I had https://github.com/nextstrain/ncov/commit/4e5ee678e3e4f6a8256955c8c1ab99d2fccecd60 in a PR branch. I then force-pushed to drop the commit (over a month ago). I just cloned and opened the repo on a new computer and got the message

We couldn't find commit 4e5ee678e3e4f6a8256955c8c1ab99d2fccecd60 ...

victorlin avatar Aug 22 '24 18:08 victorlin

@victorlin did you have the default branch checked out? Was that commit on the default branch?

alexr00 avatar Aug 22 '24 19:08 alexr00

@alexr00 It happened on a fresh clone of the repo with the default branch checked out. The commit was never on the default branch.

victorlin avatar Aug 22 '24 20:08 victorlin

Is there an open PR that contains the commit somehow? Can you share your value of the setting githubPullRequests.queries?

alexr00 avatar Aug 22 '24 20:08 alexr00

It's not on any open PR/branch. I think if that were the case, it would show up on the commit page https://github.com/nextstrain/ncov/commit/4e5ee678e3e4f6a8256955c8c1ab99d2fccecd60

My setting is "githubPullRequests.queries": [] (I've removed the default queries).

victorlin avatar Aug 22 '24 21:08 victorlin

@alexr00 I just observed this again in another repo (nextstrain/nextstrain.org):

We couldn't find commit 5709c3ce11f60cf66fa4ae3604643018e70e2e00 locally. You may want to sync the branch with remote. Sometimes commits can disappear after a force-push

Commit is available in the remote as https://github.com/nextstrain/nextstrain.org/commit/5709c3ce11f60cf66fa4ae3604643018e70e2e00 but not locally:

$ git log -1 5709c3ce11f60cf66fa4ae3604643018e70e2e00
fatal: bad object 5709c3ce11f60cf66fa4ae3604643018e70e2e00
Here are the extension logs with irrelevant system paths redacted
2024-08-27 16:20:30.378 [info] Activation> Extension version: 0.94.0
2024-08-27 16:20:30.646 [info] Looking for git repository
2024-08-27 16:20:30.646 [info] Found 0 repositories during activation
2024-08-27 16:20:30.646 [info] Git repository found, initializing review manager and pr tree view.
2024-08-27 16:20:30.646 [info] Registering git provider
2024-08-27 16:20:33.169 [info] Activation> Extension version: 0.94.0
2024-08-27 16:20:33.317 [info] Looking for git repository
2024-08-27 16:20:33.317 [info] Found 0 repositories during activation
2024-08-27 16:20:33.317 [info] Git repository found, initializing review manager and pr tree view.
2024-08-27 16:20:33.319 [info] Registering git provider
2024-08-27 16:20:33.319 [info] Review+0> Validate state in progress
2024-08-27 16:20:33.319 [info] Review+0> Validating state...
2024-08-27 16:20:33.331 [info] Found GitHub remote for folder …/nextstrain/nextstrain.org
2024-08-27 16:20:33.636 [info] Trying to use globalState for assignableUsers.
2024-08-27 16:20:33.698 [info] Review+0> Found matching pull request metadata for current branch rss-feed-932. Repo: nextstrain/nextstrain.org PR: 990
2024-08-27 16:20:33.698 [info] Review+0> current branch rss-feed-932 is associated with pull request #990
2024-08-27 16:20:33.698 [info] Review+0> Resolving pull request
2024-08-27 16:20:33.698 [info] FolderRepositoryManager+0> Found GitHub repo for pr #990: yes
2024-08-27 16:20:33.730 [info] Using globalState assignableUsers for 1.
2024-08-27 16:20:34.276 [info] Repo state for file://…/nextstrain/nextstrain.org changed.
2024-08-27 16:20:34.276 [info] Repo file://…/nextstrain/nextstrain.org has already been setup.
2024-08-27 16:20:34.348 [info] FolderRepositoryManager+0> Found GitHub pr repo for pr #990: yes
2024-08-27 16:20:34.348 [info] GitHubRepository+0> Fetch branch master - enter
2024-08-27 16:20:34.525 [info] GitHubRepository+0> Fetch branch master - done: true
2024-08-27 16:20:34.528 [info] Review+0> Resolved PR #990, state is 0
2024-08-27 16:20:34.528 [info] Review+0> Fetching pull request data
2024-08-27 16:20:34.528 [info] PullRequestTree> Adding PR #990 to tree
2024-08-27 16:20:34.733 [info] Review+0> Register comments provider
2024-08-27 16:20:34.733 [info] Review+0> Register in memory content provider
2024-08-27 16:20:35.200 [info] Review+0> Display pull request status bar indicator.
2024-08-27 16:20:35.200 [info] Review+0> Using focus mode = true.
2024-08-27 16:20:35.200 [info] Review+0> State validation silent = true.
2024-08-27 16:20:35.200 [info] Review+0> PR show should show = false.
2024-08-27 16:20:36.193 [info] GitContentFileSystemProvider> Getting change model (file://…/nextstrain/nextstrain.org) content for commit 85b014eb490eee0bcdc663e61cc3e00c69fe1a76 and path …/nextstrain/nextstrain.org/static-site/src/util/blogPosts.js
2024-08-27 16:20:36.194 [info] GitContentFileSystemProvider> Getting repository (file://…/nextstrain/nextstrain.org) content for commit 85b014eb490eee0bcdc663e61cc3e00c69fe1a76 and path …/nextstrain/nextstrain.org/static-site/src/util/blogPosts.js
2024-08-27 16:20:36.194 [info] GitContentFileSystemProvider> Getting change model (file://…/nextstrain/nextstrain.org) content for commit 5709c3ce11f60cf66fa4ae3604643018e70e2e00 and path …/nextstrain/nextstrain.org/static-site/src/components/layout.jsx
2024-08-27 16:20:36.196 [info] GitContentFileSystemProvider> Getting repository (file://…/nextstrain/nextstrain.org) content for commit 5709c3ce11f60cf66fa4ae3604643018e70e2e00 and path …/nextstrain/nextstrain.org/static-site/src/components/layout.jsx
2024-08-27 16:20:36.196 [info] GitContentFileSystemProvider> Getting change model (file://…/nextstrain/nextstrain.org) content for commit 5709c3ce11f60cf66fa4ae3604643018e70e2e00 and path …/nextstrain/nextstrain.org/static-site/src/util/blogPosts.js
2024-08-27 16:20:36.198 [info] GitContentFileSystemProvider> Getting repository (file://…/nextstrain/nextstrain.org) content for commit 5709c3ce11f60cf66fa4ae3604643018e70e2e00 and path …/nextstrain/nextstrain.org/static-site/src/util/blogPosts.js
2024-08-27 16:20:36.199 [info] GitContentFileSystemProvider> Getting change model (file://…/nextstrain/nextstrain.org) content for commit 5709c3ce11f60cf66fa4ae3604643018e70e2e00 and path …/nextstrain/nextstrain.org/package.json
2024-08-27 16:20:36.200 [info] GitContentFileSystemProvider> Getting repository (file://…/nextstrain/nextstrain.org) content for commit 5709c3ce11f60cf66fa4ae3604643018e70e2e00 and path …/nextstrain/nextstrain.org/package.json
2024-08-27 16:20:36.201 [info] GitContentFileSystemProvider> Getting change model (file://…/nextstrain/nextstrain.org) content for commit 43a922fb76960f818e28cb64a0b0139c27ec81ff and path …/nextstrain/nextstrain.org/static-site/data/SiteConfig.jsx
2024-08-27 16:20:36.201 [info] GitContentFileSystemProvider> Getting repository (file://…/nextstrain/nextstrain.org) content for commit 43a922fb76960f818e28cb64a0b0139c27ec81ff and path …/nextstrain/nextstrain.org/static-site/data/SiteConfig.jsx
2024-08-27 16:20:36.201 [info] GitContentFileSystemProvider> Getting change model (file://…/nextstrain/nextstrain.org) content for commit 43a922fb76960f818e28cb64a0b0139c27ec81ff and path …/nextstrain/nextstrain.org/static-site/src/util/blogFeeds.js
2024-08-27 16:20:36.202 [info] GitContentFileSystemProvider> Getting repository (file://…/nextstrain/nextstrain.org) content for commit 43a922fb76960f818e28cb64a0b0139c27ec81ff and path …/nextstrain/nextstrain.org/static-site/src/util/blogFeeds.js
2024-08-27 16:20:36.267 [info] GitContentFileSystemProvider> Using fallback content provider.
2024-08-27 16:20:36.273 [info] GitContentFileSystemProvider> Using fallback content provider.
2024-08-27 16:20:36.278 [info] GitContentFileSystemProvider> Using fallback content provider.
2024-08-27 16:20:36.282 [info] GitContentFileSystemProvider> Using fallback content provider.
2024-08-27 16:20:36.287 [error] Failed to execute git
2024-08-27 16:20:36.295 [error] Failed to execute git
2024-08-27 16:20:36.298 [error] Failed to execute git
2024-08-27 16:20:36.298 [error] Failed to execute git
2024-08-27 16:20:37.011 [info] Review+0> Validate state in progress
2024-08-27 16:20:37.011 [info] Review+0> Validating state...
2024-08-27 16:20:37.071 [info] Found GitHub remote for folder …/nextstrain/nextstrain.org
2024-08-27 16:20:37.072 [info] Trying to use globalState for mentionableUsers.
2024-08-27 16:20:37.072 [info] Using in-memory cached assignable users.
2024-08-27 16:20:37.087 [info] Using globalState mentionableUsers for 1.
2024-08-27 16:20:37.103 [info] Review+0> No matching pull request metadata found locally for current branch master
2024-08-27 16:20:37.652 [info] Review+0> No matching pull request metadata found on GitHub for current branch master
2024-08-27 16:20:37.652 [info] PullRequestTree> Removing PR #990 from tree

Let me know if you need anything else or if I should open a separate issue for better visibility, since this one is still in closed state.

victorlin avatar Aug 27 '24 23:08 victorlin

I think I found a way to reproduce:

  1. Make a comment on changes from a certain commit in a PR
  2. Remove/update that commit (e.g. via force push)
  3. Open the comment in the extension
  4. Observe error

Here's a demo:

https://github.com/user-attachments/assets/5b93d5ff-347a-4831-aed5-3462aea983a1

victorlin avatar Aug 28 '24 21:08 victorlin

I've been able to repro this. The commit really just doesn't exist anymore when this happens. We're not going to be able to show comments that belong to that commit on the correct line, and we're not going to be able to show file contents for that commit. I think the most reasonable thing to do is to just suppress the error if we know it's for an outdated commit.

alexr00 avatar Sep 03 '24 13:09 alexr00