diff options
author | yisiliang <yisiliang@foxmail.com> | 2020-07-06 10:08:32 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-05 22:08:32 -0400 |
commit | 9fc9c1de98aff0329f358753ba5b2635dd522ac3 (patch) | |
tree | 7850d9aef1ed851d83fa3c1ba1f9dd4201dd3bd7 /services/mirror | |
parent | c5b08f6d5a73e6ba84da84e804d05a8dd3d651be (diff) | |
download | gitea-9fc9c1de98aff0329f358753ba5b2635dd522ac3.tar.gz gitea-9fc9c1de98aff0329f358753ba5b2635dd522ac3.zip |
Update the wiki repository remote origin while update the mirror repository's Clone From URL (#12053)
* update the wiki repository remote origin #12050
* wikiRemoteURL is under repo_module
* export WikiRemoteURL func
* remove redundant space and empty line
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'services/mirror')
-rw-r--r-- | services/mirror/mirror.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go index 165e7cd35b..7c12aa0858 100644 --- a/services/mirror/mirror.go +++ b/services/mirror/mirror.go @@ -100,7 +100,25 @@ func SaveAddress(m *models.Mirror, addr string) error { } _, err = git.NewCommand("remote", "add", "origin", "--mirror=fetch", addr).RunInDir(repoPath) - return err + if err != nil && !strings.HasPrefix(err.Error(), "exit status 128 - fatal: No such remote ") { + return err + } + + if m.Repo.HasWiki() { + wikiPath := m.Repo.WikiPath() + wikiRemotePath := repo_module.WikiRemoteURL(addr) + // Remove old origin of wiki + _, err := git.NewCommand("remote", "rm", "origin").RunInDir(wikiPath) + if err != nil && !strings.HasPrefix(err.Error(), "exit status 128 - fatal: No such remote ") { + return err + } + + _, err = git.NewCommand("remote", "add", "origin", "--mirror=fetch", wikiRemotePath).RunInDir(wikiPath) + if err != nil && !strings.HasPrefix(err.Error(), "exit status 128 - fatal: No such remote ") { + return err + } + } + return nil } // gitShortEmptySha Git short empty SHA |