jordanlewis / re

re is a ✨CLI ✨code review tool for GitHub. Do code reviews from the comfort of your $EDITOR!
Apache License 2.0
53 stars 4 forks source link

Can't infer private repositories #19

Open NicolaiRuckel opened 3 years ago

NicolaiRuckel commented 3 years ago

While switching to the GitHub API made the tool a lot better, but unfortunately it doesn't work for private repositories. Interestingly, I got two different kinds of problems, and I'm not sure where the repositories differ.

For the first repository, I got the following:

$ re
unable to infer project from git repo; assuming cockroachdb/cockroach

Of course, I can just specify the repository with -p but it would be nice if this could be detected automatically, too. I started to implement that in my fork before you switched to the GitHub API. I didn't finish that since I didn't understand the GitHub API at all. :sweat_smile:

For the other repository, I got the following error

$ re
2021/07/24 11:26:04 GET https://api.github.com/search/issues?q=type:pull-request+state:open+repo:NicolaiRuckel%2FPaper+involves:NicolaiRuckel+updated:%3E=2021-06-24&page=1&per_page=100&sort=created: 422 Validation Failed [{Resource:Search Field:q Code:invalid Message:The listed users and repositories cannot be searched either because the resources do not exist or you do not have permission to view them.}]

If I specify the project with -p it works. I even tried to clone the repository again to make sure I didn't mess up anything locally. Do you have any idea why this could happen? It looks like the repository name in the GET request got cut off after a hyphen. The repository for the first example also contains a hyphen, even though I get a different error.

jordanlewis commented 3 years ago

You need to add more permissions to your personal access token to let it work with private repos - i think you need repo scope not just public_repo

NicolaiRuckel commented 3 years ago

That's what I did. screenshot_2021-07-25-175949 From the output, it looks like the URL is inferred wrong. I created a new private repository, and it works flawless for that though. :thinking:

NicolaiRuckel commented 3 years ago

It seems to be a problem with the hyphen in the repository name. The URL gets cut off at the hyphen. Interestingly, this only occurs if the repository was created with a hyphen in its name. If I create a repository without a hyphen and then change to name to include a hyphen, it works.