Skip to content

Commit ff82a18

Browse files
lunnywxiaoguangdelvh
authored
Fix mirror template bug (#19959)
* Fix mirror template bug Co-authored-by: wxiaoguang <[email protected]> Co-authored-by: delvh <[email protected]>
1 parent 3c6c150 commit ff82a18

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

modules/context/repo.go

+6-14
Original file line numberDiff line numberDiff line change
@@ -380,24 +380,16 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
380380
ctx.Data["Permission"] = &ctx.Repo.Permission
381381

382382
if repo.IsMirror {
383-
384-
// Check if the mirror has finsihed migrationg, only then we can
385-
// lookup the mirror informtation the database.
386-
finishedMigrating, err := models.HasFinishedMigratingTask(repo.ID)
387-
if err != nil {
388-
ctx.ServerError("HasFinishedMigratingTask", err)
389-
return
390-
}
391-
if finishedMigrating {
392-
ctx.Repo.Mirror, err = repo_model.GetMirrorByRepoID(ctx, repo.ID)
393-
if err != nil {
394-
ctx.ServerError("GetMirrorByRepoID", err)
395-
return
396-
}
383+
ctx.Repo.Mirror, err = repo_model.GetMirrorByRepoID(ctx, repo.ID)
384+
if err == nil {
397385
ctx.Repo.Mirror.Repo = repo
386+
ctx.Data["IsPullMirror"] = true
398387
ctx.Data["MirrorEnablePrune"] = ctx.Repo.Mirror.EnablePrune
399388
ctx.Data["MirrorInterval"] = ctx.Repo.Mirror.Interval
400389
ctx.Data["Mirror"] = ctx.Repo.Mirror
390+
} else if err != repo_model.ErrMirrorNotExist {
391+
ctx.ServerError("GetMirrorByRepoID", err)
392+
return
401393
}
402394
}
403395

templates/repo/header.tmpl

+4-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737
{{end}}
3838
</div>
3939
</div>
40-
{{if .IsMirror}}
41-
{{$address := MirrorRemoteAddress $.Context . $.Mirror.GetRemoteName}}
42-
<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" rel="noopener noreferrer" href="{{$address.Address}}">{{$address.Address}}</a></div>{{end}}
40+
{{if $.IsPullMirror}}
41+
{{$address := MirrorRemoteAddress $.Context . $.Mirror.GetRemoteName}}
42+
<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" rel="noopener noreferrer" href="{{$address.Address}}">{{$address.Address}}</a></div>
43+
{{end}}
4344
{{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{.BaseRepo.FullName}}</a></div>{{end}}
4445
{{if .IsGenerated}}<div class="fork-flag">{{$.i18n.Tr "repo.generated_from"}} <a href="{{.TemplateRepo.Link}}">{{.TemplateRepo.FullName}}</a></div>{{end}}
4546
</div>

0 commit comments

Comments
 (0)