summaryrefslogtreecommitdiff
path: root/internal/prompt/git.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/prompt/git.go')
-rw-r--r--internal/prompt/git.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/prompt/git.go b/internal/prompt/git.go
index 6f0cf1d..26291c4 100644
--- a/internal/prompt/git.go
+++ b/internal/prompt/git.go
@@ -57,12 +57,12 @@ func findRepo(path string) (*gitRepo, error) {
if err != nil {
return nil, err
}
- for _, line := range strings.Split(string(bytes), "\n") {
+ for line := range strings.SplitSeq(string(bytes), "\n") {
line = strings.TrimSpace(line)
- if strings.HasPrefix(line, "gitdir:") {
+ if gitDir, ok := strings.CutPrefix(line, "gitdir:"); ok {
return &gitRepo{
RootPath: path,
- GitDir: filepath.Join(path, strings.TrimSpace(strings.TrimPrefix(line, "gitdir:"))),
+ GitDir: filepath.Join(path, strings.TrimSpace(gitDir)),
}, nil
}
}
@@ -115,7 +115,7 @@ func tryReadFromPackedRefs(repo *gitRepo, refSpec string) string {
if err != nil {
return ""
}
- for _, line := range strings.Split(string(bytes), "\n") {
+ for line := range strings.SplitSeq(string(bytes), "\n") {
line = strings.TrimSpace(line)
if line == "" || strings.HasPrefix(line, "#") {
continue