Merge branch 'develop' into feature-convenient-mock

This commit is contained in:
iabetor 2021-05-24 21:30:33 +08:00 committed by GitHub
commit 23d191da9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 8 deletions

17
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@v1 - uses: actions/stale@v3.0.19
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is inactive for a long time.' stale-issue-message: 'This issue is inactive for a long time.'

View File

@ -2,6 +2,8 @@ language: go
go: go:
- "1.14.x" - "1.14.x"
- "1.15.x"
- "1.16.x"
services: services:
- redis-server - redis-server
- mysql - mysql
@ -12,7 +14,7 @@ env:
global: global:
- GO_REPO_FULLNAME="github.com/beego/beego/v2" - GO_REPO_FULLNAME="github.com/beego/beego/v2"
matrix: matrix:
- ORM_DRIVER=sqlite3 ORM_SOURCE=$TRAVIS_BUILD_DIR/orm_test.db - ORM_DRIVER=sqlite3 ORM_SOURCE=$TRAVIS_BUILD_DIR/orm_test.db
- ORM_DRIVER=postgres ORM_SOURCE="user=postgres dbname=orm_test sslmode=disable" - ORM_DRIVER=postgres ORM_SOURCE="user=postgres dbname=orm_test sslmode=disable"
- ORM_DRIVER=mysql export ORM_SOURCE="root:@/orm_test?charset=utf8" - ORM_DRIVER=mysql export ORM_SOURCE="root:@/orm_test?charset=utf8"
before_install: before_install:

View File

@ -1,8 +1,10 @@
# developing # developing
- Add: Convenient way to generate mock object [4620](https://github.com/beego/beego/issues/4397) - Add: Convenient way to generate mock object [4620](https://github.com/beego/beego/issues/4397)
- Infra: use dependabot to update dependencies. [4623](https://github.com/beego/beego/pull/4623)
- Lint: use golangci-lint. [4619](https://github.com/beego/beego/pull/4619) - Lint: use golangci-lint. [4619](https://github.com/beego/beego/pull/4619)
- Chore: format code. [4615](https://github.com/beego/beego/pull/4615) - Chore: format code. [4615](https://github.com/beego/beego/pull/4615)
- Test on Go v1.15.x & v1.16.x. [4614](https://github.com/beego/beego/pull/4614)
- Env: non-empty GOBIN & GOPATH. [4613](https://github.com/beego/beego/pull/4613) - Env: non-empty GOBIN & GOPATH. [4613](https://github.com/beego/beego/pull/4613)
- Chore: update dependencies. [4611](https://github.com/beego/beego/pull/4611) - Chore: update dependencies. [4611](https://github.com/beego/beego/pull/4611)
- Update orm_test.go/TestInsertOrUpdate with table-driven. [4609](https://github.com/beego/beego/pull/4609) - Update orm_test.go/TestInsertOrUpdate with table-driven. [4609](https://github.com/beego/beego/pull/4609)
@ -49,6 +51,7 @@
## Fix Sonar ## Fix Sonar
- [4624](https://github.com/beego/beego/pull/4624)
- [4608](https://github.com/beego/beego/pull/4608) - [4608](https://github.com/beego/beego/pull/4608)
- [4473](https://github.com/beego/beego/pull/4473) - [4473](https://github.com/beego/beego/pull/4473)
- [4474](https://github.com/beego/beego/pull/4474) - [4474](https://github.com/beego/beego/pull/4474)

View File

@ -250,7 +250,8 @@ func (c *Controller) Bind(obj interface{}) error {
return c.BindJson(obj) return c.BindJson(obj)
} }
i, l := 0, len(ct[0]) i, l := 0, len(ct[0])
for ; i < l && ct[0][i] != ';'; i++ { for i < l && ct[0][i] != ';' {
i++
} }
switch ct[0][0:i] { switch ct[0][0:i] {
case "application/json": case "application/json":

View File

@ -284,7 +284,7 @@ func (t *Tree) addseg(segments []string, route interface{}, wildcards []string,
// Match router to runObject & params // Match router to runObject & params
func (t *Tree) Match(pattern string, ctx *context.Context) (runObject interface{}) { func (t *Tree) Match(pattern string, ctx *context.Context) (runObject interface{}) {
if len(pattern) == 0 || pattern[0] != '/' { if pattern == "" || pattern[0] != '/' {
return nil return nil
} }
w := make([]string, 0, 20) w := make([]string, 0, 20)
@ -294,12 +294,13 @@ func (t *Tree) Match(pattern string, ctx *context.Context) (runObject interface{
func (t *Tree) match(treePattern string, pattern string, wildcardValues []string, ctx *context.Context) (runObject interface{}) { func (t *Tree) match(treePattern string, pattern string, wildcardValues []string, ctx *context.Context) (runObject interface{}) {
if len(pattern) > 0 { if len(pattern) > 0 {
i, l := 0, len(pattern) i, l := 0, len(pattern)
for ; i < l && pattern[i] == '/'; i++ { for i < l && pattern[i] == '/' {
i++
} }
pattern = pattern[i:] pattern = pattern[i:]
} }
// Handle leaf nodes: // Handle leaf nodes:
if len(pattern) == 0 { if pattern == "" {
for _, l := range t.leaves { for _, l := range t.leaves {
if ok := l.match(treePattern, wildcardValues, ctx); ok { if ok := l.match(treePattern, wildcardValues, ctx); ok {
return l.runObject return l.runObject
@ -316,7 +317,8 @@ func (t *Tree) match(treePattern string, pattern string, wildcardValues []string
} }
var seg string var seg string
i, l := 0, len(pattern) i, l := 0, len(pattern)
for ; i < l && pattern[i] != '/'; i++ { for i < l && pattern[i] != '/' {
i++
} }
if i == 0 { if i == 0 {
seg = pattern seg = pattern
@ -327,7 +329,7 @@ func (t *Tree) match(treePattern string, pattern string, wildcardValues []string
} }
for _, subTree := range t.fixrouters { for _, subTree := range t.fixrouters {
if subTree.prefix == seg { if subTree.prefix == seg {
if len(pattern) != 0 && pattern[0] == '/' { if pattern != "" && pattern[0] == '/' {
treePattern = pattern[1:] treePattern = pattern[1:]
} else { } else {
treePattern = pattern treePattern = pattern