mirror of
https://github.com/daveberrys/guh.git
synced 2026-11-29 00:26:46 +08:00
auto pushing upstream
This commit is contained in:
1 parent
e40387c817
commit
932823fdde
2 files changed
+18
-17
No files matched your search
+8
-8
@@ -82,18 +82,18 @@ var commitCmd = &cobra.Command{
|
||||
|
||||
utils.RunGitSequence(false, commitArgs)
|
||||
if afterPush {
|
||||
branch, _ := utils.RunGit(true, "rev-parse", "--abbrev-ref", "HEAD")
|
||||
if remoteName == "all" {
|
||||
remotes, err := utils.RunGit(true, "remote")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range strings.Fields(remotes) {
|
||||
if err := utils.RunGitSequence(false, []string{"push", r}); err != nil {
|
||||
return err
|
||||
remotes, _ := utils.RunGit(true, "remote")
|
||||
for i, r := range strings.Fields(remotes) {
|
||||
if i == 0 {
|
||||
utils.RunGitSequence(false, []string{"push", "-u", r, branch})
|
||||
} else {
|
||||
utils.RunGitSequence(false, []string{"push", r})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
utils.RunGitSequence(false, []string{"push", remoteName})
|
||||
utils.RunGitSequence(false, []string{"push", "-u", remoteName, branch})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
+10
-9
@@ -14,21 +14,22 @@ var pushCmd = &cobra.Command{
|
||||
Short: "Add current changes and push",
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
branch, _ := utils.RunGit(true, "rev-parse", "--abbrev-ref", "HEAD")
|
||||
|
||||
if len(args) == 0 {
|
||||
return utils.RunGitSequence(false, []string{"push"})
|
||||
return utils.RunGitSequence(false, []string{"push", "-u", "origin", branch})
|
||||
}
|
||||
if args[0] == "all" {
|
||||
remotes, err := utils.RunGit(true, "remote")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, r := range strings.Fields(remotes) {
|
||||
if err := utils.RunGitSequence(false, []string{"push", r}); err != nil {
|
||||
return err
|
||||
remotes, _ := utils.RunGit(true, "remote")
|
||||
for i, r := range strings.Fields(remotes) {
|
||||
if i == 0 {
|
||||
utils.RunGitSequence(false, []string{"push", "-u", r, branch})
|
||||
} else {
|
||||
utils.RunGitSequence(false, []string{"push", r})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return utils.RunGitSequence(false, []string{"push", args[0]})
|
||||
return utils.RunGitSequence(false, []string{"push", "-u", args[0], branch})
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user