mirror of https://github.com/gogs/gogs.git
Do a fast-fail testing on repository URL before mirroring
To ensure the URL is accessible under good condition to prevent long blocking on URL resolution without syncing anything.pull/2342/merge
parent
0cfcaca351
commit
d293aa9ced
|
@ -19,7 +19,7 @@ github.com/go-xorm/core = commit:2fbe2c7
|
||||||
github.com/go-xorm/xorm = commit:445a934
|
github.com/go-xorm/xorm = commit:445a934
|
||||||
github.com/gogits/chardet = commit:2404f77
|
github.com/gogits/chardet = commit:2404f77
|
||||||
github.com/gogits/cron = commit:2fc07a4
|
github.com/gogits/cron = commit:2fc07a4
|
||||||
github.com/gogits/git-module = commit:df1013f
|
github.com/gogits/git-module = commit:172cbc2
|
||||||
github.com/gogits/go-gogs-client = commit:98046bb
|
github.com/gogits/go-gogs-client = commit:98046bb
|
||||||
github.com/gogits/go-libravatar = commit:cd1abbd
|
github.com/gogits/go-libravatar = commit:cd1abbd
|
||||||
github.com/issue9/identicon = commit:d36b545
|
github.com/issue9/identicon = commit:d36b545
|
||||||
|
|
|
@ -94,7 +94,7 @@ func checkVersion() {
|
||||||
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
|
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
|
||||||
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
|
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
|
||||||
{"gopkg.in/macaron.v1", macaron.Version, "1.1.7"},
|
{"gopkg.in/macaron.v1", macaron.Version, "1.1.7"},
|
||||||
{"github.com/gogits/git-module", git.Version, "0.4.5"},
|
{"github.com/gogits/git-module", git.Version, "0.4.6"},
|
||||||
{"github.com/gogits/go-gogs-client", gogs.Version, "0.12.1"},
|
{"github.com/gogits/go-gogs-client", gogs.Version, "0.12.1"},
|
||||||
}
|
}
|
||||||
for _, c := range checkers {
|
for _, c := range checkers {
|
||||||
|
|
|
@ -43,7 +43,7 @@ imports:
|
||||||
- name: github.com/gogits/cron
|
- name: github.com/gogits/cron
|
||||||
version: 2fc07a4c4f1e3c4d2301c5ed578d5e2c31c70421
|
version: 2fc07a4c4f1e3c4d2301c5ed578d5e2c31c70421
|
||||||
- name: github.com/gogits/git-module
|
- name: github.com/gogits/git-module
|
||||||
version: df1013f8eb4dc70de90bc5597bf560a4b7da802e
|
version: 172cbc21accbf0085a58fd0832f46a9f694130e8
|
||||||
- name: github.com/gogits/go-gogs-client
|
- name: github.com/gogits/go-gogs-client
|
||||||
version: 98046bb98061fc6baa5bb86359af0b7c300d384a
|
version: 98046bb98061fc6baa5bb86359af0b7c300d384a
|
||||||
- name: github.com/gogits/go-libravatar
|
- name: github.com/gogits/go-libravatar
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.9.128.0131"
|
const APP_VER = "0.9.129.0131"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setting.AppVer = APP_VER
|
setting.AppVer = APP_VER
|
||||||
|
|
|
@ -599,7 +599,9 @@ func wikiRemoteURL(remote string) string {
|
||||||
remote = strings.TrimSuffix(remote, ".git")
|
remote = strings.TrimSuffix(remote, ".git")
|
||||||
for _, suffix := range commonWikiURLSuffixes {
|
for _, suffix := range commonWikiURLSuffixes {
|
||||||
wikiURL := remote + suffix
|
wikiURL := remote + suffix
|
||||||
if git.IsRepoURLAccessible(wikiURL) {
|
if git.IsRepoURLAccessible(git.NetworkOptions{
|
||||||
|
URL: wikiURL,
|
||||||
|
}) {
|
||||||
return wikiURL
|
return wikiURL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ import (
|
||||||
"github.com/go-xorm/xorm"
|
"github.com/go-xorm/xorm"
|
||||||
"gopkg.in/ini.v1"
|
"gopkg.in/ini.v1"
|
||||||
|
|
||||||
|
"github.com/gogits/git-module"
|
||||||
|
|
||||||
"github.com/gogits/gogs/modules/log"
|
"github.com/gogits/gogs/modules/log"
|
||||||
"github.com/gogits/gogs/modules/process"
|
"github.com/gogits/gogs/modules/process"
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
|
@ -104,6 +106,12 @@ func (m *Mirror) Address() string {
|
||||||
return HandleCloneUserCredentials(m.address, false)
|
return HandleCloneUserCredentials(m.address, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MosaicsAddress returns mirror address from Git repository config with credentials under mosaics.
|
||||||
|
func (m *Mirror) MosaicsAddress() string {
|
||||||
|
m.readAddress()
|
||||||
|
return HandleCloneUserCredentials(m.address, true)
|
||||||
|
}
|
||||||
|
|
||||||
// FullAddress returns mirror address from Git repository config.
|
// FullAddress returns mirror address from Git repository config.
|
||||||
func (m *Mirror) FullAddress() string {
|
func (m *Mirror) FullAddress() string {
|
||||||
m.readAddress()
|
m.readAddress()
|
||||||
|
@ -128,11 +136,23 @@ func (m *Mirror) runSync() bool {
|
||||||
wikiPath := m.Repo.WikiPath()
|
wikiPath := m.Repo.WikiPath()
|
||||||
timeout := time.Duration(setting.Git.Timeout.Mirror) * time.Second
|
timeout := time.Duration(setting.Git.Timeout.Mirror) * time.Second
|
||||||
|
|
||||||
|
// Do a fast-fail testing against on repository URL to ensure it is accessible under
|
||||||
|
// good condition to prevent long blocking on URL resolution without syncing anything.
|
||||||
|
if !git.IsRepoURLAccessible(git.NetworkOptions{
|
||||||
|
URL: m.FullAddress(),
|
||||||
|
Timeout: 10 * time.Second,
|
||||||
|
}) {
|
||||||
|
desc := fmt.Sprintf("Mirror repository URL is not accessible: %s", m.MosaicsAddress())
|
||||||
|
if err := CreateRepositoryNotice(desc); err != nil {
|
||||||
|
log.Error(4, "CreateRepositoryNotice: %v", err)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
gitArgs := []string{"remote", "update"}
|
gitArgs := []string{"remote", "update"}
|
||||||
if m.EnablePrune {
|
if m.EnablePrune {
|
||||||
gitArgs = append(gitArgs, "--prune")
|
gitArgs = append(gitArgs, "--prune")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, stderr, err := process.ExecDir(
|
if _, stderr, err := process.ExecDir(
|
||||||
timeout, repoPath, fmt.Sprintf("Mirror.runSync: %s", repoPath),
|
timeout, repoPath, fmt.Sprintf("Mirror.runSync: %s", repoPath),
|
||||||
"git", gitArgs...); err != nil {
|
"git", gitArgs...); err != nil {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.9.128.0131
|
0.9.129.0131
|
Loading…
Reference in New Issue