-
-
Notifications
You must be signed in to change notification settings - Fork 108
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 1 commit
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,24 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rs/zerolog/log" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var undo_commitCmd = &cobra.Command{ | ||
Use: "undo-commit", | ||
Short: "Undo your previous commit if it is not yet pushed to repository", | ||
Args: cobra.NoArgs, | ||
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? |
||
} | ||
|
||
func init() { | ||
BitCmd.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
}