summaryrefslogtreecommitdiffstats
path: root/pkg/commands/patch/patch_modifier.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/commands/patch/patch_modifier.go')
-rw-r--r--pkg/commands/patch/patch_modifier.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/commands/patch/patch_modifier.go b/pkg/commands/patch/patch_modifier.go
index 2d060ec18..fe0a896b1 100644
--- a/pkg/commands/patch/patch_modifier.go
+++ b/pkg/commands/patch/patch_modifier.go
@@ -27,7 +27,9 @@ func GetHunksFromDiff(diff string) []*PatchHunk {
var hunkLines []string //nolint:prealloc
pastDiffHeader := false
- for lineIdx, line := range strings.SplitAfter(diff, "\n") {
+ lines := strings.SplitAfter(diff, "\n")
+
+ for lineIdx, line := range lines {
isHunkHeader := strings.HasPrefix(line, "@@ -")
if isHunkHeader {
@@ -44,6 +46,10 @@ func GetHunksFromDiff(diff string) []*PatchHunk {
continue
}
+ if lineIdx == len(lines)-1 && line == "" { // skip the trailing newline
+ continue
+ }
+
hunkLines = append(hunkLines, line)
}