owenthereal / gh

Fast GitHub command line client (deprecated). gh has been merged into https://github.com/github/hub, see https://github.com/github/hub/issues/475 for more info
MIT License
720 stars 48 forks source link

Set `gh.host` after a successful clone. #188

Closed calavera closed 8 years ago

calavera commented 10 years ago

We assume that if you're using gh to clone a repo this one is on GitHub or GitHub Enterprise. This way, when you use command that requires the host for the first time it's already set.

calavera commented 10 years ago

@jingweno what do you think about this?

I think it's useful for people that use enterprise and harmless for everybody else.

owenthereal commented 10 years ago

I don't have much experience working with GHE but I could imagine it will be more friendly this way. It would be nice though if we could print that gh.host has been set, instead of a silent update.

On the other hand, I'm questioning the usefulness of gh.host. It's a setting inherited from Hub and it's to make sure github commands are not talking to non-github servers. But users'll know if a github command fails anyways. Maybe there're other reasons I'm not aware of.

calavera commented 10 years ago

On the other hand, I'm questioning the usefulness of gh.host. It's a setting inherited from Hub and it's to make sure github commands are not talking to non-github servers. But they'll know if a command fails anyways. Maybe there're other reasons I missed

I feel the same.

At the end, all this is only to work around the fact that we have assumptions about what a github server is. We could probably leave that to the users, if they say that "http://foobar" is a github server so be it, we shouldn't check if we have it in a static list or if we like the protocol that it uses.

calavera commented 10 years ago

@mislav we're wondering about the usefulness of gh.host. Is it useful for anything else but avoiding sending github commands to non github servers?

mislav commented 10 years ago

It's for whitelisting Enterprise hosts. So that you know a remote points to a GitHub instance even if it's not to github.com per se.

I don't like it. I've been meaning to replace it with a specialized command for authentication. Something like:

$ hub auth git.my.org
# performs user/pass authentication, 2FA
# manages OAuth keys
# saves settings for this host, e.g. if it uses HTTPS (default) or HTTP

If you can't authenticate to an Enterprise via username/password (e.g. if you have to go through some 3rd party web flow in your organization) then you need to generate a Personal Token in the web UI and you should be able to pass it to hub:

$ hub auth --add-token git.my.org
Paste your token: ***
owenthereal commented 10 years ago

I like the idea of authenticating against different GitHub hosts. With a new auth command against a particular host, we could get away from having the gh.host setting since all information of known hosts and credentials will be available in ~/.config/gh. Any host that's not authenticated, they'll be whitelisted.