diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 99b1979964..537ef71ccf 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -974,11 +974,11 @@ type remoteAddress struct { Password string } -func mirrorRemoteAddress(ctx context.Context, m *repo_model.Repository, remoteName string) remoteAddress { +func mirrorRemoteAddress(ctx context.Context, m *repo_model.Repository, remoteName string, ignoreOriginalURL bool) remoteAddress { a := remoteAddress{} remoteURL := m.OriginalURL - if remoteURL == "" { + if ignoreOriginalURL || remoteURL == "" { var err error remoteURL, err = git.GetRemoteAddress(ctx, m.RepoPath(), remoteName) if err != nil { diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 029e9a186f..94ae5ed7e2 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -38,7 +38,7 @@ {{if $.IsPullMirror}} - {{$address := MirrorRemoteAddress $.Context . $.Mirror.GetRemoteName}} + {{$address := MirrorRemoteAddress $.Context . $.Mirror.GetRemoteName false}}
{{$.i18n.Tr "repo.mirror_from"}} {{$address.Address}}
{{end}} {{if .IsFork}}
{{$.i18n.Tr "repo.forked_from"}} {{.BaseRepo.FullName}}
{{end}} diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 68cbd4de2c..ff7e2ca78a 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -91,7 +91,7 @@ {{if .Repository.IsMirror}} - {{(MirrorRemoteAddress $.Context .Repository .Mirror.GetRemoteName).Address}} + {{(MirrorRemoteAddress $.Context .Repository .Mirror.GetRemoteName false).Address}} {{$.i18n.Tr "repo.settings.mirror_settings.direction.pull"}} {{.Mirror.UpdatedUnix.AsTime}} @@ -119,7 +119,7 @@ - {{$address := MirrorRemoteAddress $.Context .Repository .Mirror.GetRemoteName}} + {{$address := MirrorRemoteAddress $.Context .Repository .Mirror.GetRemoteName false}}
@@ -168,7 +168,7 @@ {{range .PushMirrors}} - {{$address := MirrorRemoteAddress $.Context $.Repository .GetRemoteName}} + {{$address := MirrorRemoteAddress $.Context $.Repository .GetRemoteName true}} {{$address.Address}} {{$.i18n.Tr "repo.settings.mirror_settings.direction.push"}} {{if .LastUpdateUnix}}{{.LastUpdateUnix.AsTime}}{{else}}{{$.i18n.Tr "never"}}{{end}} {{if .LastError}}
{{$.i18n.Tr "error"}}
{{end}}