MCPcopy
hub / github.com/harness/harness / ParseDiffHunkHeader

Function ParseDiffHunkHeader

git/parser/hunk.go:87–112  ·  view source on GitHub ↗
(line string)

Source from the content-addressed store, hash-verified

85}
86
87func ParseDiffHunkHeader(line string) (HunkHeader, bool) {
88 groups := regExpHunkHeader.FindStringSubmatch(line)
89 if groups == nil {
90 return HunkHeader{}, false
91 }
92
93 oldLine, _ := strconv.Atoi(groups[1])
94 oldSpan := 1
95 if groups[3] != "" {
96 oldSpan, _ = strconv.Atoi(groups[3])
97 }
98
99 newLine, _ := strconv.Atoi(groups[4])
100 newSpan := 1
101 if groups[6] != "" {
102 newSpan, _ = strconv.Atoi(groups[6])
103 }
104
105 return HunkHeader{
106 OldLine: oldLine,
107 OldSpan: oldSpan,
108 NewLine: newLine,
109 NewSpan: newSpan,
110 Text: groups[8],
111 }, true
112}

Callers 4

cutLinesFromFullFileDiffFunction · 0.92
createCommentMethod · 0.92
scanHunkHeaderFunction · 0.85
GetHunkHeadersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…