From db10ce74b6bcf427c0049cc3b0c9c71ec956908d Mon Sep 17 00:00:00 2001 From: mohaijiang Date: Mon, 11 Mar 2024 16:28:16 +0800 Subject: [PATCH] update --- pkg/service/project.go | 14 ++++++++++++++ pkg/vo/project_vo.go | 1 + 2 files changed, 15 insertions(+) diff --git a/pkg/service/project.go b/pkg/service/project.go index 83fc72c..a3d7c38 100644 --- a/pkg/service/project.go +++ b/pkg/service/project.go @@ -1,6 +1,7 @@ package service import ( + "context" "encoding/json" "errors" "fmt" @@ -127,6 +128,19 @@ func (p *ProjectService) GetProjects(userId int, keyword string, page, size, pro } data.RecentBuild = recentBuild data.RecentCheck = recentCheck + githubService := application.GetBean[*GithubService]("githubService") + ctx, _ := context.WithTimeout(context.Background(), time.Second*20) + owner, repo, err := ParsingGitHubURL(project.RepositoryUrl) + if err != nil { + branches, err2 := githubService.ListRepositoryBranch(ctx, owner, repo) + if err2 != nil { + data.AllBranch = []string{data.Branch} + } + data.AllBranch = branches + } else { + data.AllBranch = []string{data.Branch} + } + projectList = append(projectList, data) } } diff --git a/pkg/vo/project_vo.go b/pkg/vo/project_vo.go index c32d98b..a408111 100644 --- a/pkg/vo/project_vo.go +++ b/pkg/vo/project_vo.go @@ -29,6 +29,7 @@ type ProjectListVo struct { RecentCheck RecentCheckVo `json:"recentCheck"` RecentBuild RecentBuildVo `json:"recentBuild"` RecentDeploy interface{} `json:"recentDeploy"` + AllBranch []string `json:"allBranch"` } type ProjectDetailVo struct {