summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-04-21 10:43:29 +0800
committerGitHub <noreply@github.com>2017-04-21 10:43:29 +0800
commitf0db3da713eb9440923ddf376349e72b65f129ef (patch)
treefed96b5b8c2dbd95ec5ee3dd104a77b5ca78e42f
parent42072783c910b6f4119bb410f0e9dd55ebfc0927 (diff)
downloadgitea-f0db3da713eb9440923ddf376349e72b65f129ef.tar.gz
gitea-f0db3da713eb9440923ddf376349e72b65f129ef.zip
fix go get sub package and add domain on installation to let go get work defaultly (#1518)
* fix go get sub package and add domain on installation to let go get work defaultly * fix import sequence * fix .git problem
-rw-r--r--modules/context/repo.go2
-rw-r--r--routers/install.go1
-rw-r--r--routers/repo/http.go25
3 files changed, 27 insertions, 1 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index aae76185e2..4deae2ebba 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -127,7 +127,7 @@ func composeGoGetImport(owner, repo string) string {
func earlyResponseForGoGetMeta(ctx *Context) {
ctx.PlainText(200, []byte(com.Expand(`<meta name="go-import" content="{GoGetImport} git {CloneLink}">`,
map[string]string{
- "GoGetImport": composeGoGetImport(ctx.Params(":username"), ctx.Params(":reponame")),
+ "GoGetImport": composeGoGetImport(ctx.Params(":username"), strings.TrimSuffix(ctx.Params(":reponame"), ".git")),
"CloneLink": models.ComposeHTTPSCloneURL(ctx.Params(":username"), ctx.Params(":reponame")),
})))
}
diff --git a/routers/install.go b/routers/install.go
index b4df536d0c..1ab409d00d 100644
--- a/routers/install.go
+++ b/routers/install.go
@@ -257,6 +257,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
cfg.Section("repository").Key("ROOT").SetValue(form.RepoRootPath)
cfg.Section("").Key("RUN_USER").SetValue(form.RunUser)
cfg.Section("server").Key("SSH_DOMAIN").SetValue(form.Domain)
+ cfg.Section("server").Key("DOMAIN").SetValue(form.Domain)
cfg.Section("server").Key("HTTP_PORT").SetValue(form.HTTPPort)
cfg.Section("server").Key("ROOT_URL").SetValue(form.AppURL)
diff --git a/routers/repo/http.go b/routers/repo/http.go
index 12fcbcfb3f..9c2ec4d029 100644
--- a/routers/repo/http.go
+++ b/routers/repo/http.go
@@ -22,12 +22,37 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
+
+ "github.com/Unknwon/com"
)
+func composeGoGetImport(owner, repo, sub string) string {
+ return path.Join(setting.Domain, setting.AppSubURL, owner, repo, sub)
+}
+
+// earlyResponseForGoGetMeta responses appropriate go-get meta with status 200
+// if user does not have actual access to the requested repository,
+// or the owner or repository does not exist at all.
+// This is particular a workaround for "go get" command which does not respect
+// .netrc file.
+func earlyResponseForGoGetMeta(ctx *context.Context, username, reponame, subpath string) {
+ ctx.PlainText(200, []byte(com.Expand(`<meta name="go-import" content="{GoGetImport} git {CloneLink}">`,
+ map[string]string{
+ "GoGetImport": composeGoGetImport(username, reponame, subpath),
+ "CloneLink": models.ComposeHTTPSCloneURL(username, reponame),
+ })))
+}
+
// HTTP implmentation git smart HTTP protocol
func HTTP(ctx *context.Context) {
username := ctx.Params(":username")
reponame := strings.TrimSuffix(ctx.Params(":reponame"), ".git")
+ subpath := ctx.Params("*")
+
+ if ctx.Query("go-get") == "1" {
+ earlyResponseForGoGetMeta(ctx, username, reponame, subpath)
+ return
+ }
var isPull bool
service := ctx.Query("service")