diff --git a/.travis.yml b/.travis.yml index 202f683a8..85d436958 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,18 @@ -os: linux language: go +os: linux +dist: xenial go: - 1.13.x - 1.14.x go_import_path: gogs.io/gogs - env: - GO111MODULE=on - before_install: - sudo apt-get update -qq - sudo apt-get install -y libpam-dev - script: + - go vet ./... - go build -v -tags "pam" - go test -v -race -coverprofile=coverage.txt -covermode=atomic ./... - after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index 7090f2e76..95ae58c7c 100644 --- a/Makefile +++ b/Makefile @@ -31,10 +31,6 @@ dist: release web: build ./gogs web -govet: - $(GOVET) gogs.go - $(GOVET) models pkg routes - build: $(GENERATED) go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)' -trimpath -o gogs diff --git a/internal/db/login_source.go b/internal/db/login_source.go index cb261f320..ee59cdbdc 100644 --- a/internal/db/login_source.go +++ b/internal/db/login_source.go @@ -695,7 +695,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC tperr, ok := err.(*textproto.Error) if (ok && tperr.Code == 535) || strings.Contains(err.Error(), "Username and Password not accepted") { - return nil, errors.UserNotExist{0, login} + return nil, errors.UserNotExist{Name: login} } return nil, err } @@ -735,7 +735,7 @@ func LoginViaSMTP(user *User, login, password string, sourceID int64, cfg *SMTPC func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMConfig, autoRegister bool) (*User, error) { if err := pam.PAMAuth(cfg.ServiceName, login, password); err != nil { if strings.Contains(err.Error(), "Authentication failure") { - return nil, errors.UserNotExist{0, login} + return nil, errors.UserNotExist{Name: login} } return nil, err } @@ -768,7 +768,7 @@ func LoginViaGitHub(user *User, login, password string, sourceID int64, cfg *Git fullname, email, url, location, err := github.Authenticate(cfg.APIEndpoint, login, password) if err != nil { if strings.Contains(err.Error(), "401") { - return nil, errors.UserNotExist{0, login} + return nil, errors.UserNotExist{Name: login} } return nil, err } @@ -840,7 +840,7 @@ func UserLogin(username, password string, loginSourceID int64) (*User, error) { return user, nil } - return nil, errors.UserNotExist{user.ID, user.Name} + return nil, errors.UserNotExist{UserID: user.ID, Name: user.Name} } // Remote login to the login source the user is associated with @@ -854,7 +854,7 @@ func UserLogin(username, password string, loginSourceID int64) (*User, error) { // Non-local login source is always greater than 0 if loginSourceID <= 0 { - return nil, errors.UserNotExist{-1, username} + return nil, errors.UserNotExist{UserID: -1, Name: username} } source, err := GetLoginSourceByID(loginSourceID) diff --git a/internal/db/mirror.go b/internal/db/mirror.go index f1b6f3d58..4ee3ce8e7 100644 --- a/internal/db/mirror.go +++ b/internal/db/mirror.go @@ -39,7 +39,7 @@ type Mirror struct { NextSync time.Time `xorm:"-" json:"-"` NextSyncUnix int64 `xorm:"next_update_unix"` - address string `xorm:"-" json:"-"` + address string `xorm:"-"` } func (m *Mirror) BeforeInsert() { diff --git a/internal/db/webhook.go b/internal/db/webhook.go index 96a01971f..418f2729b 100644 --- a/internal/db/webhook.go +++ b/internal/db/webhook.go @@ -437,10 +437,10 @@ type HookTask struct { func (t *HookTask) BeforeUpdate() { if t.RequestInfo != nil { - t.RequestContent = t.MarshalJSON(t.RequestInfo) + t.RequestContent = t.ToJSON(t.RequestInfo) } if t.ResponseInfo != nil { - t.ResponseContent = t.MarshalJSON(t.ResponseInfo) + t.ResponseContent = t.ToJSON(t.ResponseInfo) } } @@ -472,7 +472,7 @@ func (t *HookTask) AfterSet(colName string, _ xorm.Cell) { } } -func (t *HookTask) MarshalJSON(v interface{}) string { +func (t *HookTask) ToJSON(v interface{}) string { p, err := jsoniter.Marshal(v) if err != nil { log.Error("Marshal [%d]: %v", t.ID, err)