ProtectedBranch missing from models.go init #384

Closed
opened 2025-11-02 03:21:06 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @morrildl on GitHub (Feb 22, 2017).

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"}
Originally created by @morrildl on GitHub (Feb 22, 2017). 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"}
GiteaMirror added the type/bug label 2025-11-02 03:21:06 -06:00
Author
Owner

@strk commented on GitHub (Feb 23, 2017):

Duplicate of #1012

@strk commented on GitHub (Feb 23, 2017): Duplicate of #1012
Author
Owner

@strk commented on GitHub (Feb 23, 2017):

(ok, not a duplicate, now that I see #1021)

@strk commented on GitHub (Feb 23, 2017): (ok, not a duplicate, now that I see #1021)
Author
Owner

@lunny commented on GitHub (Feb 23, 2017):

resolved by #1021

@lunny commented on GitHub (Feb 23, 2017): resolved by #1021
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#384