From a2dd9ec2e1d0d613f3af9f9722e433eaa6c86a5f Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 8 Feb 2017 18:13:46 -0500 Subject: [PATCH] models/org_team: panic when team num_repos is negative (#3671) --- Makefile | 4 ++++ gogs.go | 2 +- models/org_team.go | 10 ++++++++++ templates/.VERSION | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index cc496b9a4..9b04e69e9 100644 --- a/Makefile +++ b/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 diff --git a/gogs.go b/gogs.go index 003d2ab96..3ab8f18e2 100644 --- a/gogs.go +++ b/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 diff --git a/models/org_team.go b/models/org_team.go index b119dfbb2..0d132b207 100644 --- a/models/org_team.go +++ b/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 diff --git a/templates/.VERSION b/templates/.VERSION index d6e10d7da..355ab4ef8 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.9.133.0207 \ No newline at end of file +0.9.134.0208 \ No newline at end of file