auto pushing upstream

This commit is contained in:
daveberrys committed 2026-07-19 09:53:04 +08:00
1 parent e40387c817
commit 932823fdde
2 files changed
+18 -17

No files matched your search

+8 -8
View File
@@ -82,18 +82,18 @@ var commitCmd = &cobra.Command{
utils.RunGitSequence(false, commitArgs) utils.RunGitSequence(false, commitArgs)
if afterPush { if afterPush {
branch, _ := utils.RunGit(true, "rev-parse", "--abbrev-ref", "HEAD")
if remoteName == "all" { if remoteName == "all" {
remotes, err := utils.RunGit(true, "remote") remotes, _ := utils.RunGit(true, "remote")
if err != nil { for i, r := range strings.Fields(remotes) {
return err if i == 0 {
} utils.RunGitSequence(false, []string{"push", "-u", r, branch})
for _, r := range strings.Fields(remotes) { } else {
if err := utils.RunGitSequence(false, []string{"push", r}); err != nil { utils.RunGitSequence(false, []string{"push", r})
return err
} }
} }
} else { } else {
utils.RunGitSequence(false, []string{"push", remoteName}) utils.RunGitSequence(false, []string{"push", "-u", remoteName, branch})
} }
} }
return nil return nil
+10 -9
View File
@@ -14,21 +14,22 @@ var pushCmd = &cobra.Command{
Short: "Add current changes and push", Short: "Add current changes and push",
Args: cobra.MaximumNArgs(1), Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
branch, _ := utils.RunGit(true, "rev-parse", "--abbrev-ref", "HEAD")
if len(args) == 0 { if len(args) == 0 {
return utils.RunGitSequence(false, []string{"push"}) return utils.RunGitSequence(false, []string{"push", "-u", "origin", branch})
} }
if args[0] == "all" { if args[0] == "all" {
remotes, err := utils.RunGit(true, "remote") remotes, _ := utils.RunGit(true, "remote")
if err != nil { for i, r := range strings.Fields(remotes) {
return err if i == 0 {
} utils.RunGitSequence(false, []string{"push", "-u", r, branch})
for _, r := range strings.Fields(remotes) { } else {
if err := utils.RunGitSequence(false, []string{"push", r}); err != nil { utils.RunGitSequence(false, []string{"push", r})
return err
} }
} }
return nil return nil
} }
return utils.RunGitSequence(false, []string{"push", args[0]}) return utils.RunGitSequence(false, []string{"push", "-u", args[0], branch})
}, },
} }