ejoffe / spr

Stacked Pull Requests on GitHub
MIT License
717 stars 65 forks source link

Use without Github CLI #350

Closed Kinrany closed 10 months ago

Kinrany commented 10 months ago

Is spr usable without gh?

The first error I got from git spr -h was

10:13PM WRN ../../../runner/work/spr/spr/github/githubclient/client.go:101 > failed to read hub config file error="failed to open hub config file: open <snip>/.config/hub: no such file or directory"

No GitHub OAuth token found! You can either create one
at https://github.com/settings/tokens and set the GITHUB_TOKEN environment variable,
or use the official "gh" CLI (https://cli.github.com) config to log in:

    $ gh auth login

Alternatively, configure a token manually in ~/.config/hub:

    github.com:
    - user: <your username>
      oauth_token: <your token>
      protocol: https

I created ~/.config/hub with a new token. But the next invocation of git spr -h complains that hosts.yml doesn't exist:

10:41PM WRN ../../../runner/work/spr/spr/github/githubclient/client.go:89 > failed to read gh cli config file error="failed to open gh cli config file: open <snip>/.config/gh/hosts.yml: no such file or directory"

So do other commands, and all of them seem to work other than this warning.

Overall, it's not clear where gh falls on the spectrum between a strict requirement and a small convenience.

ejoffe commented 10 months ago

Try the first approach: create a token at https://github.com/settings/tokens and set the GITHUB_TOKEN environment variable. No github cli needed.

Kinrany commented 10 months ago

You mean, place the token in an env variable instead of ~/.config/hub?

ejoffe commented 10 months ago

Yes, exactly. I have the GITHUB_TOKEN env set with the token value exported in my bashrc.

Kinrany commented 10 months ago

That works, thank you!

Had to ask because it was surprising based on the help message that the two would work differently. I'm guessing this is because ~/.config/hub is being read by a third-party library.

Kinrany commented 10 months ago

Closed because there's no bug or anything, but please feel free to reopen/edit the OP if you still need it!