diff --git a/CHANGELOG.md b/CHANGELOG.md index 52db6962a..7be3c6904 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,54 @@ All notable changes to Gogs are documented in this file. -## 0.13.0+dev (`master`) +## 0.13.0+dev (`main`) + +### Added + +- An unlisted option is added when create or migrate a repository. Unlisted repositories are public but not being listed for users without direct access in the UI. [#5733](https://github.com/gogs/gogs/issues/5733) + +### Changed + +- The default branch has been changed to `main`. [#6285](https://github.com/gogs/gogs/pull/6285) +- MSSQL as database backend is deprecated, installation page no longer shows it as an option. Existing installations and manually craft configuration file continue to work. [#6295](https://github.com/gogs/gogs/pull/6295) +- Use [Task](https://github.com/go-task/task) as the default build tool for development. [#6297](https://github.com/gogs/gogs/pull/6297) + +### Fixed + +- _Regression:_ Pages are correctly rendered when requesting `?go-get=1` for subdirectories. [#6314](https://github.com/gogs/gogs/issues/6314) + +### Removed + +- ⚠️ Migrations before 0.12 are removed, installations not on 0.12 should upgrade to it to run the migrations and then upgrade to 0.13. +- Configuration section `[mailer]` is no longer used. +- Configuration section `[service]` is no longer used. +- Configuration option `APP_NAME` is no longer used. +- Configuration option `[security] REVERSE_PROXY_AUTHENTICATION_USER` is no longer used. +- Configuration option `[database] PASSWD` is no longer used. +- Configuration option `[auth] ACTIVE_CODE_LIVE_MINUTES` is no longer used. +- Configuration option `[auth] RESET_PASSWD_CODE_LIVE_MINUTES` is no longer used. +- Configuration option `[auth] ENABLE_CAPTCHA` is no longer used. +- Configuration option `[auth] ENABLE_NOTIFY_MAIL` is no longer used. +- Configuration option `[auth] REGISTER_EMAIL_CONFIRM` is no longer used. +- Configuration option `[session] GC_INTERVAL_TIME` is no longer used. +- Configuration option `[session] SESSION_LIFE_TIME` is no longer used. +- Configuration option `[server] ROOT_URL` is no longer used. +- Configuration option `[server] LANDING_PAGE` is no longer used. +- Configuration option `[database] DB_TYPE` is no longer used. +- Configuration option `[database] PASSWD` is no longer used. + +## 0.12.1 + +### Fixed + +- The `updated_at` field is now correctly updated when updates an issue. [#6209](https://github.com/gogs/gogs/issues/6209) +- Fixed a regression which created `login_source.cfg` column to have `VARCHAR(255)` instead of `TEXT` in MySQL. [#6280](https://github.com/gogs/gogs/issues/6280) ## 0.12.0 ### Added -- Support for Git LFS, you can read documentation for both [user](https://github.com/gogs/gogs/blob/master/docs/user/lfs.md) and [admin](https://github.com/gogs/gogs/blob/master/docs/admin/lfs.md). [#1322](https://github.com/gogs/gogs/issues/1322) +- Support for Git LFS, you can read documentation for both [user](https://github.com/gogs/gogs/blob/main/docs/user/lfs.md) and [admin](https://github.com/gogs/gogs/blob/main/docs/admin/lfs.md). [#1322](https://github.com/gogs/gogs/issues/1322) - Allow admin to remove observers from the repository. [#5803](https://github.com/gogs/gogs/pull/5803) - Use `Last-Modified` HTTP header for raw files. [#5811](https://github.com/gogs/gogs/issues/5811) - Support syntax highlighting for SAS code files (i.e. `.r`, `.sas`, `.tex`, `.yaml`). [#5856](https://github.com/gogs/gogs/pull/5856) diff --git a/internal/cmd/web.go b/internal/cmd/web.go index 43b9dfc53..09c173f40 100644 --- a/internal/cmd/web.go +++ b/internal/cmd/web.go @@ -611,7 +611,7 @@ func runWeb(c *cli.Context) error { m.Get("/compare/:before([a-z0-9]{40})\\.\\.\\.:after([a-z0-9]{40})", repo.MustBeNotBare, context.RepoRef(), repo.CompareDiff) }, ignSignIn, context.RepoAssignment()) m.Group("/:username/:reponame", func() { - m.Get("", repo.Home) + m.Get("", context.ServeGoGet(), repo.Home) m.Get("/stars", repo.Stars) m.Get("/watchers", repo.Watchers) }, ignSignIn, context.RepoAssignment(), context.RepoRef()) @@ -659,7 +659,7 @@ func runWeb(c *cli.Context) error { lfs.RegisterRoutes(m.Router) }) - m.Route("/*", "GET,POST,OPTIONS", repo.HTTPContexter(), repo.HTTP) + m.Route("/*", "GET,POST,OPTIONS", context.ServeGoGet(), repo.HTTPContexter(), repo.HTTP) }) // *************************** diff --git a/internal/context/context.go b/internal/context/context.go index d05767ba4..2971700b4 100644 --- a/internal/context/context.go +++ b/internal/context/context.go @@ -8,7 +8,6 @@ import ( "fmt" "io" "net/http" - "path" "strings" "time" @@ -16,7 +15,6 @@ import ( "github.com/go-macaron/csrf" "github.com/go-macaron/i18n" "github.com/go-macaron/session" - "github.com/unknwon/com" "gopkg.in/macaron.v1" log "unknwon.dev/clog/v2" @@ -249,52 +247,6 @@ func Contexter() macaron.Handler { c.Data["Link"] = template.EscapePound(c.Link) c.Data["PageStartTime"] = time.Now() - // Quick responses appropriate go-get meta with status 200 - // regardless of if user have access to the repository, - // or the repository does not exist at all. - // This is particular a workaround for "go get" command which does not respect - // .netrc file. - if c.Query("go-get") == "1" { - ownerName := c.Params(":username") - repoName := c.Params(":reponame") - branchName := "master" - - owner, err := db.GetUserByName(ownerName) - if err != nil { - c.NotFoundOrError(err, "get user by name") - return - } - - repo, err := db.GetRepositoryByName(owner.ID, repoName) - if err == nil && len(repo.DefaultBranch) > 0 { - branchName = repo.DefaultBranch - } - - prefix := conf.Server.ExternalURL + path.Join(ownerName, repoName, "src", branchName) - insecureFlag := "" - if !strings.HasPrefix(conf.Server.ExternalURL, "https://") { - insecureFlag = "--insecure " - } - c.PlainText(http.StatusOK, com.Expand(` - -
- - - - - go get {InsecureFlag}{GoGetImport} - - -`, map[string]string{ - "GoGetImport": path.Join(conf.Server.URL.Host, conf.Server.Subpath, ownerName, repoName), - "CloneLink": db.ComposeHTTPSCloneURL(ownerName, repoName), - "GoDocDirectory": prefix + "{/dir}", - "GoDocFile": prefix + "{/dir}/{file}#L{line}", - "InsecureFlag": insecureFlag, - })) - return - } - if len(conf.HTTP.AccessControlAllowOrigin) > 0 { c.Header().Set("Access-Control-Allow-Origin", conf.HTTP.AccessControlAllowOrigin) c.Header().Set("'Access-Control-Allow-Credentials' ", "true") diff --git a/internal/context/go_get.go b/internal/context/go_get.go new file mode 100644 index 000000000..2851b5db0 --- /dev/null +++ b/internal/context/go_get.go @@ -0,0 +1,62 @@ +package context + +import ( + "net/http" + "path" + "strings" + + "github.com/unknwon/com" + "gopkg.in/macaron.v1" + + "gogs.io/gogs/internal/conf" + "gogs.io/gogs/internal/db" +) + +// ServeGoGet does quick responses for appropriate go-get meta with status OK +// regardless of whether the user has access to the repository, or the repository +// does exist at all. This is particular a workaround for "go get" command which +// does not respect .netrc file. +func ServeGoGet() macaron.Handler { + return func(c *macaron.Context) { + if c.Query("go-get") != "1" { + return + } + + ownerName := c.Params(":username") + repoName := c.Params(":reponame") + branchName := "master" + + owner, err := db.Users.GetByUsername(ownerName) + if err == nil { + repo, err := db.Repos.GetByName(owner.ID, repoName) + if err == nil && repo.DefaultBranch != "" { + branchName = repo.DefaultBranch + } + } + + prefix := conf.Server.ExternalURL + path.Join(ownerName, repoName, "src", branchName) + insecureFlag := "" + if !strings.HasPrefix(conf.Server.ExternalURL, "https://") { + insecureFlag = "--insecure " + } + c.PlainText(http.StatusOK, []byte(com.Expand(` + + + + + + + go get {InsecureFlag}{GoGetImport} + + +`, + map[string]string{ + "GoGetImport": path.Join(conf.Server.URL.Host, conf.Server.Subpath, ownerName, repoName), + "CloneLink": db.ComposeHTTPSCloneURL(ownerName, repoName), + "GoDocDirectory": prefix + "{/dir}", + "GoDocFile": prefix + "{/dir}/{file}#L{line}", + "InsecureFlag": insecureFlag, + }, + ))) + } +}