diff --git a/completers/git_completer/cmd/mergeBase.go b/completers/git_completer/cmd/mergeBase.go new file mode 100644 index 0000000000..62c493287a --- /dev/null +++ b/completers/git_completer/cmd/mergeBase.go @@ -0,0 +1,43 @@ +package cmd + +import ( + "github.com/carapace-sh/carapace" + "github.com/carapace-sh/carapace-bin/pkg/actions/tools/git" + "github.com/spf13/cobra" +) + +var mergeBaseCmd = &cobra.Command{ + Use: "merge-base", + Short: "Find as good common ancestors as possible for a merge", + Run: func(cmd *cobra.Command, args []string) {}, + GroupID: groups[group_low_level_interrogator].ID, +} + +func init() { + carapace.Gen(mergeBaseCmd).Standalone() + + mergeBaseCmd.Flags().BoolP("all", "a", false, "output all merge bases for the commits") + mergeBaseCmd.Flags().Bool("fork-point", false, "find the point at which a branch forked from another branch ") + mergeBaseCmd.Flags().Bool("independent", false, "print a minimal subset of the supplied commits with the same ancestors") + mergeBaseCmd.Flags().Bool("is-ancestor", false, "check if the first is an ancestor of the second ") + mergeBaseCmd.Flags().Bool("octopus", false, "compute the best common ancestors of all supplied commits") + rootCmd.AddCommand(mergeBaseCmd) + + mergeBaseCmd.MarkFlagsMutuallyExclusive( + "fork-point", + "independent", + "is-ancestor", + "octopus", + ) + + carapace.Gen(mergeBaseCmd).PositionalAnyCompletion( + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + switch { + case mergeBaseCmd.Flag("is-ancestor").Changed && len(c.Args) > 1, + mergeBaseCmd.Flag("fork-point").Changed && len(c.Args) > 1: + return carapace.ActionValues() + } + return git.ActionRefs(git.RefOption{}.Default()) + }), + ) +} diff --git a/completers/git_completer/cmd/merge_base_generated.go b/completers/git_completer/cmd/merge_base_generated.go deleted file mode 100644 index 58f17e2eb4..0000000000 --- a/completers/git_completer/cmd/merge_base_generated.go +++ /dev/null @@ -1,23 +0,0 @@ -package cmd - -import ( - "github.com/carapace-sh/carapace" - "github.com/spf13/cobra" -) - -var merge_baseCmd = &cobra.Command{ - Use: "merge-base", - Short: "Find as good common ancestors as possible for a merge", - Run: func(cmd *cobra.Command, args []string) {}, - GroupID: groups[group_low_level_interrogator].ID, -} - -func init() { - carapace.Gen(merge_baseCmd).Standalone() - merge_baseCmd.Flags().BoolP("all", "a", false, "output all common ancestors") - merge_baseCmd.Flags().Bool("fork-point", false, "find where forked from reflog of ") - merge_baseCmd.Flags().Bool("independent", false, "list revs not reachable from others") - merge_baseCmd.Flags().Bool("is-ancestor", false, "is the first one ancestor of the other?") - merge_baseCmd.Flags().Bool("octopus", false, "find ancestors for a single n-way merge") - rootCmd.AddCommand(merge_baseCmd) -} diff --git a/completers/git_completer/cmd/pretty.txt b/completers/git_completer/cmd/pretty.txt deleted file mode 100644 index df032deb97..0000000000 --- a/completers/git_completer/cmd/pretty.txt +++ /dev/null @@ -1,12 +0,0 @@ ---pretty[=] pretty print commit message ---format= pretty-print the contents of the commit logs in a given format ---abbrev-commit show a prefix that names the object uniquely ---no-abbrev-commit show the full 40-byte hexadecimal commit object name ---oneline this is a shorthand for "--pretty=oneline --abbrev-commit" used together ---encoding= re-code the commit log message in the preferred encoding ---expand-tabs perform a tab expansion ---no-expand-tabs do not expand a tab expansion ---notes[=] show the notes that annotate the commit ---no-notes do not show notes ---show-notes-by-default show the default notes ---show-signature check the validity of a signed commit object