mirror of
https://github.com/daveberrys/guh.git
synced 2026-11-29 00:46:45 +08:00
implement undo, account store cred
This commit is contained in:
1 parent
bb6ffb1271
commit
aa4f72b87d
2 files changed
+28
No files matched your search
@@ -18,6 +18,7 @@ var switchAccountCmd = &cobra.Command{
|
||||
if err != nil { return err }
|
||||
|
||||
if err := utils.RunGitSequence(false,
|
||||
[]string{"config", "--global", "credential.helper", "store"},
|
||||
[]string{"config", "--global", "user.name", account.Username},
|
||||
[]string{"config", "--global", "user.email", account.Email},
|
||||
); err != nil { return err }
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package cmd
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/daveberrys/guh/src/utils"
|
||||
)
|
||||
|
||||
func init() { RootCmd.AddCommand(undoCmd) }
|
||||
|
||||
var undoCmd = &cobra.Command{
|
||||
Use: "undo [commits] [flavour]",
|
||||
Short: "Undo the last LOCAL commit. Flavour can be hard, mixed, or soft. It's optional.",
|
||||
Args: cobra.MinimumNArgs(1),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
var flavour string
|
||||
switch args[1] {
|
||||
case "hard":
|
||||
flavour = "--hard"
|
||||
case "mixed":
|
||||
flavour = "--mixed"
|
||||
default:
|
||||
flavour = "--soft"
|
||||
}
|
||||
|
||||
utils.RunGitSequence(false, []string{"reset", flavour, "HEAD~" + args[0]})
|
||||
return nil
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user