Skip to content

Commit 7a8fdc2

Browse files
committed
improvements
1 parent 976df17 commit 7a8fdc2

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

routers/web/repo/setting/setting.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ func handleSettingsPostMirror(ctx *context.Context) {
265265
handleSettingRemoteAddrError(ctx, err, form)
266266
return
267267
}
268+
if u == nil {
269+
ctx.Data["Err_MirrorAddress"] = true
270+
handleSettingRemoteAddrError(ctx, err, form)
271+
return
272+
}
268273
if u.User != nil && form.MirrorPassword == "" && form.MirrorUsername == u.User.Username() {
269274
form.MirrorPassword, _ = u.User.Password()
270275
}

services/mirror/mirror_pull.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -408,28 +408,6 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
408408
stderrBuilder.Reset()
409409
stdoutBuilder.Reset()
410410

411-
// check whether the remote still exists before pruning to avoid prune creating a new remote
412-
// this is needed because prune will not fail if the remote does not exist
413-
u, err := gitrepo.GitRemoteGetURL(ctx, m.Repo.WikiStorageRepo(), m.GetRemoteName())
414-
if err != nil {
415-
log.Error("SyncMirrors [repo: %-v Wiki]: GetRemoteURL Error %v", m.Repo, err)
416-
return nil, false
417-
}
418-
if u == nil {
419-
log.Error("remote %s does not exist for repository %s", m.GetRemoteName(), m.Repo.WikiStorageRepo().RelativePath())
420-
return nil, false
421-
}
422-
423-
fetchConfig, err := gitrepo.GitConfigGet(ctx, m.Repo.WikiStorageRepo(), "remote.origin.fetch")
424-
if err != nil {
425-
log.Error("SyncMirrors [repo: %-v Wiki]: GetGitConfig Error %v", m.Repo, err)
426-
return nil, false
427-
}
428-
if fetchConfig == "" {
429-
log.Error("remote %s has no fetch config for repository %s", m.GetRemoteName(), m.Repo.WikiStorageRepo().RelativePath())
430-
return nil, false
431-
}
432-
433411
if err = gitrepo.GitRemoteUpdatePrune(ctx, m.Repo.WikiStorageRepo(), m.GetRemoteName(),
434412
timeout, &stdoutBuilder, &stderrBuilder); err != nil {
435413
stdout := stdoutBuilder.String()

0 commit comments

Comments
 (0)