|
67 | 67 |
|
68 | 68 | </div>
|
69 | 69 |
|
70 |
| - {{if .MirrorsEnabled}} |
| 70 | + |
| 71 | + {{/* These variables exist to make the logic in the Settings window easier to comprehend and are not used later on. */}} |
| 72 | + {{$newMirrorsPartiallyEnabled := or (not .DisableNewPullMirrors) (not .DisableNewPushMirrors)}} |
| 73 | + {{/* .Repository.IsMirror is not always reliable if the repository is not actively acting as a mirror because of errors. */}} |
| 74 | + {{$showMirrorSettings := or $newMirrorsPartiallyEnabled .Repository.IsMirror .PullMirror .PushMirrors}} |
| 75 | + {{$newMirrorsEntirelyEnabled := and (not .DisableNewPullMirrors) (not .DisableNewPushMirrors)}} |
| 76 | + {{$onlyNewPushMirrorsEnabled := and (not .DisableNewPushMirrors) .DisableNewPullMirrors}} |
| 77 | + {{$onlyNewPullMirrorsEnabled := and .DisableNewPushMirrors (not .DisableNewPullMirrors)}} |
| 78 | + {{$existingPushMirror := or .Repository.IsMirror .PushMirrors}} |
| 79 | + {{$modifyBrokenPullMirror := and .Repository.IsMirror (not .PullMirror)}} |
| 80 | + {{$isWorkingPullMirror := .PullMirror}} |
| 81 | + |
| 82 | + {{if $showMirrorSettings}} |
71 | 83 | <h4 class="ui top attached header">
|
72 | 84 | {{.locale.Tr "repo.settings.mirror_settings"}}
|
73 | 85 | </h4>
|
74 | 86 | <div class="ui attached segment">
|
75 |
| - {{$.locale.Tr "repo.settings.mirror_settings.docs" | Safe}} |
| 87 | + {{if $newMirrorsEntirelyEnabled}} |
| 88 | + {{$.locale.Tr "repo.settings.mirror_settings.docs"}} |
| 89 | + <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/usage/repo-mirror/#pushing-to<ing-to-a-remote-repository">{{$.locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br> |
| 90 | + {{$.locale.Tr "repo.settings.mirror_settings.docs.pull_mirror_instructions"}} |
| 91 | + <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/usage/repo-mirror/#pulling-from-a-remote-repository">{{$.locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br> |
| 92 | + {{else if $onlyNewPushMirrorsEnabled}} |
| 93 | + {{$.locale.Tr "repo.settings.mirror_settings.docs.disabled_pull_mirror.instructions"}} |
| 94 | + <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/usage/repo-mirror/#pulling-from-a-remote-repository">{{$.locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br> |
| 95 | + {{else if $onlyNewPullMirrorsEnabled}} |
| 96 | + {{$.locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.instructions"}} |
| 97 | + {{$.locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.pull_mirror_warning"}} |
| 98 | + <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/usage/repo-mirror/#pulling-from-a-remote-repository">{{$.locale.Tr "repo.settings.mirror_settings.docs.doc_link_title"}}</a><br><br> |
| 99 | + {{$.locale.Tr "repo.settings.mirror_settings.docs.disabled_push_mirror.info"}} |
| 100 | + {{if $existingPushMirror}} |
| 101 | + {{$.locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}} |
| 102 | + {{end}} |
| 103 | + {{else}} |
| 104 | + {{$.locale.Tr "repo.settings.mirror_settings.docs.no_new_mirrors"}} {{$.locale.Tr "repo.settings.mirror_settings.docs.can_still_use"}}<br> |
| 105 | + {{end}} |
76 | 106 | <table class="ui table">
|
77 |
| - {{if or .Repository.IsMirror .PushMirrors}} |
| 107 | + {{if $existingPushMirror}} |
78 | 108 | <thead>
|
79 | 109 | <tr>
|
80 | 110 | <th style="width:40%">{{$.locale.Tr "repo.settings.mirror_settings.mirrored_repository"}}</th>
|
|
84 | 114 | </tr>
|
85 | 115 | </thead>
|
86 | 116 | {{end}}
|
87 |
| - {{if and .Repository.IsMirror (not .PullMirror)}} |
| 117 | + {{if $modifyBrokenPullMirror}} |
88 | 118 | {{/* even if a repo is a pull mirror (IsMirror=true), the PullMirror might still be nil if the mirror migration is broken */}}
|
89 | 119 | <tbody>
|
90 | 120 | <tr>
|
|
93 | 123 | </td>
|
94 | 124 | </tr>
|
95 | 125 | </tbody>
|
96 |
| - {{else if .PullMirror}} |
| 126 | + {{else if $isWorkingPullMirror}} |
97 | 127 | <tbody>
|
98 | 128 | <tr>
|
99 | 129 | <td>{{(MirrorRemoteAddress $.Context .Repository .PullMirror.GetRemoteName false).Address}}</td>
|
|
0 commit comments