aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml8
-rw-r--r--Makefile4
-rw-r--r--internal/db/login_source.go10
-rw-r--r--internal/db/mirror.go2
-rw-r--r--internal/db/webhook.go6
5 files changed, 12 insertions, 18 deletions
diff --git a/.travis.yml b/.travis.yml
index 202f683a..85d43695 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 7090f2e7..95ae58c7 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 cb261f32..ee59cdbd 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 f1b6f3d5..4ee3ce8e 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 96a01971..418f2729 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)