Skip to content
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

feat: add --all flag to av commit amend #452

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/av/commit_amend.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ var commitAmendFlags struct {

// Same as `git commit --amend --no-edit`. Amends a commit without changing its commit message.
NoEdit bool

// Same as `git commit --all`.
All bool
}

var commitAmendCmd = &cobra.Command{
Expand Down Expand Up @@ -56,6 +59,9 @@ func runAmend(repo *git.Repo, db meta.DB) error {
if commitAmendFlags.NoEdit {
commitArgs = append(commitArgs, "--no-edit")
}
if commitAmendFlags.All {
commitArgs = append(commitArgs, "--all")
}
if commitAmendFlags.Message != "" {
commitArgs = append(commitArgs, "--message", commitAmendFlags.Message)
}
Expand Down Expand Up @@ -89,4 +95,6 @@ func init() {
commitAmendCmd.Flags().
BoolVar(&commitAmendFlags.NoEdit, "no-edit", false, "amend a commit without changing its commit message")
commitAmendCmd.MarkFlagsMutuallyExclusive("message", "no-edit")
commitAmendCmd.Flags().
BoolVarP(&commitAmendFlags.All, "all", "a", false, "automatically stage modified files (same as git commit --all)")
}