diff --git a/pkg/commands/patch_manager.go b/pkg/commands/patch_manager.go index 3cd106fbc..6c1b9ced9 100644 --- a/pkg/commands/patch_manager.go +++ b/pkg/commands/patch_manager.go @@ -23,7 +23,7 @@ type PatchManager struct { ApplyPatch applyPatchFunc } -// NewPatchManager returns a new PatchModifier +// NewPatchManager returns a new PatchManager func NewPatchManager(log *logrus.Entry, applyPatch applyPatchFunc) *PatchManager { return &PatchManager{ Log: log, @@ -31,7 +31,7 @@ func NewPatchManager(log *logrus.Entry, applyPatch applyPatchFunc) *PatchManager } } -// NewPatchManager returns a new PatchModifier +// NewPatchManager returns a new PatchManager func (p *PatchManager) Start(commitSha string, diffMap map[string]string) { p.CommitSha = commitSha p.fileInfoMap = map[string]*fileInfo{} @@ -101,8 +101,7 @@ func (p *PatchManager) RenderPlainPatchForFile(filename string, reverse bool, ke return info.diff case PART: // generate a new diff with just the selected lines - m := NewPatchModifier(p.Log, filename, info.diff) - return m.ModifiedPatchForLines(info.includedLineIndices, reverse, keepOriginalHeader) + return ModifiedPatchForLines(p.Log, filename, info.diff, info.includedLineIndices, reverse, keepOriginalHeader) default: return "" } diff --git a/pkg/commands/patch_modifier.go b/pkg/commands/patch_modifier.go index e407199c0..092814f90 100644 --- a/pkg/commands/patch_modifier.go +++ b/pkg/commands/patch_modifier.go @@ -258,3 +258,8 @@ func ModifiedPatchForRange(log *logrus.Entry, filename string, diffText string, p := NewPatchModifier(log, filename, diffText) return p.ModifiedPatchForRange(firstLineIdx, lastLineIdx, reverse, keepOriginalHeader) } + +func ModifiedPatchForLines(log *logrus.Entry, filename string, diffText string, includedLineIndices []int, reverse bool, keepOriginalHeader bool) string { + p := NewPatchModifier(log, filename, diffText) + return p.ModifiedPatchForLines(includedLineIndices, reverse, keepOriginalHeader) +}