Skip to content

Commit

Permalink
Fix ccmenu endpoint (#2543)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty287 authored Oct 7, 2023
1 parent 3bd53b3 commit 6699577
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions server/api/badge.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,21 @@ func GetBadge(c *gin.Context) {
// @Param name path string true "the repository name"
func GetCC(c *gin.Context) {
_store := store.FromContext(c)
repo, err := _store.GetRepoName(c.Param("owner") + "/" + c.Param("name"))
var repo *model.Repo
var err error

if c.Param("repo_name") != "" {
repo, err = _store.GetRepoName(c.Param("repo_id_or_owner") + "/" + c.Param("repo_name"))
} else {
var repoID int64
repoID, err = strconv.ParseInt(c.Param("repo_id_or_owner"), 10, 64)
if err != nil {
c.AbortWithStatus(http.StatusBadRequest)
return
}
repo, err = _store.GetRepo(repoID)
}

if err != nil {
handleDbError(c, err)
return
Expand All @@ -118,7 +132,7 @@ func GetCC(c *gin.Context) {
return
}

url := fmt.Sprintf("%s/%s/%d", server.Config.Server.Host, repo.FullName, pipelines[0].Number)
url := fmt.Sprintf("%s/repos/%d/pipeline/%d", server.Config.Server.Host, repo.ID, pipelines[0].Number)
cc := ccmenu.New(repo, pipelines[0], url)
c.XML(http.StatusOK, cc)
}

0 comments on commit 6699577

Please sign in to comment.