Skip to content

Commit f6dcdbd

Browse files
authored
Merge pull request #3234 from carapace-sh/git-valid-refs
git: ActionRefCommits / ActionRefParents - prefix intenally to return valid refs
2 parents 8d26d6f + ff1d2c6 commit f6dcdbd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pkg/actions/tools/git/commit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func ActionRefCommits(ref string) carapace.Action {
2424
for index, line := range lines[:len(lines)-1] {
2525
vals = append(vals, fmt.Sprintf("%0"+strconv.Itoa(len(strconv.Itoa(limit-1)))+"d", index), strings.TrimSpace(line[10:]))
2626
}
27-
return carapace.ActionValuesDescribed(vals...).Style(styles.Git.Commit)
27+
return carapace.ActionValuesDescribed(vals...).Prefix(ref + "~").Style(styles.Git.Commit)
2828
})
2929
}).Tag("ref commits")
3030
}
@@ -41,7 +41,7 @@ func ActionRefParents(ref string) carapace.Action {
4141
for index, field := range strings.Fields(string(output)) {
4242
vals = append(vals, strconv.Itoa(index+1), field)
4343
}
44-
return carapace.ActionValuesDescribed(vals...).Style(styles.Git.Commit)
44+
return carapace.ActionValuesDescribed(vals...).Prefix(ref + "^").Style(styles.Git.Commit)
4545
})
4646
}).Tag("parent commits")
4747
}

pkg/actions/tools/git/ref.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func ActionRefs(refOption RefOption) carapace.Action {
7676
index := max(strings.LastIndex(c.Value, "~"), strings.LastIndex(c.Value, "^"), strings.LastIndex(c.Value, "@"))
7777
switch c.Value[index] {
7878
case '^':
79-
return ActionRefParents(c.Value[:index]).Prefix(c.Value[:index+1])
79+
return ActionRefParents(c.Value[:index])
8080
case '@':
8181
return carapace.Batch(
8282
time.ActionDateTime(time.DateTimeOpts{}),
@@ -95,7 +95,7 @@ func ActionRefs(refOption RefOption) carapace.Action {
9595
).ToA().Prefix(c.Value[:index+1] + "{")
9696

9797
default: // '~'
98-
return ActionRefCommits(c.Value[:index]).Prefix(c.Value[:index+1])
98+
return ActionRefCommits(c.Value[:index])
9999
}
100100
}).UidF(Uid("ref"))
101101
})

0 commit comments

Comments
 (0)