chore: checkpoint all working changes
This commit is contained in:
parent
68e9fa6f6c
commit
ce81cce76c
@ -73,7 +73,7 @@ func (d *diffIndex) repoDiff(repo string) *repoDiff {
|
|||||||
parseUnifiedDiff(string(out), rd)
|
parseUnifiedDiff(string(out), rd)
|
||||||
}
|
}
|
||||||
if out, err := exec.Command("git", "-C", repo, "ls-files", "--others", "--exclude-standard").Output(); err == nil {
|
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 != "" {
|
if f != "" {
|
||||||
rd.untracked[filepath.ToSlash(f)] = true
|
rd.untracked[filepath.ToSlash(f)] = true
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ func parseUnifiedDiff(diff string, rd *repoDiff) {
|
|||||||
if rd.changed[cur] == nil {
|
if rd.changed[cur] == nil {
|
||||||
rd.changed[cur] = map[int]bool{}
|
rd.changed[cur] = map[int]bool{}
|
||||||
}
|
}
|
||||||
for i := 0; i < count; i++ {
|
for i := range count {
|
||||||
rd.changed[cur][start+i] = true
|
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
|
// parseHunkNewRange extracts (start, count) from the `+c,d` part of a hunk
|
||||||
// header like `@@ -a,b +c,d @@`. A missing `,d` means count 1.
|
// header like `@@ -a,b +c,d @@`. A missing `,d` means count 1.
|
||||||
func parseHunkNewRange(header string) (int, int) {
|
func parseHunkNewRange(header string) (int, int) {
|
||||||
plus := strings.IndexByte(header, '+')
|
_, after, ok := strings.Cut(header, "+")
|
||||||
if plus < 0 {
|
if !ok {
|
||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
rest := header[plus+1:]
|
rest := after
|
||||||
if sp := strings.IndexByte(rest, ' '); sp >= 0 {
|
if sp := strings.IndexByte(rest, ' '); sp >= 0 {
|
||||||
rest = rest[:sp]
|
rest = rest[:sp]
|
||||||
}
|
}
|
||||||
start, count := 0, 1
|
start, count := 0, 1
|
||||||
if comma := strings.IndexByte(rest, ','); comma >= 0 {
|
if before, after, ok := strings.Cut(rest, ","); ok {
|
||||||
start, _ = strconv.Atoi(rest[:comma])
|
start, _ = strconv.Atoi(before)
|
||||||
count, _ = strconv.Atoi(rest[comma+1:])
|
count, _ = strconv.Atoi(after)
|
||||||
} else {
|
} else {
|
||||||
start, _ = strconv.Atoi(rest)
|
start, _ = strconv.Atoi(rest)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,10 +68,7 @@ func checkToolbarInjection(root string) []toolbarViolation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bodyStart := fset.Position(fn.Body.Pos()).Offset
|
bodyStart := fset.Position(fn.Body.Pos()).Offset
|
||||||
bodyEnd := fset.Position(fn.Body.End()).Offset
|
bodyEnd := min(fset.Position(fn.Body.End()).Offset, len(srcText))
|
||||||
if bodyEnd > len(srcText) {
|
|
||||||
bodyEnd = len(srcText)
|
|
||||||
}
|
|
||||||
body := srcText[bodyStart:bodyEnd]
|
body := srcText[bodyStart:bodyEnd]
|
||||||
|
|
||||||
hasSiteSettings := strings.Contains(body, "getSiteSettings")
|
hasSiteSettings := strings.Contains(body, "getSiteSettings")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user