Refactor comments in stripDiffFormat function
Simplified and clarified comments in the stripDiffFormat function to improve readability and maintainability. No functional changes were made to the code.
This commit is contained in:
parent
f6b49858a2
commit
25c0d0cf90
1 changed files with 3 additions and 6 deletions
|
|
@ -342,18 +342,15 @@ func stripDiffFormat(diff string) string {
|
|||
}
|
||||
}
|
||||
|
||||
// Guard clause: if we didn't find a hunk header, this isn't a diff, so
|
||||
// we defensively just return the original string.
|
||||
// This isn't a diff.
|
||||
if hunkEndIndex == -1 {
|
||||
return diff
|
||||
}
|
||||
|
||||
// We found the hunk header end; strip everything before it.
|
||||
// Removing hunk header.
|
||||
lines = lines[hunkEndIndex+1:]
|
||||
|
||||
// Now we strip the leading + and - from lines, if they exist.
|
||||
// Note: most of the time, but not all the time, we get a diff without
|
||||
// these prefixes.
|
||||
// Strip the leading + and - from lines, if they exist.
|
||||
var stripped []string
|
||||
for _, line := range lines {
|
||||
if strings.HasPrefix(line, "+") || strings.HasPrefix(line, "-") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue