mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
didn't realize gin supports net.Context. Change to support Context pattern!
This commit is contained in:
@@ -6,14 +6,12 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/drone/drone/model"
|
||||
"github.com/drone/drone/router/middleware/context"
|
||||
"github.com/drone/drone/router/middleware/session"
|
||||
"github.com/drone/drone/shared/token"
|
||||
"github.com/drone/drone/store"
|
||||
)
|
||||
|
||||
func GetCommit(c *gin.Context) {
|
||||
db := context.Database(c)
|
||||
repo := session.Repo(c)
|
||||
|
||||
parsed, err := token.ParseRequest(c.Request, func(t *token.Token) (string, error) {
|
||||
@@ -34,7 +32,7 @@ func GetCommit(c *gin.Context) {
|
||||
branch = repo.Branch
|
||||
}
|
||||
|
||||
build, err := model.GetBuildCommit(db, repo, commit, branch)
|
||||
build, err := store.GetBuildCommit(c, repo, commit, branch)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
@@ -44,7 +42,6 @@ func GetCommit(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetPullRequest(c *gin.Context) {
|
||||
db := context.Database(c)
|
||||
repo := session.Repo(c)
|
||||
refs := fmt.Sprintf("refs/pull/%s/head", c.Param("number"))
|
||||
|
||||
@@ -60,7 +57,7 @@ func GetPullRequest(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
build, err := model.GetBuildRef(db, repo, refs)
|
||||
build, err := store.GetBuildRef(c, repo, refs)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
@@ -70,7 +67,6 @@ func GetPullRequest(c *gin.Context) {
|
||||
}
|
||||
|
||||
func RedirectSha(c *gin.Context) {
|
||||
db := context.Database(c)
|
||||
repo := session.Repo(c)
|
||||
|
||||
commit := c.Param("sha")
|
||||
@@ -79,7 +75,7 @@ func RedirectSha(c *gin.Context) {
|
||||
branch = repo.Branch
|
||||
}
|
||||
|
||||
build, err := model.GetBuildCommit(db, repo, commit, branch)
|
||||
build, err := store.GetBuildCommit(c, repo, commit, branch)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
@@ -90,11 +86,10 @@ func RedirectSha(c *gin.Context) {
|
||||
}
|
||||
|
||||
func RedirectPullRequest(c *gin.Context) {
|
||||
db := context.Database(c)
|
||||
repo := session.Repo(c)
|
||||
refs := fmt.Sprintf("refs/pull/%s/head", c.Param("number"))
|
||||
|
||||
build, err := model.GetBuildRef(db, repo, refs)
|
||||
build, err := store.GetBuildRef(c, repo, refs)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusNotFound, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user