Ver Fonte

models/org_team: panic when team num_repos is negative (#3671)

Unknwon há 7 anos atrás
pai
commit
a2dd9ec2e1
4 ficheiros alterados com 16 adições e 2 exclusões
  1. 4 0
      Makefile
  2. 1 1
      gogs.go
  3. 10 0
      models/org_team.go
  4. 1 1
      templates/.VERSION

+ 4 - 0
Makefile

@@ -74,3 +74,7 @@ fixme:
 
 todo:
 	grep -rnw "TODO" routers models modules
+
+# Legacy code should be remove by the time of release
+legacy:
+	grep -rnw "LEGACY" routers models modules

+ 1 - 1
gogs.go

@@ -16,7 +16,7 @@ import (
 	"github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.9.133.0207"
+const APP_VER = "0.9.134.0208"
 
 func init() {
 	setting.AppVer = APP_VER

+ 10 - 0
models/org_team.go

@@ -26,6 +26,16 @@ type Team struct {
 	NumMembers  int
 }
 
+func (t *Team) AfterSet(colName string, _ xorm.Cell) {
+	switch colName {
+	case "num_repos":
+		// LEGACY [0.11]: this is backward compatibility bug fix for https://github.com/gogits/gogs/issues/3671
+		if t.NumRepos < 0 {
+			t.NumRepos = 0
+		}
+	}
+}
+
 // IsOwnerTeam returns true if team is owner team.
 func (t *Team) IsOwnerTeam() bool {
 	return t.Name == OWNER_TEAM

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.9.133.0207
+0.9.134.0208