-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add protocol flag for gh repo create #3088
Comments
Btw, just to say, I'm also open to alternative solutions here. Not hell-bend on the protocol flag. Just looking for a clean and seamless way to create a repo for the user and push the main branch onto the repo. |
@driesvints I think I would rather see this an an environment variable that all git invocations respect than a command flag since that would entail editing all existing commands that have git functionality to use this new flag. As a temporary solution thought, since this is an automated script, could you not retrieve the current users |
Thanks for thinking on this! I'm not sure if that's the right solution. If any of the commands fail between the calls, it could leave the user's preference in an unwanted state. |
like @samcoe , I would also rather see this feature begin its life as an environment variable since that is consistent with the way we override other configurable things. does that work for you, @driesvints ? |
Something like this? GH_PROTOCOL=ssh gh repo create |
@driesvints yep |
Sounds perfect to me 👍 |
@driesvints Keep in mind that once #2944 gets solved, I'm not opposed to something like a Ref. #2189 |
@mislav I fully agree with you here. The main problem that I'm trying to prevent is users getting prompted for authentication when they're already properly authenticated through the GitHub CLI. So if this can be solved differently and without a flag then that's fine by me 👍 Feel free to close this if you want. |
@driesvints Which operations other than |
Only |
@driesvints Thank you! It looks like you For now, you could do a git push like this:
Yes, it's verbose, but it's relatively safe to do and will ensure that as long as gh is authenticated (either via |
@mislav thanks a lot for that. I've sent in a PR to do just that: laravel/installer#191 I think related to this entire thread is that it would be cool if Something like |
@driesvints I do like the create-and-push idea! You are welcome to submit that as a separate feature request. BTW we can still consider the per-invocation |
@mislav we unfortunately had to revert your suggestion for the installer because it would only work on WSL for Windows. Our installer is intended to work for Windows in general. So we're back at square one I'm afraid. |
@driesvints Thanks for letting me know. I don't see why that approach wouldn't work outside of WSL, but I must admit I haven't tested it on Windows. I will report back with my findings |
Describe the feature or problem you’d like to solve
When running
gh repo create
as part of an automation the defaultgh_protocol
is used to set up the remote. Therefor, any subsequent git call to the remote will be using thehttps
protocol if it was the default. However, this causes any git call to invoke a usename/password prompt which can't be filled in by the user since they're not on-session due to it being an automation.Proposed solution
I'd like to propose the addition of a
--protocol
flag which can be used as follows:This way the more seamlessly
ssh
protocol is used to set up the remote which doesn't prompts the user and just uses an SSH key to authenticate. Of course, the user needs to have a SSH key set up with GitHub.Additional context
What I'm actually trying to do is run these two commands as part of the automation to automatically set up a GitHub repository and push the main branch to it:
Part one initialises the git repo and commits the working directory
Part two creates the GitHub repository and pushes the main branch to GitHub
It's for the second part that I specifically need the remote to be added with the
ssh
protocol so the push is seamlessly and without any interruption. Note that I cannot make use ofgh config set git_protocol ssh
because I don't want to alter the user's protocol preference in the automation.For full reference, this is the PR where I introduced the support for
gh repo create
with the Laravel installer: laravel/installer#185The text was updated successfully, but these errors were encountered: