Skip to content

ProtectedBranch missing from models.go init #1015

@morrildl

Description

@morrildl

With a new installation with clean git repos, a newly created repo cannot be pushed to. update.log says:

2017/02/22 13:24:38 [T] pushing to 1 master
2017/02/22 13:24:38 [.../gitea/cmd/update.go:63 runUpdate()] [F] retrieve protected branches information failed
2017/02/22 13:38:26 [T] pushing to 2 lol
2017/02/22 13:38:26 [.../gitea/cmd/update.go:63 runUpdate()] [F] retrieve protected branches information failed

Adding a bit of code to update:63 to print the err != nil shows:

2017/02/22 13:50:05 [.../gitea/cmd/update.go:63 runUpdate()] [F] retrieve protected branches information failed%!(EXTRA *pq.Error=pq: relation "protected_branch" does not exist)

This seems to be the same root cause as in #1012 -- and adding new(ProtectedBranch), to the init() also fixes this error, and I can push.

diff --git a/models/models.go b/models/models.go
index 33268fa..0840b46 100644
--- a/models/models.go
+++ b/models/models.go
@@ -114,6 +114,8 @@ func init() {
                new(TwoFactor),
                new(RepoUnit),
                new(RepoRedirect),
+               new(ExternalLoginUser),
+               new(ProtectedBranch),
        )
 
        gonicNames := []string{"SSL", "UID"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions