Skip to content

Commit

Permalink
Merge pull request #450 from rsteube/git-apply
Browse files Browse the repository at this point in the history
git: added am
  • Loading branch information
rsteube authored Jul 8, 2021
2 parents 1ec2ed9 + 80724c8 commit c3dd9b1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/spf13/cobra"
)

var amCmd = &cobra.Command{
Use: "am",
Short: "Apply a series of patches from a mailbox",
Run: func(cmd *cobra.Command, args []string) {
},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(amCmd).Standalone()

amCmd.Flags().BoolP("3way", "3", false, "allow fall back on 3way merging if needed")
amCmd.Flags().StringS("C", "C", "", "pass it through git-apply")
amCmd.Flags().Bool("abort", false, "restore the original branch and abort the patching operation.")
amCmd.Flags().Bool("abort", false, "restore the original branch and abort the patching operation")
amCmd.Flags().Bool("committer-date-is-author-date", false, "lie about committer date")
amCmd.Flags().Bool("continue", false, "continue applying patches after resolving a conflict")
amCmd.Flags().String("directory", "", "pass it through git-apply")
Expand All @@ -33,16 +36,35 @@ func init() {
amCmd.Flags().StringS("p", "p", "", "pass it through git-apply")
amCmd.Flags().String("patch-format", "", "format the patch(es) are in")
amCmd.Flags().BoolP("quiet", "q", false, "be quiet")
amCmd.Flags().Bool("quit", false, "abort the patching operation but keep HEAD where it is.")
amCmd.Flags().Bool("quit", false, "abort the patching operation but keep HEAD where it is")
amCmd.Flags().String("quoted-cr", "", "pass it through git-mailinfo")
amCmd.Flags().Bool("reject", false, "pass it through git-apply")
amCmd.Flags().Bool("rerere-autoupdate", false, "update the index with reused conflict resolution if possible")
amCmd.Flags().BoolP("resolved", "r", false, "synonyms for --continue")
amCmd.Flags().String("resolvemsg", "", "override error message when patch failure occurs")
amCmd.Flags().BoolP("scissors", "c", false, "strip everything before a scissors line")
amCmd.Flags().String("show-current-patch", "", "show the patch being applied")
amCmd.Flags().BoolP("signoff", "s", false, "add a Signed-off-by line to the commit message")
amCmd.Flags().BoolP("signoff", "s", false, "add a Signed-off-by trailer to the commit message")
amCmd.Flags().Bool("skip", false, "skip the current patch")
amCmd.Flags().BoolP("utf8", "u", false, "recode into utf8 (default)")
amCmd.Flags().String("whitespace", "", "pass it through git-apply")
rootCmd.AddCommand(amCmd)

amCmd.Flag("gpg-sign").NoOptDefVal = " "
amCmd.Flag("show-current-patch").NoOptDefVal = " "

carapace.Gen(amCmd).FlagCompletion(carapace.ActionMap{
"directory": carapace.ActionDirectories(),
"exclude": carapace.ActionDirectories(),
"gpg-sign": os.ActionGpgKeyIds(),
"include": carapace.ActionDirectories(),
"patch-format": carapace.ActionValues("mbox", "mboxrd", "stgit", "stgit-series", "hg"),
"quoted-cr": carapace.ActionValuesDescribed(
"nowarn", "Git will do nothing when such a CRLF is found.",
"warn", "Git will issue a warning for each message if such a CRLF is found.",
"strip", "Git will convert those CRLF to LF.",
),
"show-current-patch": carapace.ActionValues("diff", "raw"),
"whitespace": carapace.ActionValues("nowarn", "warn", "fix", "error", "error-all"),
})
}
10 changes: 9 additions & 1 deletion completers/git_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/git"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -33,7 +34,14 @@ func init() {
rootCmd.Flags().String("work-tree", "", "path to working tree")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"c": carapace.ActionMessage("TODO"), // TODO ActionMultiparts with callback for config values (git help --config)
"c": carapace.ActionMultiParts("=", func(c carapace.Context) carapace.Action {
switch len(c.Parts) {
case 0:
return git.ActionConfigs()
default:
return carapace.ActionValues()
}
}),
"C": carapace.ActionDirectories(),
"exec-path": carapace.ActionDirectories(),
"git-dir": carapace.ActionDirectories(),
Expand Down

0 comments on commit c3dd9b1

Please sign in to comment.