Skip to content

Commit a330d68

Browse files
committed
Use strings.CutLast for .gitmodules keys
Go 1.27 is on main now.
1 parent 3fdbe51 commit a330d68

1 file changed

Lines changed: 1 addition & 9 deletions

File tree

‎internal/gitcache/mirror.go‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (c *Cache) submodules(ctx context.Context, key, dir, commit string) ([]Subm
161161
for entry := range strings.SplitSeq(out, "\x00") {
162162
key, value, ok := strings.Cut(entry, "\n")
163163
section, ok2 := strings.CutPrefix(key, "submodule.")
164-
name, field, dotted := cutLast(section, ".")
164+
name, field, dotted := strings.CutLast(section, ".")
165165
if !ok || !ok2 || !dotted {
166166
continue
167167
}
@@ -201,14 +201,6 @@ func (c *Cache) submodules(ctx context.Context, key, dir, commit string) ([]Subm
201201
return submodules, nil
202202
}
203203

204-
func cutLast(s, sep string) (before, after string, found bool) {
205-
i := strings.LastIndex(s, sep)
206-
if i < 0 {
207-
return s, "", false
208-
}
209-
return s[:i], s[i+len(sep):], true
210-
}
211-
212204
// ensureCommit makes sure the repository has commit, fetching it by ID when
213205
// it doesn't and fetchWants allows it. A commit on no branch or tag that is
214206
// cached already gets a new wanted ref, so it is kept for wantedMaxAge from

0 commit comments

Comments
 (0)