diff options
author | Caellion <administrator@michalpol.pl> | 2021-12-16 08:12:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-16 15:12:50 +0800 |
commit | e79272ab2047b4fa18fbdb469b3d987c902e6b05 (patch) | |
tree | 3a2a6631f736e3fcb69c4f8ee0e58262d6d6f1d5 /models | |
parent | cc129d2ca22100fe9c28106d9bc302678651f339 (diff) | |
download | gitea-e79272ab2047b4fa18fbdb469b3d987c902e6b05.tar.gz gitea-e79272ab2047b4fa18fbdb469b3d987c902e6b05.zip |
Fix TemplateRepo no longer in models.repo (#17993)
* Fixes error 500 that appears when trying to browse code of a repository generated from template
* forgot to update comment
* Update models/repo/repo.go
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Update repo.go
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'models')
-rw-r--r-- | models/repo/repo.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/models/repo/repo.go b/models/repo/repo.go index e5943b5a2d..43ac9fb62a 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -683,6 +683,16 @@ func getTemplateRepo(e db.Engine, repo *Repository) (*Repository, error) { return getRepositoryByID(e, repo.TemplateID) } +// TemplateRepo returns the repository, which is template of this repository +func (repo *Repository) TemplateRepo() *Repository { + repo, err := GetTemplateRepo(repo) + if err != nil { + log.Error("TemplateRepo: %v", err) + return nil + } + return repo +} + func countRepositories(userID int64, private bool) int64 { sess := db.GetEngine(db.DefaultContext).Where("id > 0") |