microsoft / vscode-pull-request-github

GitHub Pull Requests for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github
MIT License
2.31k stars 580 forks source link

GitHub Pull Requests in CodeSpace can not access ${owner}/${repository} #5700

Open lakruzz opened 9 months ago

lakruzz commented 9 months ago

Problem:

The following query doesn't render anything:

          {
            "label": "Created Issues",
            "query": "author:${user} state:open repo:${owner}/${repository} sort:created-desc"
          }

If I add something like this it gives a list of all issues I created

        {
            "label": "All Issues I created",
            "query": "author:${user} state:open sort:created-desc"
        }

But that also triggers the previous query to suddenly show something - although it's not from the current repo, but another repo in my organisation.

I then tried to hardwire the repo to one that is public - and that works fine.

Questions:

alexr00 commented 9 months ago

How does authentication work in a CodeSpace - it seems like the GitHub for VS Code extension is only used by VS Code.

GitHub Pull Requests also uses the GitHub Authentication extension.

How can I test what ${user}, ${owner} and ${repository} renders to? Is there an execution log from the GitHub Pull Requests extension I can turn on or get access to?

We don't currently log this, but I've just added it with https://github.com/microsoft/vscode-pull-request-github/pull/5723

alexr00 commented 9 months ago

The following query doesn't render anything:

I tried with the same query, but I can't repro this. Can you share the output from GitHub Pull Request?

lakruzz commented 5 months ago

Hi @alexr00 Thanks for getting back - I really appreciated that - and sorry for my late reply.

I also have troubles reproducing this 🤷‍♂️ and I always only saw it in one particular of my repositories - all others worked fine.


May or may not be related, This is merely a theory or suspicion:

What I have seen occasionally is that some containers, even the curated ones from Microsoft, create a hick-up about the repository being dubious and suggests running git config --global safe.directory ...

I can't consistently reproduce this either - it comes and goes. But I think I found a solution.

I used to run my container's postCreateCommand like this ()

"postCreateCommand": "$(git rev-parse --show-toplevel)/.devcontainer/postcreate.sh"

But that didn't always work either - since git rev-parse --show-toplevel can't run in an unsafe repo. Now I do this instead:

"postCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"postStartCommand": "$(git rev-parse --show-toplevel)/.devcontainer/postcreate.sh"

It works. git config isn't dependant on a git repo - only git being installed available. And post start runs after post create, so by the time I run the postStartCommand the git repo is no longer dubious.

I still don't know the root cause for this phenomena though.