From cda2de9606f53d5c72b92aaac12e670492c48d74 Mon Sep 17 00:00:00 2001 From: Darko Draskovic Date: Thu, 21 Mar 2024 17:43:32 +0000 Subject: [PATCH] Add fix for git show numstat result in - - str (#1130) --- git/adapter/commit.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/git/adapter/commit.go b/git/adapter/commit.go index 023b1287e..1f7ff36e6 100644 --- a/git/adapter/commit.go +++ b/git/adapter/commit.go @@ -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{},