Skip to content

Commit

Permalink
Fix TemplateRepo no longer in models.repo (go-gitea#17993)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
2 people authored and Stelios Malathouras committed Mar 28, 2022
1 parent 6c119e2 commit 7343eee
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions models/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 7343eee

Please sign in to comment.