Add fix for git show numstat result in - - str (#1130)

pull/3486/head
Darko Draskovic 2024-03-21 17:43:32 +00:00 committed by Harness
parent cbbb565f24
commit cda2de9606
1 changed files with 9 additions and 5 deletions

View File

@ -374,12 +374,11 @@ func getChangeInfoTypes(
return changeInfoTypes, nil
}
// Will match "31\t0\t.harness/apidiff.yaml".
// Will extract 31, 0 and .harness/apidiff.yaml.
var insertionsDeletionsRegex = regexp.MustCompile(`(\d+)\t(\d+)\t(.+)`)
// Will match "31\t0\t.harness/apidiff.yaml" and extract 31, 0 and .harness/apidiff.yaml.
// Will match "-\t-\ttools/code-api/chart/charts/harness-common-1.0.27.tgz" and extract -, -, and a filename.
var insertionsDeletionsRegex = regexp.MustCompile(`(\d+|-)\t(\d+|-)\t(.+)`)
// Will match "0\t0\tREADME.md => README_new.md".
// Will extract README_new.md.
// Will match "0\t0\tREADME.md => README_new.md" and extract README_new.md.
var renameRegexWithArrow = regexp.MustCompile(`\d+\t\d+\t.+\s=>\s(.+)`)
func getChangeInfoChanges(
@ -404,6 +403,11 @@ func getChangeInfoChanges(
path = renMatches[1]
}
if matches[1] == "-" || matches[2] == "-" {
changeInfos[path] = changeInfoChange{}
continue
}
insertions, err := strconv.ParseInt(matches[1], 10, 64)
if err != nil {
return map[string]changeInfoChange{},