From e6fc58a74461bd67efb06fc2e5658265ede2edb5 Mon Sep 17 00:00:00 2001 From: Peter Smit Date: Tue, 17 Feb 2015 10:36:17 +0200 Subject: [PATCH] Remove GoGet option from repository and handle it with ?go-get=1 instead The normal go get protocol is to show the go-import meta tag when ?go-get=1 is appended to the url. This commit implements that behaviour and cleans the go-get option from the repository settings page. --- conf/locale/locale_en-US.ini | 2 -- models/repo.go | 1 - modules/auth/repo_form.go | 1 - modules/middleware/repo.go | 3 +-- routers/repo/setting.go | 3 +-- templates/base/head.tmpl | 2 +- templates/ng/base/head.tmpl | 2 +- templates/repo/settings/options.tmpl | 5 ----- 8 files changed, 4 insertions(+), 15 deletions(-) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 6b59be7391..54b80abb5e 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -281,8 +281,6 @@ init_readme = Initialize this repository with a README.md create_repo = Create Repository default_branch = Default Branch mirror_interval = Mirror Interval (hour) -goget_meta = Go-Get Meta -goget_meta_helper = This repository will be Go-Getable need_auth = Need Authorization migrate_type = Migration Type diff --git a/models/repo.go b/models/repo.go index cdb838a1fb..179120a311 100644 --- a/models/repo.go +++ b/models/repo.go @@ -154,7 +154,6 @@ type Repository struct { IsPrivate bool IsBare bool - IsGoget bool IsMirror bool *Mirror `xorm:"-"` diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index 36e62f04fb..c771dd59b8 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -52,7 +52,6 @@ type RepoSettingForm struct { Branch string `form:"branch"` Interval int `form:"interval"` Private bool `form:"private"` - GoGet bool `form:"goget"` } func (f *RepoSettingForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 1ab158dd6d..67a9eda691 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -394,8 +394,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler { } ctx.Data["CloneLink"] = ctx.Repo.CloneLink - if ctx.Repo.Repository.IsGoget { - ctx.Data["GoGetLink"] = fmt.Sprintf("%s%s/%s", setting.AppUrl, u.LowerName, repo.LowerName) + if ctx.Query("go-get") == "1" { ctx.Data["GoGetImport"] = fmt.Sprintf("%s/%s/%s", setting.Domain, u.LowerName, repo.LowerName) } diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 33bf1eab28..8368513ad8 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -8,9 +8,9 @@ import ( "encoding/json" "errors" "fmt" + "path" "strings" "time" - "path" "github.com/Unknwon/com" @@ -84,7 +84,6 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) { ctx.Repo.Repository.Description = form.Description ctx.Repo.Repository.Website = form.Website ctx.Repo.Repository.IsPrivate = form.Private - ctx.Repo.Repository.IsGoget = form.GoGet if err := models.UpdateRepository(ctx.Repo.Repository); err != nil { ctx.Handle(404, "UpdateRepository", err) return diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 7775933ca9..cb3951ea2c 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -9,7 +9,7 @@ - {{if .Repository.IsGoget}}{{end}} + {{if .GoGetImport}}{{end}} {{if CdnMode}} diff --git a/templates/ng/base/head.tmpl b/templates/ng/base/head.tmpl index 40a7d28ff2..f2a235bd43 100644 --- a/templates/ng/base/head.tmpl +++ b/templates/ng/base/head.tmpl @@ -7,7 +7,7 @@ - {{if .Repository.IsGoget}}{{end}} + {{if .GoGetImport}}{{end}} diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index 093e937553..41683f8450 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -59,11 +59,6 @@ {{.i18n.Tr "repo.visiblity_helper" | Str2html}} -
- - - {{.i18n.Tr "repo.goget_meta_helper" | Str2html}} -