From ea0bfeb91fb7a9d831d78f9e6a4678a1083a0d8f Mon Sep 17 00:00:00 2001 From: rsteube Date: Tue, 10 May 2022 11:05:45 +0200 Subject: [PATCH] spec: default arg --- completers/git_completer/cmd/archive.go | 2 +- completers/git_completer/cmd/bisect.go | 2 +- completers/git_completer/cmd/bisect_bad.go | 2 +- completers/git_completer/cmd/bisect_good.go | 2 +- completers/git_completer/cmd/bisect_reset.go | 2 +- completers/git_completer/cmd/bisect_start.go | 2 +- completers/git_completer/cmd/blame.go | 4 ++-- completers/git_completer/cmd/branch.go | 10 +++++----- completers/git_completer/cmd/bundle_create.go | 2 +- completers/git_completer/cmd/catFile.go | 2 +- completers/git_completer/cmd/checkout.go | 2 +- completers/git_completer/cmd/cherryPick.go | 2 +- completers/git_completer/cmd/clangFormat.go | 2 +- completers/git_completer/cmd/describe.go | 2 +- completers/git_completer/cmd/diff.go | 2 +- completers/git_completer/cmd/difftool.go | 4 ++-- completers/git_completer/cmd/formatPatch.go | 4 ++-- completers/git_completer/cmd/grep.go | 2 +- completers/git_completer/cmd/gui_blame.go | 2 +- completers/git_completer/cmd/gui_browser.go | 2 +- completers/git_completer/cmd/log.go | 2 +- completers/git_completer/cmd/merge.go | 2 +- completers/git_completer/cmd/rebase.go | 4 ++-- completers/git_completer/cmd/reset.go | 2 +- completers/git_completer/cmd/restore.go | 4 ++-- completers/git_completer/cmd/revert.go | 2 +- completers/git_completer/cmd/shortlog.go | 2 +- completers/git_completer/cmd/show.go | 2 +- .../git_completer/cmd/submodule_summary.go | 2 +- completers/git_completer/cmd/whatchanged.go | 2 +- completers/gitk_completer/cmd/root.go | 4 ++-- completers/tig_completer/cmd/reflog.go | 2 +- completers/tig_completer/cmd/root.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- pkg/actions/tools/git/action.go | 19 ++++++++----------- 36 files changed, 54 insertions(+), 57 deletions(-) diff --git a/completers/git_completer/cmd/archive.go b/completers/git_completer/cmd/archive.go index 30bd522832..e1b65303ff 100644 --- a/completers/git_completer/cmd/archive.go +++ b/completers/git_completer/cmd/archive.go @@ -44,7 +44,7 @@ func init() { }) carapace.Gen(archiveCmd).PositionalCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) carapace.Gen(archiveCmd).PositionalAnyCompletion( diff --git a/completers/git_completer/cmd/bisect.go b/completers/git_completer/cmd/bisect.go index 015949654a..b185344796 100644 --- a/completers/git_completer/cmd/bisect.go +++ b/completers/git_completer/cmd/bisect.go @@ -22,7 +22,7 @@ func init() { if len(c.Parts) > 2 { return carapace.ActionValues() } - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) }), ) } diff --git a/completers/git_completer/cmd/bisect_bad.go b/completers/git_completer/cmd/bisect_bad.go index 2ce6c1fb92..72964f19a2 100644 --- a/completers/git_completer/cmd/bisect_bad.go +++ b/completers/git_completer/cmd/bisect_bad.go @@ -18,6 +18,6 @@ func init() { bisectCmd.AddCommand(bisect_badCmd) carapace.Gen(bisect_badCmd).PositionalCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) } diff --git a/completers/git_completer/cmd/bisect_good.go b/completers/git_completer/cmd/bisect_good.go index a49803a7fd..83a454f608 100644 --- a/completers/git_completer/cmd/bisect_good.go +++ b/completers/git_completer/cmd/bisect_good.go @@ -18,6 +18,6 @@ func init() { bisectCmd.AddCommand(bisect_goodCmd) carapace.Gen(bisect_goodCmd).PositionalAnyCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) } diff --git a/completers/git_completer/cmd/bisect_reset.go b/completers/git_completer/cmd/bisect_reset.go index 8e2e0b8562..40df698d3a 100644 --- a/completers/git_completer/cmd/bisect_reset.go +++ b/completers/git_completer/cmd/bisect_reset.go @@ -18,6 +18,6 @@ func init() { bisectCmd.AddCommand(bisect_resetCmd) carapace.Gen(bisect_resetCmd).PositionalCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) } diff --git a/completers/git_completer/cmd/bisect_start.go b/completers/git_completer/cmd/bisect_start.go index 39fa755920..53b78edbca 100644 --- a/completers/git_completer/cmd/bisect_start.go +++ b/completers/git_completer/cmd/bisect_start.go @@ -28,7 +28,7 @@ func init() { if bisect_startCmd.Flags().ArgsLenAtDash() != -1 { return carapace.ActionFiles() } - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) }), ) } diff --git a/completers/git_completer/cmd/blame.go b/completers/git_completer/cmd/blame.go index cc5b7f17c6..f425fc38b4 100644 --- a/completers/git_completer/cmd/blame.go +++ b/completers/git_completer/cmd/blame.go @@ -54,7 +54,7 @@ func init() { carapace.Gen(blameCmd).FlagCompletion(carapace.ActionMap{ "S": carapace.ActionFiles(), "contents": carapace.ActionFiles(), - "ignore-rev": git.ActionRefs(git.RefOptionDefault), + "ignore-rev": git.ActionRefs(git.RefOption{}.Default()), "ignore-revs-file": carapace.ActionFiles(), }) @@ -63,7 +63,7 @@ func init() { if util.HasPathPrefix(c.CallbackValue) { return carapace.ActionFiles() } - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) }), carapace.ActionCallback(func(c carapace.Context) carapace.Action { if util.HasPathPrefix(c.Args[0]) { diff --git a/completers/git_completer/cmd/branch.go b/completers/git_completer/cmd/branch.go index 56d6d2bbf5..6c24db92d3 100644 --- a/completers/git_completer/cmd/branch.go +++ b/completers/git_completer/cmd/branch.go @@ -49,13 +49,13 @@ func init() { rootCmd.AddCommand(branchCmd) carapace.Gen(branchCmd).FlagCompletion(carapace.ActionMap{ - "D": git.ActionRefs(git.RefOptionDefault), + "D": git.ActionRefs(git.RefOption{}.Default()), "color": carapace.ActionValues("auto", "never", "always").StyleF(style.ForKeyword), - "contains": git.ActionRefs(git.RefOptionDefault), + "contains": git.ActionRefs(git.RefOption{}.Default()), "delete": git.ActionRefs(git.RefOption{LocalBranches: true, RemoteBranches: true}), - "merged": git.ActionRefs(git.RefOptionDefault), - "no-contains": git.ActionRefs(git.RefOptionDefault), - "no-merged": git.ActionRefs(git.RefOptionDefault), + "merged": git.ActionRefs(git.RefOption{}.Default()), + "no-contains": git.ActionRefs(git.RefOption{}.Default()), + "no-merged": git.ActionRefs(git.RefOption{}.Default()), "points-at": git.ActionRefs(git.RefOption{RemoteBranches: true, Tags: true}), "set-upstream-to": git.ActionRefs(git.RefOption{RemoteBranches: true, Tags: true}), "sort": git.ActionFieldNames(), diff --git a/completers/git_completer/cmd/bundle_create.go b/completers/git_completer/cmd/bundle_create.go index 45d2ce4a59..7568664e30 100644 --- a/completers/git_completer/cmd/bundle_create.go +++ b/completers/git_completer/cmd/bundle_create.go @@ -27,6 +27,6 @@ func init() { ) carapace.Gen(bundle_createCmd).PositionalAnyCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) } diff --git a/completers/git_completer/cmd/catFile.go b/completers/git_completer/cmd/catFile.go index f5427b9d00..0961490788 100644 --- a/completers/git_completer/cmd/catFile.go +++ b/completers/git_completer/cmd/catFile.go @@ -34,6 +34,6 @@ func init() { // TODO completions carapace.Gen(catFileCmd).PositionalCompletion( carapace.ActionValues("blob", "tree", "commit", "tag"), - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) } diff --git a/completers/git_completer/cmd/checkout.go b/completers/git_completer/cmd/checkout.go index 2e4fd6aa2d..62495859d3 100644 --- a/completers/git_completer/cmd/checkout.go +++ b/completers/git_completer/cmd/checkout.go @@ -48,7 +48,7 @@ func init() { }) carapace.Gen(checkoutCmd).PositionalCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) carapace.Gen(checkoutCmd).PositionalAnyCompletion( diff --git a/completers/git_completer/cmd/cherryPick.go b/completers/git_completer/cmd/cherryPick.go index d662446579..670d281210 100644 --- a/completers/git_completer/cmd/cherryPick.go +++ b/completers/git_completer/cmd/cherryPick.go @@ -54,7 +54,7 @@ func init() { // TODO `...` divider not yet working carapace.ActionMultiParts("...", func(c carapace.Context) carapace.Action { if len(c.Parts) < 2 { - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) } return carapace.ActionValues() }), diff --git a/completers/git_completer/cmd/clangFormat.go b/completers/git_completer/cmd/clangFormat.go index f88b3a4d12..f533bff133 100644 --- a/completers/git_completer/cmd/clangFormat.go +++ b/completers/git_completer/cmd/clangFormat.go @@ -34,7 +34,7 @@ func init() { } if diff := clangFormatCmd.Flag("diff").Changed; len(c.Args) == 0 || (len(c.Args) == 1 && diff) { - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) } return carapace.ActionFiles() }), diff --git a/completers/git_completer/cmd/describe.go b/completers/git_completer/cmd/describe.go index 003cf719b3..f689c2b803 100644 --- a/completers/git_completer/cmd/describe.go +++ b/completers/git_completer/cmd/describe.go @@ -40,7 +40,7 @@ func init() { if describeCmd.Flag("dirty").Changed || describeCmd.Flag("broken").Changed { return carapace.ActionValues() } else { - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) } }), ) diff --git a/completers/git_completer/cmd/diff.go b/completers/git_completer/cmd/diff.go index 958d394a67..18fae51516 100644 --- a/completers/git_completer/cmd/diff.go +++ b/completers/git_completer/cmd/diff.go @@ -23,7 +23,7 @@ func init() { if diffCmd.Flags().ArgsLenAtDash() != -1 { return carapace.ActionFiles() } - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) }), ) } diff --git a/completers/git_completer/cmd/difftool.go b/completers/git_completer/cmd/difftool.go index 135d4ce015..819ff37ed7 100644 --- a/completers/git_completer/cmd/difftool.go +++ b/completers/git_completer/cmd/difftool.go @@ -35,8 +35,8 @@ func init() { }) carapace.Gen(difftoolCmd).PositionalCompletion( - git.ActionRefs(git.RefOptionDefault), - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), + git.ActionRefs(git.RefOption{}.Default()), ) carapace.Gen(difftoolCmd).DashAnyCompletion( diff --git a/completers/git_completer/cmd/formatPatch.go b/completers/git_completer/cmd/formatPatch.go index 054cf63895..51d544eb14 100644 --- a/completers/git_completer/cmd/formatPatch.go +++ b/completers/git_completer/cmd/formatPatch.go @@ -67,9 +67,9 @@ func init() { carapace.ActionMultiParts("...", func(c carapace.Context) carapace.Action { switch len(c.Parts) { case 0: - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) case 1: - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) default: return carapace.ActionValues() } diff --git a/completers/git_completer/cmd/grep.go b/completers/git_completer/cmd/grep.go index e527f6ffcd..62b4b2da79 100644 --- a/completers/git_completer/cmd/grep.go +++ b/completers/git_completer/cmd/grep.go @@ -81,7 +81,7 @@ func init() { ) carapace.Gen(grepCmd).PositionalAnyCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) carapace.Gen(grepCmd).DashAnyCompletion( diff --git a/completers/git_completer/cmd/gui_blame.go b/completers/git_completer/cmd/gui_blame.go index 9a2a5b92f9..60727449b3 100644 --- a/completers/git_completer/cmd/gui_blame.go +++ b/completers/git_completer/cmd/gui_blame.go @@ -24,7 +24,7 @@ func init() { if util.HasPathPrefix(c.CallbackValue) { return carapace.ActionFiles() } - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) }), carapace.ActionFiles(), ) diff --git a/completers/git_completer/cmd/gui_browser.go b/completers/git_completer/cmd/gui_browser.go index 880c0d704e..8129cb0a7b 100644 --- a/completers/git_completer/cmd/gui_browser.go +++ b/completers/git_completer/cmd/gui_browser.go @@ -18,6 +18,6 @@ func init() { guiCmd.AddCommand(browserCmd) carapace.Gen(browserCmd).PositionalCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) } diff --git a/completers/git_completer/cmd/log.go b/completers/git_completer/cmd/log.go index 1feacc136d..c7aa21211a 100644 --- a/completers/git_completer/cmd/log.go +++ b/completers/git_completer/cmd/log.go @@ -44,7 +44,7 @@ func init() { } else { return carapace.ActionMultiParts("...", func(c carapace.Context) carapace.Action { if len(c.Parts) < 2 { - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) } else { return carapace.ActionValues() } diff --git a/completers/git_completer/cmd/merge.go b/completers/git_completer/cmd/merge.go index 178a16e918..86116d0da6 100644 --- a/completers/git_completer/cmd/merge.go +++ b/completers/git_completer/cmd/merge.go @@ -60,7 +60,7 @@ func init() { carapace.Gen(mergeCmd).PositionalAnyCompletion( carapace.ActionCallback(func(c carapace.Context) carapace.Action { - return git.ActionRefs(git.RefOptionDefault).Invoke(c).Filter(c.Args).ToA() + return git.ActionRefs(git.RefOption{}.Default()).Invoke(c).Filter(c.Args).ToA() }), ) } diff --git a/completers/git_completer/cmd/rebase.go b/completers/git_completer/cmd/rebase.go index 7cf7191da1..608d09d4f2 100644 --- a/completers/git_completer/cmd/rebase.go +++ b/completers/git_completer/cmd/rebase.go @@ -60,7 +60,7 @@ func init() { carapace.Gen(rebaseCmd).FlagCompletion(carapace.ActionMap{ "empty": carapace.ActionValues("drop", "keep", "ask"), "gpg-sign": os.ActionGpgKeyIds(), - "onto": git.ActionRefs(git.RefOptionDefault), + "onto": git.ActionRefs(git.RefOption{}.Default()), "rebase-merges": carapace.ActionValues("rebase-cousins", "no-rebase-cousins"), "strategy": git.ActionMergeStrategy(), "strategy-option": carapace.ActionCallback(func(c carapace.Context) carapace.Action { @@ -75,7 +75,7 @@ func init() { !rebaseCmd.Flag("abort").Changed && !rebaseCmd.Flag("skip").Changed && !rebaseCmd.Flag("edit-todo").Changed { - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) } else { return carapace.ActionValues() } diff --git a/completers/git_completer/cmd/reset.go b/completers/git_completer/cmd/reset.go index dad99363d2..c64a01d682 100644 --- a/completers/git_completer/cmd/reset.go +++ b/completers/git_completer/cmd/reset.go @@ -35,7 +35,7 @@ func init() { }) carapace.Gen(resetCmd).PositionalCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) carapace.Gen(resetCmd).PositionalAnyCompletion( diff --git a/completers/git_completer/cmd/restore.go b/completers/git_completer/cmd/restore.go index 4c04305432..9456017617 100644 --- a/completers/git_completer/cmd/restore.go +++ b/completers/git_completer/cmd/restore.go @@ -36,8 +36,8 @@ func init() { carapace.Gen(restoreCmd).FlagCompletion(carapace.ActionMap{ "conflict": carapace.ActionValues("merge", "diff3"), "pathspec-from-file": carapace.ActionFiles(), - "recurse-submodules": git.ActionRefs(git.RefOptionDefault), - "source": git.ActionRefs(git.RefOptionDefault), + "recurse-submodules": git.ActionRefs(git.RefOption{}.Default()), + "source": git.ActionRefs(git.RefOption{}.Default()), }) carapace.Gen(restoreCmd).PositionalAnyCompletion( diff --git a/completers/git_completer/cmd/revert.go b/completers/git_completer/cmd/revert.go index 8c2dc219a0..f529e81d39 100644 --- a/completers/git_completer/cmd/revert.go +++ b/completers/git_completer/cmd/revert.go @@ -42,5 +42,5 @@ func init() { }), }) - carapace.Gen(revertCmd).PositionalAnyCompletion(git.ActionRefs(git.RefOptionDefault)) + carapace.Gen(revertCmd).PositionalAnyCompletion(git.ActionRefs(git.RefOption{}.Default())) } diff --git a/completers/git_completer/cmd/shortlog.go b/completers/git_completer/cmd/shortlog.go index ef62e76efd..9bdf5da352 100644 --- a/completers/git_completer/cmd/shortlog.go +++ b/completers/git_completer/cmd/shortlog.go @@ -108,7 +108,7 @@ func init() { } else { return carapace.ActionMultiParts("...", func(c carapace.Context) carapace.Action { if len(c.Parts) < 2 { - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) } else { return carapace.ActionValues() } diff --git a/completers/git_completer/cmd/show.go b/completers/git_completer/cmd/show.go index da4a77c0a9..cdc0edcbce 100644 --- a/completers/git_completer/cmd/show.go +++ b/completers/git_completer/cmd/show.go @@ -40,7 +40,7 @@ func init() { carapace.ActionMultiParts(":", func(c carapace.Context) carapace.Action { switch len(c.Parts) { case 0: - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) case 1: return git.ActionRefFiles(c.Parts[0]) default: diff --git a/completers/git_completer/cmd/submodule_summary.go b/completers/git_completer/cmd/submodule_summary.go index 0a7cd2d777..a6c406c09e 100644 --- a/completers/git_completer/cmd/submodule_summary.go +++ b/completers/git_completer/cmd/submodule_summary.go @@ -21,7 +21,7 @@ func init() { submoduleCmd.AddCommand(submodule_summaryCmd) carapace.Gen(submodule_summaryCmd).PositionalCompletion( - git.ActionRefs(git.RefOptionDefault), // TODO commmit of submodule?? + git.ActionRefs(git.RefOption{}.Default()), // TODO commmit of submodule?? ) carapace.Gen(submodule_summaryCmd).PositionalAnyCompletion( diff --git a/completers/git_completer/cmd/whatchanged.go b/completers/git_completer/cmd/whatchanged.go index 7da95a11c9..bf8fec51ea 100644 --- a/completers/git_completer/cmd/whatchanged.go +++ b/completers/git_completer/cmd/whatchanged.go @@ -45,7 +45,7 @@ func init() { } else { return carapace.ActionMultiParts("...", func(c carapace.Context) carapace.Action { if len(c.Parts) < 2 { - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) } else { return carapace.ActionValues() } diff --git a/completers/gitk_completer/cmd/root.go b/completers/gitk_completer/cmd/root.go index 8daffb44e6..c71aa74b11 100644 --- a/completers/gitk_completer/cmd/root.go +++ b/completers/gitk_completer/cmd/root.go @@ -45,14 +45,14 @@ func init() { carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ "argscmd": carapace.ActionFiles(), - "select-commit": git.ActionRefs(git.RefOptionDefault), + "select-commit": git.ActionRefs(git.RefOption{}.Default()), "since": time.ActionDate(), "until": time.ActionDate(), }) carapace.Gen(rootCmd).PositionalCompletion( carapace.ActionMultiParts("...", func(c carapace.Context) carapace.Action { - return git.ActionRefs(git.RefOptionDefault) + return git.ActionRefs(git.RefOption{}.Default()) }), ) diff --git a/completers/tig_completer/cmd/reflog.go b/completers/tig_completer/cmd/reflog.go index 66c0d6cb3c..9cc0c4c93c 100644 --- a/completers/tig_completer/cmd/reflog.go +++ b/completers/tig_completer/cmd/reflog.go @@ -18,6 +18,6 @@ func init() { rootCmd.AddCommand(reflogCmd) carapace.Gen(reflogCmd).PositionalAnyCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) } diff --git a/completers/tig_completer/cmd/root.go b/completers/tig_completer/cmd/root.go index c6b840ca8b..f14d9490d0 100644 --- a/completers/tig_completer/cmd/root.go +++ b/completers/tig_completer/cmd/root.go @@ -29,7 +29,7 @@ func init() { }) carapace.Gen(rootCmd).PositionalCompletion( - git.ActionRefs(git.RefOptionDefault), + git.ActionRefs(git.RefOption{}.Default()), ) carapace.Gen(rootCmd).PreInvoke(func(cmd *cobra.Command, flag *pflag.Flag, action carapace.Action) carapace.Action { diff --git a/go.mod b/go.mod index 2351264e65..a922409359 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/mitchellh/go-ps v1.0.0 github.com/pelletier/go-toml v1.9.5 github.com/rsteube/carapace v0.20.2 - github.com/rsteube/carapace-spec v0.0.16 + github.com/rsteube/carapace-spec v0.0.17 github.com/spf13/cobra v1.4.0 github.com/spf13/pflag v1.0.5 golang.org/x/sys v0.0.0-20211205182925-97ca703d548d diff --git a/go.sum b/go.sum index 5fce9dd458..1b4506050e 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rsteube/carapace v0.20.2 h1:i6QSQZ5vZKmXcwupsYch8XdJ/GBbZU+H8XtfXEs8Z4E= github.com/rsteube/carapace v0.20.2/go.mod h1:GgiwpPVhucHNOv0AmtIkxhiEFkCMP5BBRauyQLP0mFY= -github.com/rsteube/carapace-spec v0.0.16 h1:HW3+VYX1ZyT9QDUFtjdgCX2dVYAiZL9d0I00qocW478= -github.com/rsteube/carapace-spec v0.0.16/go.mod h1:vyKkMfbIYHhPiUeyCemLWh96XNPwWI9B6Go0+W5nDUw= +github.com/rsteube/carapace-spec v0.0.17 h1:rLV3fSZyqPgwCl8I3taOamMsINUUgtZ18ggLAroTzLI= +github.com/rsteube/carapace-spec v0.0.17/go.mod h1:vyKkMfbIYHhPiUeyCemLWh96XNPwWI9B6Go0+W5nDUw= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= diff --git a/pkg/actions/tools/git/action.go b/pkg/actions/tools/git/action.go index 36b293ec37..9fad3eff65 100644 --- a/pkg/actions/tools/git/action.go +++ b/pkg/actions/tools/git/action.go @@ -1,7 +1,6 @@ package git import ( - "reflect" "strings" "github.com/rsteube/carapace" @@ -24,12 +23,14 @@ type RefOption struct { Stashes bool } -var RefOptionDefault = RefOption{ - LocalBranches: true, - RemoteBranches: true, - Commits: 100, - Tags: true, - Stashes: true, +func (o RefOption) Default() RefOption { + o.LocalBranches = true + o.RemoteBranches = true + o.Commits = 100 + o.Tags = true + o.Stashes = true + return o + } // ActionRefs completes git references (commits, branches, tags) @@ -37,10 +38,6 @@ var RefOptionDefault = RefOption{ // v0.0.1 (last commit msg) func ActionRefs(refOption RefOption) carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { - if reflect.DeepEqual(refOption, RefOption{}) { // for macros: if none is set use the default - refOption = RefOptionDefault - } - vals := make([]string, 0) if branches, err := branches(c, refOption); err != nil { return carapace.ActionMessage(err.Error())