mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-26 02:10:31 +00:00
Refresh token before loading branches (#4284)
This commit is contained in:
parent
560eab96f0
commit
6ef7cddde8
1 changed files with 7 additions and 0 deletions
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/rs/zerolog/log"
|
||||
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/forge"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/model"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/router/middleware/session"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/store"
|
||||
|
@ -359,6 +360,7 @@ func GetRepoPermissions(c *gin.Context) {
|
|||
// @Param page query int false "for response pagination, page offset number" default(1)
|
||||
// @Param perPage query int false "for response pagination, max items per page" default(50)
|
||||
func GetRepoBranches(c *gin.Context) {
|
||||
_store := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
user := session.User(c)
|
||||
_forge, err := server.Config.Services.Manager.ForgeFromRepo(repo)
|
||||
|
@ -368,6 +370,8 @@ func GetRepoBranches(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
forge.Refresh(c, _forge, _store, user)
|
||||
|
||||
branches, err := _forge.Branches(c, user, repo, session.Pagination(c))
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("failed to load branches")
|
||||
|
@ -390,6 +394,7 @@ func GetRepoBranches(c *gin.Context) {
|
|||
// @Param page query int false "for response pagination, page offset number" default(1)
|
||||
// @Param perPage query int false "for response pagination, max items per page" default(50)
|
||||
func GetRepoPullRequests(c *gin.Context) {
|
||||
_store := store.FromContext(c)
|
||||
repo := session.Repo(c)
|
||||
user := session.User(c)
|
||||
_forge, err := server.Config.Services.Manager.ForgeFromRepo(repo)
|
||||
|
@ -399,6 +404,8 @@ func GetRepoPullRequests(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
forge.Refresh(c, _forge, _store, user)
|
||||
|
||||
prs, err := _forge.PullRequests(c, user, repo, session.Pagination(c))
|
||||
if err != nil {
|
||||
_ = c.AbortWithError(http.StatusInternalServerError, err)
|
||||
|
|
Loading…
Reference in a new issue