diff options
author | Joe Chen <jc@unknwon.io> | 2022-08-08 13:56:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-08 13:56:50 +0800 |
commit | a43b933c90ed7207e1d573bf118e3c37541835f8 (patch) | |
tree | c9db9bb6345628213cb481a943b2e4e0fdafb28f | |
parent | cfa5ddbde82f8aa892a5cc56fcc5aa7388e27ddc (diff) |
go: update required version to be 1.17 and add 1.19 to CI (#7129)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
-rw-r--r-- | .github/workflows/go.yml | 10 | ||||
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | go.mod | 86 | ||||
-rw-r--r-- | gogs.go | 4 | ||||
-rw-r--r-- | internal/db/actions.go | 2 | ||||
-rw-r--r-- | internal/db/repo.go | 17 | ||||
-rw-r--r-- | internal/httplib/httplib.go | 15 | ||||
-rw-r--r-- | internal/testutil/exec.go | 4 |
8 files changed, 99 insertions, 41 deletions
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 80264fdb..203e7113 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -55,7 +55,7 @@ jobs: name: Test strategy: matrix: - go-version: [ 1.16.x, 1.17.x, 1.18.x ] + go-version: [ 1.17.x, 1.18.x, 1.19.x ] platform: [ ubuntu-latest, macos-latest ] runs-on: ${{ matrix.platform }} steps: @@ -95,7 +95,7 @@ jobs: name: Test strategy: matrix: - go-version: [ 1.16.x, 1.17.x, 1.18.x ] + go-version: [ 1.17.x, 1.18.x, 1.19.x ] platform: [ windows-latest ] runs-on: ${{ matrix.platform }} steps: @@ -133,7 +133,7 @@ jobs: name: Postgres strategy: matrix: - go-version: [ 1.16.x, 1.17.x, 1.18.x ] + go-version: [ 1.17.x, 1.18.x, 1.19.x ] platform: [ ubuntu-latest ] runs-on: ${{ matrix.platform }} services: @@ -169,7 +169,7 @@ jobs: name: MySQL strategy: matrix: - go-version: [ 1.16.x, 1.17.x, 1.18.x ] + go-version: [ 1.17.x, 1.18.x, 1.19.x ] platform: [ ubuntu-18.04 ] runs-on: ${{ matrix.platform }} steps: @@ -194,7 +194,7 @@ jobs: name: SQLite - Go strategy: matrix: - go-version: [ 1.16.x, 1.17.x, 1.18.x ] + go-version: [ 1.17.x, 1.18.x, 1.19.x ] platform: [ ubuntu-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 18bd12dd..7520e3fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ All notable changes to Gogs are documented in this file. - 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 build tool. [#6297](https://github.com/gogs/gogs/pull/6297) -- The required Go version to compile source code changed to 1.16. +- The required Go version to compile source code changed to 1.17. - Access tokens are now stored using their SHA256 hashes instead of raw values. [#7008](https://github.com/gogs/gogs/pull/7008) ### Fixed @@ -1,13 +1,11 @@ module gogs.io/gogs -go 1.16 +go 1.17 require ( github.com/Masterminds/semver/v3 v3.1.1 - github.com/bgentry/speakeasy v0.1.0 // indirect github.com/derision-test/go-mockgen v1.3.3 github.com/editorconfig/editorconfig-core-go/v2 v2.4.5 - github.com/fatih/color v1.9.0 // indirect github.com/go-ldap/ldap/v3 v3.4.4 github.com/go-macaron/binding v1.2.0 github.com/go-macaron/cache v0.0.0-20190810181446-10f7c57e2196 @@ -24,15 +22,9 @@ require ( github.com/gogs/go-libravatar v0.0.0-20191106065024-33a75213d0a0 github.com/gogs/minwinsvc v0.0.0-20170301035411-95be6356811a github.com/google/go-github v17.0.0+incompatible - github.com/google/go-querystring v1.0.0 // indirect github.com/issue9/identicon v1.2.1 github.com/jaytaylor/html2text v0.0.0-20190408195923-01ec452cbe43 github.com/json-iterator/go v1.1.12 - github.com/klauspost/compress v1.8.6 // indirect - github.com/klauspost/cpuid v1.2.1 // indirect - github.com/mattn/go-isatty v0.0.13 // indirect - github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect - github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2 // indirect github.com/microcosm-cc/bluemonday v1.0.19 github.com/msteinert/pam v0.0.0-20190215180659-f29b9f28d6f9 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 @@ -42,10 +34,8 @@ require ( github.com/pquerna/otp v1.3.0 github.com/prometheus/client_golang v1.12.2 github.com/russross/blackfriday v1.6.0 - github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect github.com/satori/go.uuid v1.2.0 github.com/sergi/go-diff v1.2.0 - github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect github.com/stretchr/testify v1.8.0 github.com/unknwon/cae v1.0.2 github.com/unknwon/com v1.0.1 @@ -56,7 +46,6 @@ require ( golang.org/x/net v0.0.0-20220325170049-de3da57026de golang.org/x/text v0.3.7 gopkg.in/DATA-DOG/go-sqlmock.v2 v2.0.0-20180914054222-c19298f520d0 - gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df gopkg.in/ini.v1 v1.66.6 gopkg.in/macaron.v1 v1.4.0 @@ -72,5 +61,76 @@ require ( xorm.io/xorm v0.8.0 ) -// +heroku goVersion go1.16 +require ( + github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e // indirect + github.com/aymerick/douceur v0.2.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bgentry/speakeasy v0.1.0 // indirect + github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect + github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/denisenkom/go-mssqldb v0.12.0 // indirect + github.com/fatih/color v1.9.0 // indirect + github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect + github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191 // indirect + github.com/go-sql-driver/mysql v1.6.0 // indirect + github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect + github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-querystring v1.0.0 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/gorilla/css v1.0.0 // indirect + github.com/jackc/chunkreader/v2 v2.0.1 // indirect + github.com/jackc/pgconn v1.12.1 // indirect + github.com/jackc/pgio v1.0.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgproto3/v2 v2.3.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect + github.com/jackc/pgtype v1.11.0 // indirect + github.com/jackc/pgx/v4 v4.16.1 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect + github.com/klauspost/compress v1.8.6 // indirect + github.com/klauspost/cpuid v1.2.1 // indirect + github.com/mattn/go-colorable v0.1.6 // indirect + github.com/mattn/go-isatty v0.0.13 // indirect + github.com/mattn/go-runewidth v0.0.9 // indirect + github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/mcuadros/go-version v0.0.0-20190830083331-035f6764e8d2 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/procfs v0.7.3 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect + github.com/russross/blackfriday/v2 v2.0.1 // indirect + github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect + golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect + golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886 // indirect + golang.org/x/tools v0.1.10 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + google.golang.org/protobuf v1.26.0 // indirect + gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect + gopkg.in/bufio.v1 v1.0.0-20140618132640-567b2bfa514e // indirect + gopkg.in/redis.v2 v2.3.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/uint128 v1.1.1 // indirect + modernc.org/cc/v3 v3.36.0 // indirect + modernc.org/ccgo/v3 v3.16.6 // indirect + modernc.org/libc v1.16.7 // indirect + modernc.org/mathutil v1.4.1 // indirect + modernc.org/memory v1.1.1 // indirect + modernc.org/opt v0.1.1 // indirect + modernc.org/strutil v1.1.1 // indirect + modernc.org/token v1.0.0 // indirect +) + +// +heroku goVersion go1.17 // +heroku install ./ @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.17 +// +build go1.17 // Copyright 2014 The Gogs Authors. All rights reserved. // Use of this source code is governed by a MIT-style diff --git a/internal/db/actions.go b/internal/db/actions.go index b0a96b80..b7f0cca9 100644 --- a/internal/db/actions.go +++ b/internal/db/actions.go @@ -943,7 +943,7 @@ func (pcs *PushCommits) APIFormat(ctx context.Context, usersStore UsersStore, re // avatars, and falls back to general avatar link. // // FIXME: This method does not belong to PushCommits, should be a pure template -// function. +// function. func (pcs *PushCommits) AvatarLink(email string) string { _, ok := pcs.avatars[email] if !ok { diff --git a/internal/db/repo.go b/internal/db/repo.go index 71cd4601..94f50dfe 100644 --- a/internal/db/repo.go +++ b/internal/db/repo.go @@ -11,7 +11,6 @@ import ( "image" _ "image/jpeg" "image/png" - "io/ioutil" "os" "os/exec" "path" @@ -681,7 +680,7 @@ func (repo *Repository) SavePatch(index int64, patch []byte) error { if err = os.MkdirAll(filepath.Dir(patchPath), os.ModePerm); err != nil { return err } - if err = ioutil.WriteFile(patchPath, patch, 0644); err != nil { + if err = os.WriteFile(patchPath, patch, 0644); err != nil { return fmt.Errorf("WriteFile: %v", err) } @@ -736,8 +735,8 @@ type MigrateRepoOptions struct { } /* - GitHub, GitLab, Gogs: *.wiki.git - BitBucket: *.git/wiki +- GitHub, GitLab, Gogs: *.wiki.git +- BitBucket: *.git/wiki */ var commonWikiURLSuffixes = []string{".wiki.git", ".git/wiki"} @@ -871,7 +870,7 @@ var hooksTpls = map[git.HookName]string{ func createDelegateHooks(repoPath string) (err error) { for _, name := range git.ServerSideHooks { hookPath := filepath.Join(repoPath, "hooks", string(name)) - if err = ioutil.WriteFile(hookPath, + if err = os.WriteFile(hookPath, []byte(fmt.Sprintf(hooksTpls[name], conf.Repository.ScriptType, conf.AppPath(), conf.CustomConf)), os.ModePerm); err != nil { return fmt.Errorf("create delegate hook '%s': %v", hookPath, err) @@ -946,7 +945,7 @@ func getRepoInitFile(tp, name string) ([]byte, error) { // Use custom file when available. customPath := filepath.Join(conf.CustomDir(), "conf", relPath) if osutil.IsFile(customPath) { - return ioutil.ReadFile(customPath) + return os.ReadFile(customPath) } return embedConf.Files.ReadFile(relPath) } @@ -972,7 +971,7 @@ func prepareRepoCommit(repo *Repository, tmpDir, repoPath string, opts CreateRep "CloneURL.SSH": cloneLink.SSH, "CloneURL.HTTPS": cloneLink.HTTPS, } - if err = ioutil.WriteFile(filepath.Join(tmpDir, "README.md"), + if err = os.WriteFile(filepath.Join(tmpDir, "README.md"), []byte(com.Expand(string(data), match)), 0644); err != nil { return fmt.Errorf("write README.md: %v", err) } @@ -992,7 +991,7 @@ func prepareRepoCommit(repo *Repository, tmpDir, repoPath string, opts CreateRep } if buf.Len() > 0 { - if err = ioutil.WriteFile(filepath.Join(tmpDir, ".gitignore"), buf.Bytes(), 0644); err != nil { + if err = os.WriteFile(filepath.Join(tmpDir, ".gitignore"), buf.Bytes(), 0644); err != nil { return fmt.Errorf("write .gitignore: %v", err) } } @@ -1005,7 +1004,7 @@ func prepareRepoCommit(repo *Repository, tmpDir, repoPath string, opts CreateRep return fmt.Errorf("getRepoInitFile[%s]: %v", opts.License, err) } - if err = ioutil.WriteFile(filepath.Join(tmpDir, "LICENSE"), data, 0644); err != nil { + if err = os.WriteFile(filepath.Join(tmpDir, "LICENSE"), data, 0644); err != nil { return fmt.Errorf("write LICENSE: %v", err) } } diff --git a/internal/httplib/httplib.go b/internal/httplib/httplib.go index f1b35eb3..438b4a69 100644 --- a/internal/httplib/httplib.go +++ b/internal/httplib/httplib.go @@ -11,7 +11,6 @@ import ( "crypto/tls" "encoding/xml" "io" - "io/ioutil" "log" "mime/multipart" "net" @@ -199,9 +198,9 @@ func (r *Request) SetTransport(transport http.RoundTripper) *Request { // example: // // func(req *http.Request) (*url.URL, error) { -// u, _ := url.ParseRequestURI("http://127.0.0.1:8118") -// return u, nil -// } +// u, _ := url.ParseRequestURI("http://127.0.0.1:8118") +// return u, nil +// } func (r *Request) SetProxy(proxy func(*http.Request) (*url.URL, error)) *Request { r.setting.Proxy = proxy return r @@ -225,11 +224,11 @@ func (r *Request) Body(data interface{}) *Request { switch t := data.(type) { case string: bf := bytes.NewBufferString(t) - r.req.Body = ioutil.NopCloser(bf) + r.req.Body = io.NopCloser(bf) r.req.ContentLength = int64(len(t)) case []byte: bf := bytes.NewBuffer(t) - r.req.Body = ioutil.NopCloser(bf) + r.req.Body = io.NopCloser(bf) r.req.ContentLength = int64(len(t)) } return r @@ -286,7 +285,7 @@ func (r *Request) getResponse() (*http.Response, error) { _ = pw.Close() }() r.Header("Content-Type", bodyWriter.FormDataContentType()) - r.req.Body = ioutil.NopCloser(pr) + r.req.Body = io.NopCloser(pr) } else if len(paramBody) > 0 { r.Header("Content-Type", "application/x-www-form-urlencoded") r.Body(paramBody) @@ -384,7 +383,7 @@ func (r *Request) Bytes() ([]byte, error) { return nil, nil } defer resp.Body.Close() - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { return nil, err } diff --git a/internal/testutil/exec.go b/internal/testutil/exec.go index eee1677b..45f08315 100644 --- a/internal/testutil/exec.go +++ b/internal/testutil/exec.go @@ -16,8 +16,8 @@ import ( // It is useful to mock "os/exec" functions in tests. When succeeded, it returns // the result produced by the test helper. // The test helper should: -// 1. Use WantHelperProcess function to determine if it is being called in helper mode. -// 2. Call fmt.Fprintln(os.Stdout, ...) to print results for the main test to collect. +// 1. Use WantHelperProcess function to determine if it is being called in helper mode. +// 2. Call fmt.Fprintln(os.Stdout, ...) to print results for the main test to collect. func Exec(helper string, envs ...string) (string, error) { cmd := exec.Command(os.Args[0], "-test.run="+helper, "--") cmd.Env = []string{"GO_WANT_HELPER_PROCESS=1"} |