Skip to content

Commit c60a978

Browse files
authored
feat: support repo project format {orga}/{repo} (#455)
Signed-off-by: ismael FALL <ismael.fall@epitech.eu> Signed-off-by: ismael FALL <ismael.fall@epitech.eu>
1 parent 7dd9057 commit c60a978

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

go/pkg/yolostore/store.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package yolostore
22

33
import (
44
"fmt"
5+
"strings"
56

67
"berty.tech/yolo/v2/go/pkg/yolopb"
78
"go.uber.org/zap"
@@ -241,6 +242,17 @@ type GetBuildListOpts struct {
241242
Limit int32
242243
}
243244

245+
// i.e, has_project=berty/berty -> has_project=https://github.com/berty/berty
246+
func formatProjectIDs(projectIDs []string) []string {
247+
for i, p := range projectIDs {
248+
if strings.Count(p, "/") == 1 {
249+
projectIDs[i] = fmt.Sprintf("https://github.com/%s", p)
250+
continue
251+
}
252+
}
253+
return projectIDs
254+
}
255+
244256
func (s *store) GetBuildList(bl GetBuildListOpts) ([]*yolopb.Build, error) {
245257
var builds []*yolopb.Build
246258

@@ -279,7 +291,8 @@ func (s *store) GetBuildList(bl GetBuildListOpts) ([]*yolopb.Build, error) {
279291
query = query.Where("build.driver IN (?)", bl.BuildDriver)
280292
}
281293
if len(bl.ProjectID) > 0 {
282-
query = query.Joins("JOIN project ON project.id = build.has_project_id AND (project.id IN (?) OR project.yolo_id IN (?))", bl.ProjectID, bl.ProjectID)
294+
formattedProjectsID := formatProjectIDs(bl.ProjectID)
295+
query = query.Joins("JOIN project ON project.id = build.has_project_id AND (project.id IN (?) OR project.yolo_id IN (?))", formattedProjectsID, formattedProjectsID)
283296
}
284297
if len(bl.MergeRequestID) > 0 {
285298
query = query.Where("build.has_mergerequest_id IN (?)", bl.MergeRequestID)

0 commit comments

Comments
 (0)