Skip to content

Commit e79272a

Browse files
Caellionlunny
andauthored
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 <[email protected]> * Update repo.go Co-authored-by: Lunny Xiao <[email protected]>
1 parent cc129d2 commit e79272a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

models/repo/repo.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,16 @@ func getTemplateRepo(e db.Engine, repo *Repository) (*Repository, error) {
683683
return getRepositoryByID(e, repo.TemplateID)
684684
}
685685

686+
// TemplateRepo returns the repository, which is template of this repository
687+
func (repo *Repository) TemplateRepo() *Repository {
688+
repo, err := GetTemplateRepo(repo)
689+
if err != nil {
690+
log.Error("TemplateRepo: %v", err)
691+
return nil
692+
}
693+
return repo
694+
}
695+
686696
func countRepositories(userID int64, private bool) int64 {
687697
sess := db.GetEngine(db.DefaultContext).Where("id > 0")
688698

0 commit comments

Comments
 (0)