chore: checkpoint all working changes

This commit is contained in:
Alex Dunmow 2026-09-05 21:14:15 +08:00
parent 68e9fa6f6c
commit ce81cce76c
2 changed files with 9 additions and 12 deletions

View File

@ -73,7 +73,7 @@ func (d *diffIndex) repoDiff(repo string) *repoDiff {
parseUnifiedDiff(string(out), rd)
}
if out, err := exec.Command("git", "-C", repo, "ls-files", "--others", "--exclude-standard").Output(); err == nil {
for _, f := range strings.Split(strings.TrimSpace(string(out)), "\n") {
for f := range strings.SplitSeq(strings.TrimSpace(string(out)), "\n") {
if f != "" {
rd.untracked[filepath.ToSlash(f)] = true
}
@ -106,7 +106,7 @@ func parseUnifiedDiff(diff string, rd *repoDiff) {
if rd.changed[cur] == nil {
rd.changed[cur] = map[int]bool{}
}
for i := 0; i < count; i++ {
for i := range count {
rd.changed[cur][start+i] = true
}
}
@ -116,18 +116,18 @@ func parseUnifiedDiff(diff string, rd *repoDiff) {
// parseHunkNewRange extracts (start, count) from the `+c,d` part of a hunk
// header like `@@ -a,b +c,d @@`. A missing `,d` means count 1.
func parseHunkNewRange(header string) (int, int) {
plus := strings.IndexByte(header, '+')
if plus < 0 {
_, after, ok := strings.Cut(header, "+")
if !ok {
return 0, 0
}
rest := header[plus+1:]
rest := after
if sp := strings.IndexByte(rest, ' '); sp >= 0 {
rest = rest[:sp]
}
start, count := 0, 1
if comma := strings.IndexByte(rest, ','); comma >= 0 {
start, _ = strconv.Atoi(rest[:comma])
count, _ = strconv.Atoi(rest[comma+1:])
if before, after, ok := strings.Cut(rest, ","); ok {
start, _ = strconv.Atoi(before)
count, _ = strconv.Atoi(after)
} else {
start, _ = strconv.Atoi(rest)
}

View File

@ -68,10 +68,7 @@ func checkToolbarInjection(root string) []toolbarViolation {
}
bodyStart := fset.Position(fn.Body.Pos()).Offset
bodyEnd := fset.Position(fn.Body.End()).Offset
if bodyEnd > len(srcText) {
bodyEnd = len(srcText)
}
bodyEnd := min(fset.Position(fn.Body.End()).Offset, len(srcText))
body := srcText[bodyStart:bodyEnd]
hasSiteSettings := strings.Contains(body, "getSiteSettings")