-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Allow setting a default remote #62
Conversation
Based on MIT licensed coded at github.com/tcnksm/go-gitconfig
Also allows push command to set default remote.
The commit doesn't add the ability to set the default remote in termui. I'm not sure that functionality is necessary, but it would be easy to add.
return err | ||
} | ||
|
||
fmt.Println("Default remote: ", str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unreachable code
func runPush(cmd *cobra.Command, args []string) error { | ||
if len(args) > 1 { | ||
return errors.New("Only pushing to one remote at a time is supported") | ||
} | ||
|
||
remote := "origin" | ||
if len(args) == 0 && defaultRemote { | ||
str, err := git.GetConfig("gitbug.defaultremote") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this value of str
is never used
Damn, you are on fire 🎉 🎉 🎉 Instead of importing part of go-gitconfig, you can use the interface function |
pushCmd.Flags().SortFlags = false | ||
|
||
pushCmd.Flags().BoolVarP(&defaultRemote, "default", "d", false, | ||
"If a remote is provided, set the default remote for future pushes. Otherwise list the default remote if one exists.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In term of UX that's not good. The push
command should not have a lasting effect on the config. All the git-bug config manipulation should be centralized in a new config
command. I guess it would be better to open an issue, see what it should cover and design this new command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I see the argument, but a standard git push
can already have a lasting effect on the repo config with e.g. --set-upstream
. Even if there is a config
command, it still seems like you should be able to both push to a remote and set that remote as the default at the same time.
Sorry to rain on the parade :-\ Maybe before starting a new feature, contact me so I can give you the useful pointers and we can design the thing together. There is either the gitter lobby, a github issue or my mail (in my github profile). As I'm starting a new job on Monday I will be a bit less responsive though. Btw, if you are looking for a new target, it would be awesome to have a proper window in the termui to edit the search query, with widget and selectors (a bit like the toolbar in https://github.com/MichaelMure/git-bug/issues). Again, sorry to be annoying :-| |
No worries. This didn't take very long at all to knock up, so I'm not that attached to it. |
This is still a valid feature but the code for commands has moved so much that it would need to be reimplemented. At the same time, reading the git config is now integral part of Sorry :-\ |
@adamslc Is there any hope that you would revive this PR? I usually reserve |
…lMure#62) from ja/FixReferenceUpdatedConcurrently into master Reviewed-on: https://gitea.daedalean.ai/daedalean-github/git-ticket/pulls/62 Reviewed-by: Johannes Frohnhofen <jf@daedalean.ai>
Adds some code to read and write gitconfig files, and uses it to enable default remotes.
This is based off code at go-gitconfig. I would have just used that code, but the project seems abandoned, and it is licensed as MIT.
Closes #11.