From ebc8801fb2928053a58ad923859f7372afeb9a0e Mon Sep 17 00:00:00 2001 From: zeripath Date: Mon, 22 Aug 2022 07:14:48 +0100 Subject: [PATCH] Fix push mirror address backend get error Address cause setting page display error (#20593) (#20901) --- modules/templates/helper.go | 4 ++-- templates/repo/header.tmpl | 2 +- templates/repo/settings/options.tmpl | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) 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}}