@@ -142,35 +142,39 @@ type remoteAddress struct {
142
142
Password string
143
143
}
144
144
145
- func mirrorRemoteAddress (ctx context.Context , m * repo_model.Repository , remoteName string , ignoreOriginalURL bool ) remoteAddress {
146
- a := remoteAddress {}
147
-
148
- remoteURL := m .OriginalURL
149
- if ignoreOriginalURL || remoteURL == "" {
150
- var err error
151
- remoteURL , err = git .GetRemoteAddress (ctx , m .RepoPath (), remoteName )
152
- if err != nil {
153
- log .Error ("GetRemoteURL %v" , err )
154
- return a
155
- }
145
+ func mirrorRemoteAddress (ctx context.Context , m * repo_model.Repository , remoteName string ) remoteAddress {
146
+ ret := remoteAddress {}
147
+ remoteURL , err := git .GetRemoteAddress (ctx , m .RepoPath (), remoteName )
148
+ if err != nil {
149
+ log .Error ("GetRemoteURL %v" , err )
150
+ return ret
156
151
}
157
152
158
153
u , err := giturl .Parse (remoteURL )
159
154
if err != nil {
160
155
log .Error ("giturl.Parse %v" , err )
161
- return a
156
+ return ret
162
157
}
163
158
164
159
if u .Scheme != "ssh" && u .Scheme != "file" {
165
160
if u .User != nil {
166
- a .Username = u .User .Username ()
167
- a .Password , _ = u .User .Password ()
161
+ ret .Username = u .User .Username ()
162
+ ret .Password , _ = u .User .Password ()
168
163
}
169
- u .User = nil
170
164
}
171
- a .Address = u .String ()
172
165
173
- return a
166
+ // The URL stored in the git repo could contain authentication,
167
+ // erase it, or it will be shown in the UI.
168
+ u .User = nil
169
+ ret .Address = u .String ()
170
+ // Why not use m.OriginalURL to set ret.Address?
171
+ // It should be OK to use it, since m.OriginalURL should be the same as the authentication-erased URL from the Git repository.
172
+ // However, the old code has already stored authentication in m.OriginalURL when updating mirror settings.
173
+ // That means we need to use "giturl.Parse" for m.OriginalURL again to ensure authentication is erased.
174
+ // Instead of doing this, why not directly use the authentication-erased URL from the Git repository?
175
+ // It should be the same as long as there are no bugs.
176
+
177
+ return ret
174
178
}
175
179
176
180
func FilenameIsImage (filename string ) bool {
0 commit comments