Skip to content

Commit

Permalink
Frogbot may fail for Azure Repos due to a bug in the "fetch commit st…
Browse files Browse the repository at this point in the history
…atus" API (#328)
  • Loading branch information
EyalDelarea authored May 4, 2023
1 parent 6939acb commit 2075e18
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion commands/scanandfixrepos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
14 changes: 14 additions & 0 deletions commands/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 2075e18

Please sign in to comment.