implement undo, account store cred

This commit is contained in:
daveberrys committed 2026-07-15 22:24:21 +08:00
1 parent bb6ffb1271
commit aa4f72b87d
2 files changed
+28

No files matched your search

+1
View File
@@ -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 }
+27
View File
@@ -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
},
}