mirror of
https://github.com/daveberrys/guh.git
synced 2026-11-29 00:56:45 +08:00
improve commiting and pushing
This commit is contained in:
1 parent
99e2b8d92f
commit
5c7575a889
2 files changed
+74
-6
No files matched your search
+20
-3
@@ -1,6 +1,8 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/daveberrys/guh/src/utils"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -8,10 +10,25 @@ import (
|
||||
func init() { rootCmd.AddCommand(pushCmd) }
|
||||
|
||||
var pushCmd = &cobra.Command{
|
||||
Use: "push",
|
||||
Use: "push [remote]",
|
||||
Short: "Add current changes and push",
|
||||
Args: cobra.NoArgs,
|
||||
Args: cobra.MaximumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return utils.RunGitSequence(false, []string{"push"})
|
||||
if len(args) == 0 {
|
||||
return utils.RunGitSequence(false, []string{"push"})
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return utils.RunGitSequence(false, []string{"push", args[0]})
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user