abhinav / git-spice

Manage stacked Git branches
https://abhinav.github.io/git-spice/
GNU General Public License v3.0
220 stars 11 forks source link

Support setting GitHub URLs via configuration #330

Closed abhinav closed 2 months ago

abhinav commented 2 months ago

Setting GITHUB_URL and GITHUB_API_URL environment variables can be inconvenient. Allow setting these values via git config if desired.

abhinav commented 2 months ago

This change is part of the following stack:

Change managed by git-spice.

messense commented 2 months ago

It'd be really nice if git-spice can infer GHE server and API urls from git remote URL in .git/config when it's not github.com.

abhinav commented 2 months ago

It'd be really nice if git-spice can infer GHE server and API urls from git remote URL in .git/config when it's not github.com.

I agree, but unfortunately, unless there's a clear way to identify GHE servers (e.g. they must always have github.com in their name), that's not possible. While git-spice currently only supports GitHub, I've intentionally tried to keep it forge-agonistic. GitHub-specific details are in a single place. Everything outside that assumes that a repository could be using any forge. It is possible and conceivable to add support for other code forges to git-spice. In fact, most of the CLI behavior tests run against a fake forge with a simpler API that is registered only for tests.

messense commented 2 months ago

Maybe there should be an option to configure the git server type? Then you can infer the API urls based on server type and remote URL, it's just nicer to not have to explicitly write out multiple URLs.

abhinav commented 2 months ago

Maybe there should be an option to configure the git server type? Then you can infer the API urls based on server type and remote URL, it's just nicer to not have to explicitly write out multiple URLs.

Oh, hm. 🤔 Are you suggesting a way to say, "assume all remotes are GitHub"? I can see that being more convenient than the version in this PR.

abhinav commented 2 months ago

Oh, I think I understand what you mean. The configuration would just state that this is a GHES server, and (I guess?) the API URL for those is always /api on the instance URL?

I ask because I agree that that's a better UX, but I'm trying to determine whether that's mutually exclusive with the configuration option offered here. I'll revert this PR if that's the case. If they're not mutually exclusive, I'll leave this PR in, and that option can happen separately.

messense commented 2 months ago

The configuration would just state that this is a GHES server, and (I guess?) the API URL for those is always /api on the instance URL?

exactly, I don't think they are mutually exclusive, it's just a shortcut IMO.

abhinav commented 2 months ago

Created https://github.com/abhinav/git-spice/issues/336.

Separately, @messense, re this:

it's just nicer to not have to explicitly write out multiple URLs.

One obvious convenience we can add here: if GitHub URL is not github.com, then API URL is GitHub URL + "/api". That would help here a little, yes?

messense commented 2 months ago

One obvious convenience we can add here: if GitHub URL is not github.com, then API URL is GitHub URL + "/api". That would help here a little, yes?

Yes, I think so.