1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-24 10:07:21 +02:00

add chown command to switch repo owner

This commit is contained in:
Brad Rydzewski 2016-06-14 14:05:53 -07:00
parent 8de93539e3
commit d656b2a75b
2 changed files with 14 additions and 0 deletions

View File

@ -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)

View File

@ -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))
}