From a2dd9ec2e1d0d613f3af9f9722e433eaa6c86a5f Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 8 Feb 2017 18:13:46 -0500 Subject: models/org_team: panic when team num_repos is negative (#3671) --- models/org_team.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'models') diff --git a/models/org_team.go b/models/org_team.go index b119dfbb..0d132b20 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 -- cgit v1.2.3