mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 10:21:00 +00:00
add chown command to switch repo owner
This commit is contained in:
parent
8de93539e3
commit
d656b2a75b
2 changed files with 14 additions and 0 deletions
|
@ -103,6 +103,7 @@ func Load(middleware ...gin.HandlerFunc) http.Handler {
|
|||
// requires push permissions
|
||||
repo.PATCH("", session.MustPush, server.PatchRepo)
|
||||
repo.DELETE("", session.MustPush, server.DeleteRepo)
|
||||
repo.POST("/chown", session.MustPush, server.ChownRepo)
|
||||
|
||||
repo.POST("/builds/:number", session.MustPush, server.PostBuild)
|
||||
repo.DELETE("/builds/:number/:job", session.MustPush, server.DeleteBuild)
|
||||
|
|
|
@ -136,6 +136,19 @@ func PatchRepo(c *gin.Context) {
|
|||
c.JSON(http.StatusOK, repo)
|
||||
}
|
||||
|
||||
func ChownRepo(c *gin.Context) {
|
||||
repo := session.Repo(c)
|
||||
user := session.User(c)
|
||||
repo.UserID = user.ID
|
||||
|
||||
err := store.UpdateRepo(c, repo)
|
||||
if err != nil {
|
||||
c.AbortWithError(http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, repo)
|
||||
}
|
||||
|
||||
func GetRepo(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, session.Repo(c))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue