aboutsummaryrefslogtreecommitdiff
path: root/internal/prompt
diff options
context:
space:
mode:
Diffstat (limited to 'internal/prompt')
-rw-r--r--internal/prompt/cloud.go2
-rw-r--r--internal/prompt/git.go8
2 files changed, 5 insertions, 5 deletions
diff --git a/internal/prompt/cloud.go b/internal/prompt/cloud.go
index 624f56d..14cd18a 100644
--- a/internal/prompt/cloud.go
+++ b/internal/prompt/cloud.go
@@ -86,7 +86,7 @@ func getKubernetesFieldViaU8S() string {
context string
namespace string
)
- for _, line := range strings.Split(string(stdout), "\n") {
+ for line := range strings.SplitSeq(string(stdout), "\n") {
fields := strings.SplitN(strings.TrimSpace(line), "=", 2)
if len(fields) != 2 {
continue
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