mirror of
https://github.com/rsteube/carapace-bin.git
synced 2025-05-05 15:32:53 +00:00
git: restore - support --source
This commit is contained in:
parent
50e3839ec3
commit
70048c9260
@ -89,7 +89,7 @@ func actionDiffArgs(cmd *cobra.Command) carapace.Action {
|
||||
var action carapace.Action
|
||||
if cmd.Flag("cached").Changed {
|
||||
if len(expanded) > 0 {
|
||||
action = git.ActionCachedDiffs(expanded[0])
|
||||
action = git.ActionCachedRefDiffs(expanded[0])
|
||||
}
|
||||
} else {
|
||||
action = git.ActionRefDiffs(expanded...)
|
||||
|
@ -44,8 +44,15 @@ func init() {
|
||||
carapace.Gen(restoreCmd).PositionalAnyCompletion(
|
||||
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
|
||||
if restoreCmd.Flag("staged").Changed {
|
||||
if f := restoreCmd.Flag("source"); f.Changed {
|
||||
return git.ActionCachedRefDiffs(f.Value.String())
|
||||
}
|
||||
return git.ActionChanges(git.ChangeOpts{Staged: true}).FilterArgs()
|
||||
}
|
||||
|
||||
if f := restoreCmd.Flag("source"); f.Changed {
|
||||
return git.ActionRefDiffs(f.Value.String())
|
||||
}
|
||||
return git.ActionChanges(git.ChangeOpts{Unstaged: true}).FilterArgs()
|
||||
}),
|
||||
)
|
||||
|
@ -138,7 +138,7 @@ func ActionRefDiffs(refs ...string) carapace.Action {
|
||||
}
|
||||
|
||||
// ActionCachedDiffs completes changes between stage and given ref
|
||||
func ActionCachedDiffs(ref string) carapace.Action {
|
||||
func ActionCachedRefDiffs(ref string) carapace.Action {
|
||||
return actionRefDiffs(true, ref)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user