-
-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add undo-commit command #115
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rs/zerolog/log" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var fixCmd = &cobra.Command{ | ||
Use: "fix sub-command", | ||
Short: "For all the times you did something you really wish you didn't", | ||
Args: cobra.NoArgs, | ||
} | ||
|
||
var undo_commitCmd = &cobra.Command{ | ||
Use: "undo-commit", | ||
Short: "soft undos last commit if not pushed already", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if IsAheadOfCurrent() { | ||
err := execCommand("git", "reset", "--soft", "HEAD~1").Run() | ||
if err != nil { | ||
log.Debug().Err(err).Send() | ||
} | ||
} | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After this line you'll need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @chriswalz i added fix as command and undo-commit as sub command to fix command. Hence i added There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chriswalz could you take look into this? |
||
Args: cobra.NoArgs, | ||
} | ||
|
||
func init() { | ||
BitCmd.AddCommand(fixCmd) | ||
fixCmd.AddCommand(undo_commitCmd) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From lines 13-17 should be wrapped in this code
arg := args[0]
if (arg == "undo-commit") {
// undo commit code
}