aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2017-01-31 18:40:38 -0500
committerUnknwon <u@gogs.io>2017-01-31 18:40:38 -0500
commitd293aa9ced0108b3342053c34ed9147de1c8f2af (patch)
tree5fb13ee3d4851703ae67c5fa58b4cb0fb66f0b90
parent0cfcaca351b78e3e2affd030d110662c537d6328 (diff)
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.
-rw-r--r--.gopmfile2
-rw-r--r--cmd/web.go2
-rw-r--r--glide.lock2
-rw-r--r--gogs.go2
-rw-r--r--models/repo.go4
-rw-r--r--models/repo_mirror.go22
-rw-r--r--templates/.VERSION2
7 files changed, 29 insertions, 7 deletions
diff --git a/.gopmfile b/.gopmfile
index 9ee21cb6..5da6e108 100644
--- a/.gopmfile
+++ b/.gopmfile
@@ -19,7 +19,7 @@ github.com/go-xorm/core = commit:2fbe2c7
github.com/go-xorm/xorm = commit:445a934
github.com/gogits/chardet = commit:2404f77
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-libravatar = commit:cd1abbd
github.com/issue9/identicon = commit:d36b545
diff --git a/cmd/web.go b/cmd/web.go
index 9979929c..49dbbf20 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -94,7 +94,7 @@ func checkVersion() {
{"github.com/go-macaron/toolbox", toolbox.Version, "0.1.0"},
{"gopkg.in/ini.v1", ini.Version, "1.8.4"},
{"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"},
}
for _, c := range checkers {
diff --git a/glide.lock b/glide.lock
index 58c49a4d..62047004 100644
--- a/glide.lock
+++ b/glide.lock
@@ -43,7 +43,7 @@ imports:
- name: github.com/gogits/cron
version: 2fc07a4c4f1e3c4d2301c5ed578d5e2c31c70421
- name: github.com/gogits/git-module
- version: df1013f8eb4dc70de90bc5597bf560a4b7da802e
+ version: 172cbc21accbf0085a58fd0832f46a9f694130e8
- name: github.com/gogits/go-gogs-client
version: 98046bb98061fc6baa5bb86359af0b7c300d384a
- name: github.com/gogits/go-libravatar
diff --git a/gogs.go b/gogs.go
index 18e95e32..831ced92 100644
--- a/gogs.go
+++ b/gogs.go
@@ -16,7 +16,7 @@ import (
"github.com/gogits/gogs/modules/setting"
)
-const APP_VER = "0.9.128.0131"
+const APP_VER = "0.9.129.0131"
func init() {
setting.AppVer = APP_VER
diff --git a/models/repo.go b/models/repo.go
index f9e52682..2e52cd1e 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -599,7 +599,9 @@ func wikiRemoteURL(remote string) string {
remote = strings.TrimSuffix(remote, ".git")
for _, suffix := range commonWikiURLSuffixes {
wikiURL := remote + suffix
- if git.IsRepoURLAccessible(wikiURL) {
+ if git.IsRepoURLAccessible(git.NetworkOptions{
+ URL: wikiURL,
+ }) {
return wikiURL
}
}
diff --git a/models/repo_mirror.go b/models/repo_mirror.go
index 1ab095ea..c20397c2 100644
--- a/models/repo_mirror.go
+++ b/models/repo_mirror.go
@@ -13,6 +13,8 @@ import (
"github.com/go-xorm/xorm"
"gopkg.in/ini.v1"
+ "github.com/gogits/git-module"
+
"github.com/gogits/gogs/modules/log"
"github.com/gogits/gogs/modules/process"
"github.com/gogits/gogs/modules/setting"
@@ -104,6 +106,12 @@ func (m *Mirror) Address() string {
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.
func (m *Mirror) FullAddress() string {
m.readAddress()
@@ -128,11 +136,23 @@ func (m *Mirror) runSync() bool {
wikiPath := m.Repo.WikiPath()
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"}
if m.EnablePrune {
gitArgs = append(gitArgs, "--prune")
}
-
if _, stderr, err := process.ExecDir(
timeout, repoPath, fmt.Sprintf("Mirror.runSync: %s", repoPath),
"git", gitArgs...); err != nil {
diff --git a/templates/.VERSION b/templates/.VERSION
index ceeaf43a..2381dcb4 100644
--- a/templates/.VERSION
+++ b/templates/.VERSION
@@ -1 +1 @@
-0.9.128.0131 \ No newline at end of file
+0.9.129.0131 \ No newline at end of file