Various fixes and improvements (#1643)

- allow repo names to be case-insensitive
- improve backend error handling on DB get errors (record not found ->
404, else -> 500)
- replace magic numbers of http response codes
- unify the look and feel of cancel / save buttons on forms and view
them in one line

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
qwerty287
2023-03-19 13:52:58 +01:00
committed by GitHub
parent 42a115e19e
commit ade8e6d010
27 changed files with 230 additions and 179 deletions

View File

@@ -15,11 +15,13 @@
package session
import (
"errors"
"net/http"
"time"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"github.com/woodpecker-ci/woodpecker/server/store/types"
"github.com/woodpecker-ci/woodpecker/server"
"github.com/woodpecker-ci/woodpecker/server/model"
@@ -62,7 +64,11 @@ func SetRepo() gin.HandlerFunc {
)
if user != nil {
c.AbortWithStatus(http.StatusNotFound)
if errors.Is(err, types.RecordNotExist) {
c.AbortWithStatus(http.StatusNotFound)
return
}
_ = c.AbortWithError(http.StatusInternalServerError, err)
} else {
c.AbortWithStatus(http.StatusUnauthorized)
}