From 2075e181bde2bef852d1cd09c3be37182db31635 Mon Sep 17 00:00:00 2001 From: Eyal Delarea Date: Thu, 4 May 2023 23:00:41 +0300 Subject: [PATCH] Frogbot may fail for Azure Repos due to a bug in the "fetch commit status" API (#328) --- commands/scanandfixrepos.go | 2 +- commands/utils/utils.go | 14 ++++++++++++++ go.mod | 4 +--- go.sum | 4 ++-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/commands/scanandfixrepos.go b/commands/scanandfixrepos.go index 19709e6c2..a6f8a665f 100644 --- a/commands/scanandfixrepos.go +++ b/commands/scanandfixrepos.go @@ -90,7 +90,7 @@ func (saf *ScanAndFixRepositories) setCommitBuildStatus(client vcsclient.VcsClie if err := client.SetCommitStatus(context.Background(), state, repoConfig.RepoOwner, repoConfig.RepoName, commitHash, utils.FrogbotCreatorName, description, utils.CommitStatusDetailsUrl); err != nil { return fmt.Errorf("failed to mark last commit build status due to: %s", err.Error()) } - log.Info("Commit'", commitHash, "'in repo '", repoConfig.RepoName, "', has successfully marked as scanned") + log.Info(fmt.Sprintf("Commit '%s' in repo '%s', has successfuly marked as %s", commitHash, repoConfig.RepoName, utils.CommitStatusToString(state))) return nil } diff --git a/commands/utils/utils.go b/commands/utils/utils.go index 9cdd1ccd5..d66716110 100644 --- a/commands/utils/utils.go +++ b/commands/utils/utils.go @@ -149,6 +149,20 @@ func Md5Hash(values ...string) (string, error) { return hex.EncodeToString(hash.Sum(nil)), nil } +func CommitStatusToString(status vcsclient.CommitStatus) string { + switch status { + case 0: + return "passed" + case 1: + return "failed" + case 2: + return "error" + case 3: + return "in progress" + } + return "" +} + // Generates MD5Hash from a FixVersionMap object // The map can be returned in different order from Xray, so we need to sort the strings before hashing. func fixVersionsMapToMd5Hash(versionsMap map[string]*FixVersionInfo) (string, error) { diff --git a/go.mod b/go.mod index c9c86a2eb..2e99f61ab 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/go-git/go-git/v5 v5.6.1 github.com/golang/mock v1.6.0 github.com/jfrog/build-info-go v1.9.3 - github.com/jfrog/froggit-go v1.7.1 + github.com/jfrog/froggit-go v1.7.2 github.com/jfrog/gofrog v1.3.0 github.com/jfrog/jfrog-cli-core/v2 v2.32.1 github.com/jfrog/jfrog-client-go v1.28.3 @@ -116,5 +116,3 @@ require ( //replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230430083747-590ae14f9dca //replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27 - -//replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230403064815-ea83b399ac8e diff --git a/go.sum b/go.sum index d1903e200..513c11e27 100644 --- a/go.sum +++ b/go.sum @@ -225,8 +225,8 @@ github.com/jedib0t/go-pretty/v6 v6.4.6/go.mod h1:Ndk3ase2CkQbXLLNf5QDHoYb6J9WtVf github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jfrog/build-info-go v1.9.3 h1:ZpVcNM4hH+r6dK0ERdSNaizuZALPgSdE29Da1Iki1fo= github.com/jfrog/build-info-go v1.9.3/go.mod h1:GbuFS+viHCKZYx9nWHYu7ab1DgQkFdtVN3BJPUNb2D4= -github.com/jfrog/froggit-go v1.7.1 h1:1LBOjB3qZCW2Ys/GqG52zYHlmtHICaprDgwLvBbJy+w= -github.com/jfrog/froggit-go v1.7.1/go.mod h1:xfsfQXzSaAM04RV9IyU5heBiRrsm2oS6rFCfEofQr6U= +github.com/jfrog/froggit-go v1.7.2 h1:uxbIHlfoCRjgCpZhKrw7NY9sLtGqcFppFHc0JdiXi6c= +github.com/jfrog/froggit-go v1.7.2/go.mod h1:xfsfQXzSaAM04RV9IyU5heBiRrsm2oS6rFCfEofQr6U= github.com/jfrog/gofrog v1.3.0 h1:o4zgsBZE4QyDbz2M7D4K6fXPTBJht+8lE87mS9bw7Gk= github.com/jfrog/gofrog v1.3.0/go.mod h1:IFMc+V/yf7rA5WZ74CSbXe+Lgf0iApEQLxRZVzKRUR0= github.com/jfrog/jfrog-cli-core/v2 v2.32.1 h1:dsCMMX5H2J1/VcCqogWJjLqy+hlKpTEi4gy55w0etDw=