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:
parent
8de93539e3
commit
d656b2a75b
@ -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 New Issue
Block a user