diff options
author | L0veSunshine <xuan199651@gmail.com> | 2020-04-08 20:13:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-08 15:13:04 +0300 |
commit | 08208cdfb87bc3f0b534eda9d9ef265dcfbc18c3 (patch) | |
tree | 1a5dd7d1dde5c1636666dd478b4e05994882cd4c /models | |
parent | b40107c4164748873f89a9553ed24e8403999339 (diff) | |
download | gitea-08208cdfb87bc3f0b534eda9d9ef265dcfbc18c3.tar.gz gitea-08208cdfb87bc3f0b534eda9d9ef265dcfbc18c3.zip |
Fix forked repo has no icon and language stat. (#10791)
* Update header.tmpl
* Update _repository.less
* Update pull.go
* Update indexer.go
* Update pull.go
* Update pull.go
* Update indexer.go
* fix forked repo doesn't have language stat
* fix forked repo doesn't have language stat
* fix forked repo doesn't have language stat
* fix forked repo doesn't have language stat
* fix forked repo doesn't have language stat
* fix forked repo doesn't have language stat
* fix forked repo doesn't have language stat
* fix forked repo doesn't have language stat
* fix forked repo doesn't have language stat
* fix forked repo doesn't have language stat
* fix forked repo doesn't have language stat
Thanks the advice from lunny and 6543.
* fix forked repo doesn't have language stat
Modified as suggested by 6543.
* fix forked repo doesn't have language stat
simplify the function.
* fix forked repo doesn't have language stat
update the indexer after the loop
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'models')
-rw-r--r-- | models/repo_language_stats.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/models/repo_language_stats.go b/models/repo_language_stats.go index bf8f5f59d0..fd5bcbb8ec 100644 --- a/models/repo_language_stats.go +++ b/models/repo_language_stats.go @@ -144,3 +144,32 @@ func (repo *Repository) UpdateLanguageStats(commitID string, stats map[string]fl return sess.Commit() } + +// CopyLanguageStat Copy originalRepo language stat information to destRepo (use for forked repo) +func CopyLanguageStat(originalRepo, destRepo *Repository) error { + sess := x.NewSession() + defer sess.Close() + if err := sess.Begin(); err != nil { + return err + } + RepoLang := make(LanguageStatList, 0, 6) + if err := sess.Where("`repo_id` = ?", originalRepo.ID).Desc("`percentage`").Find(&RepoLang); err != nil { + return err + } + if len(RepoLang) > 0 { + for i := range RepoLang { + RepoLang[i].ID = 0 + RepoLang[i].RepoID = destRepo.ID + RepoLang[i].CreatedUnix = timeutil.TimeStampNow() + } + //update destRepo's indexer status + tmpCommitID := RepoLang[0].CommitID + if err := destRepo.updateIndexerStatus(sess, RepoIndexerTypeStats, tmpCommitID); err != nil { + return err + } + if _, err := sess.Insert(&RepoLang); err != nil { + return err + } + } + return sess.Commit() +} |