woodpecker/server
Lukas 12ff74c4cb
Fix branch loading (#1249)
Fixes a panic I got while viewing the branches in the UI.

```
runtime error: index out of range [0] with length 0
/home/gitpod/go/src/runtime/panic.go:113 (0x44053e)
        goPanicIndex: panic(boundsError{x: int64(x), signed: true, y: y, code: boundsIndex})
/workspace/woodpecker/server/remote/gitea/gitea.go:444 (0xd36764)
        (*Gitea).Branches.func1: result[i] = branches[i].Name
/workspace/woodpecker/server/remote/common/utils.go:34 (0xd3942a)
        Paginate[...]: batch, err := get(page)
/workspace/woodpecker/server/remote/gitea/gitea.go:439 (0xd36665)
        (*Gitea).Branches: branches, err := common.Paginate(func(page int) ([]string, error) {
/workspace/woodpecker/server/api/repo.go:202 (0xc823a1)
        GetRepoBranches: branches, err := r.Branches(c, user, repo)
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xc71d44)
        (*Context).Next: c.handlers[c.index](c)
/workspace/woodpecker/server/router/middleware/session/repo.go:148 (0xc71bba)
        MustPull: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xc71aee)
        (*Context).Next: c.handlers[c.index](c)
/workspace/woodpecker/server/router/middleware/session/repo.go:139 (0xc71aaa)
        SetPerm.func1: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xc71251)
        (*Context).Next: c.handlers[c.index](c)
/workspace/woodpecker/server/router/middleware/session/repo.go:53 (0xc710ec)
        SetRepo.func1: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xccb50f)
        (*Context).Next: c.handlers[c.index](c)
/workspace/woodpecker/server/router/middleware/token/token.go:50 (0xccb248)
        Refresh: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xc721fc)
        (*Context).Next: c.handlers[c.index](c)
/workspace/woodpecker/server/router/middleware/session/user.go:72 (0xc721e3)
        SetUser.func1: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xcd069e)
        (*Context).Next: c.handlers[c.index](c)
/workspace/woodpecker/server/router/middleware/store.go:29 (0xcd0685)
        Store.func1: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xccff47)
        (*Context).Next: c.handlers[c.index](c)
/workspace/woodpecker/server/router/middleware/logger.go:23 (0xccff2a)
        Logger.func1: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xccaf99)
        (*Context).Next: c.handlers[c.index](c)
/workspace/woodpecker/server/router/middleware/header/header.go:38 (0xccaec4)
        Options: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xccae21)
        (*Context).Next: c.handlers[c.index](c)
/workspace/woodpecker/server/router/middleware/header/header.go:30 (0xccae06)
        NoCache: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xccf32a)
        (*Context).Next: c.handlers[c.index](c)
/workspace/woodpecker/server/router/router.go:39 (0xccf310)
        Load.func1: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xa2e0c1)
        (*Context).Next: c.handlers[c.index](c)
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/recovery.go:101 (0xa2e0ac)
        CustomRecoveryWithWriter.func1: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/context.go:173 (0xa2cf30)
        (*Context).Next: c.handlers[c.index](c)
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/gin.go:616 (0xa2cb98)
        (*Engine).handleHTTPRequest: c.Next()
/workspace/go/pkg/mod/github.com/gin-gonic/gin@v1.8.1/gin.go:572 (0xa2c6dc)
        (*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/home/gitpod/go/src/net/http/server.go:2947 (0x79cc4b)
        serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/home/gitpod/go/src/net/http/server.go:1991 (0x797e66)
        (*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/home/gitpod/go/src/runtime/asm_amd64.s:1594 (0x476d80)
        goexit: BYTE    $0x90   // NOP
```

Co-authored-by: Anbraten <anton@ju60.de>
2022-10-09 21:10:36 +02:00
..
api Add ability to trigger manual builds (#1156) 2022-09-27 11:05:00 +02:00
badges fix badges (#957) 2022-06-04 16:23:45 +02:00
cache Add method to check organization membership (#1037) 2022-07-25 03:09:35 +02:00
ccmenu Move Badge & CCMenue into own packages (#908) 2022-05-14 14:30:09 +02:00
cron Create mock for store and add unit tests for cron (#1146) 2022-09-01 01:19:49 +02:00
grpc Add agent tagging / filtering for pipelines (#902) 2022-05-31 01:12:18 +02:00
logging Remove unused code (#797) 2022-02-25 21:42:45 +01:00
model Sort secret lists and events (#1223) 2022-09-29 22:46:20 +02:00
pipeline Add when evaluate filter (#1213) 2022-10-06 01:49:23 +02:00
plugins Dedup code and migrate away from deprecated funcs (#1141) 2022-08-30 01:14:07 +02:00
pubsub Add linter staticcheck (#535) 2021-11-25 17:15:36 +01:00
queue Add agent tagging / filtering for pipelines (#902) 2022-05-31 01:12:18 +02:00
remote Fix branch loading (#1249) 2022-10-09 21:10:36 +02:00
router Add ability to trigger manual builds (#1156) 2022-09-27 11:05:00 +02:00
shared Add when evaluate filter (#1213) 2022-10-06 01:49:23 +02:00
store Sort secret lists and events (#1223) 2022-09-29 22:46:20 +02:00
swagger Fetch repositories with remote ID if possible (#1078) 2022-09-05 17:08:51 +02:00
web Show forge icons in UI (#987) 2022-06-17 20:14:01 +02:00
config.go Add method to check organization membership (#1037) 2022-07-25 03:09:35 +02:00