Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scanrepository/scanrepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ func (cfp *ScanRepositoryCmd) fixMultiplePackages(fullProjectPath string, vulner
// Otherwise, it performs a force push to the same branch and reopens the pull request if it was closed.
// Only one aggregated pull request should remain open at all times.
func (cfp *ScanRepositoryCmd) fixIssuesSinglePR(repository *utils.Repository, vulnerabilitiesMap map[string]map[string]*utils.VulnerabilityDetails) (err error) {
aggregatedFixBranchName := cfp.gitManager.GenerateAggregatedFixBranchName(cfp.scanDetails.BaseBranch(), cfp.projectTech)
aggregatedFixBranchName, err := cfp.gitManager.GenerateAggregatedFixBranchName(cfp.scanDetails.BaseBranch(), cfp.projectTech)
if err != nil {
return
}
existingPullRequestDetails, err := cfp.getOpenPullRequestBySourceBranch(aggregatedFixBranchName)
if err != nil {
return
Expand Down
8 changes: 6 additions & 2 deletions utils/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,16 @@ func (gm *GitManager) getPullRequestTitleTemplate(tech []techutils.Technology) s

// GenerateAggregatedFixBranchName Generating a consistent branch name to enable branch updates
// and to ensure that there is only one Frogbot aggregate pull request from each base branch scanned.
func (gm *GitManager) GenerateAggregatedFixBranchName(baseBranch string, tech []techutils.Technology) (fixBranchName string) {
func (gm *GitManager) GenerateAggregatedFixBranchName(baseBranch string, tech []techutils.Technology) (fixBranchName string, err error) {
branchFormat := gm.customTemplates.branchNameTemplate
if branchFormat == "" {
branchFormat = AggregatedBranchNameTemplate
}
return formatStringWithPlaceHolders(branchFormat, "", "", techArrayToString(tech, fixBranchTechSeparator), baseBranch, false)
hash, err := Md5Hash("frogbot", baseBranch, techArrayToString(tech, fixBranchTechSeparator))
if err != nil {
return "", err
}
return formatStringWithPlaceHolders(branchFormat, techArrayToString(tech, fixBranchTechSeparator), "", hash, baseBranch, false), nil
}

// dryRunClone clones an existing repository from our testdata folder into the destination folder for testing purposes.
Expand Down
2 changes: 1 addition & 1 deletion utils/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestGitManager_GenerateAggregatedFixBranchName(t *testing.T) {
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
titleOutput := test.gitManager.GenerateAggregatedFixBranchName(test.baseBranch, []techutils.Technology{techutils.Go})
titleOutput, _ := test.gitManager.GenerateAggregatedFixBranchName(test.baseBranch, []techutils.Technology{techutils.Go})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add
assert.NoError(t, err)

assert.Equal(t, test.expected, titleOutput)
})
}
Expand Down
Loading