Skip to content

Commit

Permalink
Merge pull request #2483 from carapace-sh/git-expand-args
Browse files Browse the repository at this point in the history
git: expand `git-dir` and `work-tree`
  • Loading branch information
rsteube authored Aug 15, 2024
2 parents 5b4c1a6 + da07e28 commit 2a05063
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions completers/git_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,18 @@ func init() {
carapace.Gen(rootCmd).PreInvoke(func(cmd *cobra.Command, flag *pflag.Flag, action carapace.Action) carapace.Action {
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if f := rootCmd.Flag("git-dir"); f.Changed {
c.Setenv("GIT_DIR", f.Value.String())
gitDir, err := c.Abs(f.Value.String())
if err != nil {
return carapace.ActionMessage(err.Error())
}
c.Setenv("GIT_DIR", gitDir)
}
if f := rootCmd.Flag("work-tree"); f.Changed {
c.Setenv("GIT_WORK_TREE", f.Value.String())
workTree, err := c.Abs(f.Value.String())
if err != nil {
return carapace.ActionMessage(err.Error())
}
c.Setenv("GIT_WORK_TREE", workTree)
action = action.Chdir(f.Value.String())
}
if f := rootCmd.Flag("C"); f.Changed {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/carapace-sh/carapace-bin
go 1.21

require (
github.com/carapace-sh/carapace v1.1.4
github.com/carapace-sh/carapace v1.1.5
github.com/carapace-sh/carapace-bridge v1.0.2
github.com/carapace-sh/carapace-shlex v1.0.1
github.com/carapace-sh/carapace-spec v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPn
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/carapace-sh/carapace v1.1.4 h1:SZzJiLE/TfKe4cCMwhJYtvWsZ7XOMmb+a+3I093iqww=
github.com/carapace-sh/carapace v1.1.4/go.mod h1:djegtVDi/3duSAqZNU+/nCq7XtDRMRZUb5bW0O/HnEs=
github.com/carapace-sh/carapace v1.1.5 h1:nacO1H9k8towi/PZDv/kbEi5Rn6+xC8gdjidax2ccqk=
github.com/carapace-sh/carapace v1.1.5/go.mod h1:djegtVDi/3duSAqZNU+/nCq7XtDRMRZUb5bW0O/HnEs=
github.com/carapace-sh/carapace-bridge v1.0.2 h1:q2yVrhpxjxA0p3ZcGHpjns99KE9lCrJLc3Zgaa7kMK4=
github.com/carapace-sh/carapace-bridge v1.0.2/go.mod h1:1tuz7tWpJeGMHa6Yvwlkb9QCNqxRD5VsS/4iZdK9ofQ=
github.com/carapace-sh/carapace-pflag v1.0.0 h1:uJMhl+vwEM/Eb0UdxZUuv4jo4rUAyPijkRGP5gfCuCE=
Expand Down

0 comments on commit 2a05063

Please sign in to comment.