Browse Source

Remove check for negative length (#5120)

tags/v1.7.0-dev
Oleg Kovalov 5 years ago
parent
commit
5a4648cdd6
7 changed files with 8 additions and 8 deletions
  1. 1
    1
      models/issue_label.go
  2. 2
    2
      models/org.go
  3. 1
    1
      models/ssh_key.go
  4. 1
    1
      modules/auth/auth.go
  5. 1
    1
      modules/user/user_test.go
  6. 1
    1
      routers/api/v1/api.go
  7. 1
    1
      routers/user/home.go

+ 1
- 1
models/issue_label.go View File

@@ -134,7 +134,7 @@ func NewLabels(labels ...*Label) error {
// If pass repoID as 0, then ORM will ignore limitation of repository
// and can return arbitrary label with any valid ID.
func getLabelInRepoByName(e Engine, repoID int64, labelName string) (*Label, error) {
if len(labelName) <= 0 {
if len(labelName) == 0 {
return nil, ErrLabelNotExist{0, repoID}
}


+ 2
- 2
models/org.go View File

@@ -677,7 +677,7 @@ func (env *accessibleReposEnv) Repos(page, pageSize int) ([]*Repository, error)
}

repos := make([]*Repository, 0, len(repoIDs))
if len(repoIDs) <= 0 {
if len(repoIDs) == 0 {
return repos, nil
}

@@ -705,7 +705,7 @@ func (env *accessibleReposEnv) MirrorRepos() ([]*Repository, error) {
}

repos := make([]*Repository, 0, len(repoIDs))
if len(repoIDs) <= 0 {
if len(repoIDs) == 0 {
return repos, nil
}


+ 1
- 1
models/ssh_key.go View File

@@ -376,7 +376,7 @@ func calcFingerprint(publicKeyContent string) (string, error) {
}

func addKey(e Engine, key *PublicKey) (err error) {
if len(key.Fingerprint) <= 0 {
if len(key.Fingerprint) == 0 {
key.Fingerprint, err = calcFingerprint(key.Content)
if err != nil {
return err

+ 1
- 1
modules/auth/auth.go View File

@@ -36,7 +36,7 @@ func SignedInID(ctx *macaron.Context, sess session.Store) int64 {
// Check access token.
if IsAPIPath(ctx.Req.URL.Path) {
tokenSHA := ctx.Query("token")
if len(tokenSHA) <= 0 {
if len(tokenSHA) == 0 {
tokenSHA = ctx.Query("access_token")
}
if len(tokenSHA) == 0 {

+ 1
- 1
modules/user/user_test.go View File

@@ -18,7 +18,7 @@ func getWhoamiOutput() (string, error) {

func TestCurrentUsername(t *testing.T) {
user := CurrentUsername()
if len(user) <= 0 {
if len(user) == 0 {
t.Errorf("expected non-empty user, got: %s", user)
}
// Windows whoami is weird, so just skip remaining tests

+ 1
- 1
routers/api/v1/api.go View File

@@ -80,7 +80,7 @@ import (
func sudo() macaron.Handler {
return func(ctx *context.APIContext) {
sudo := ctx.Query("sudo")
if len(sudo) <= 0 {
if len(sudo) == 0 {
sudo = ctx.Req.Header.Get("Sudo")
}


+ 1
- 1
routers/user/home.go View File

@@ -213,7 +213,7 @@ func Issues(ctx *context.Context) {
return
}
}
if len(userRepoIDs) <= 0 {
if len(userRepoIDs) == 0 {
userRepoIDs = []int64{-1}
}


Loading…
Cancel
Save