// 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}
}
}
repos := make([]*Repository, 0, len(repoIDs))
- if len(repoIDs) <= 0 {
+ if len(repoIDs) == 0 {
return repos, nil
}
}
repos := make([]*Repository, 0, len(repoIDs))
- if len(repoIDs) <= 0 {
+ if len(repoIDs) == 0 {
return repos, nil
}
}
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
// 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 {
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
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")
}
return
}
}
- if len(userRepoIDs) <= 0 {
+ if len(userRepoIDs) == 0 {
userRepoIDs = []int64{-1}
}