From 7b6cd40fe778c8b99ed51cdab70874623379cb51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jun 2022 20:33:18 +0800 Subject: [PATCH 1/4] mod: bump github.com/stretchr/testify from 1.7.2 to 1.7.5 (#82) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index ddbc2b6d..e463f2ea 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,6 @@ go 1.13 require ( github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75 - github.com/stretchr/testify v1.7.2 + github.com/stretchr/testify v1.7.5 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e ) diff --git a/go.sum b/go.sum index ba4e65f8..6a98a8df 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,19 @@ -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75 h1:Pijfgr7ZuvX7QIQiEwLdRVr3RoMG+i0SbBO1Qu+7yVk= github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75/go.mod h1:76rfSfYPWj01Z85hUf/ituArm797mNKcvINh1OlsZKo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.5 h1:s5PTfem8p8EbKQOctVV53k6jCJt3UX4IEJzwh+C324Q= +github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From e7a612b4321e90e8c5d591f572194af853c39419 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Jul 2022 23:10:42 +0800 Subject: [PATCH 2/4] mod: bump github.com/stretchr/testify from 1.7.5 to 1.8.0 (#83) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e463f2ea..345890ac 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,6 @@ go 1.13 require ( github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75 - github.com/stretchr/testify v1.7.5 + github.com/stretchr/testify v1.8.0 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e ) diff --git a/go.sum b/go.sum index 6a98a8df..2941a4d2 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.5 h1:s5PTfem8p8EbKQOctVV53k6jCJt3UX4IEJzwh+C324Q= -github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 34a6ca3df4df0a0d40037c2512d0ff9f4db37d9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 Oct 2022 10:38:05 +0800 Subject: [PATCH 3/4] mod: bump github.com/stretchr/testify from 1.8.0 to 1.8.1 (#85) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Joe Chen --- .github/workflows/go.yml | 2 +- .golangci.yml | 5 +---- README.md | 2 +- diff_test.go | 20 ++++++++++---------- go.mod | 4 ++-- go.sum | 4 +++- signature.go | 6 ++++-- 7 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index cebbfaff..97b3887b 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -44,7 +44,7 @@ jobs: name: Test strategy: matrix: - go-version: [ 1.13.x, 1.14.x, 1.15.x, 1.16.x, 1.17.x, 1.18.x ] + go-version: [ 1.16.x, 1.17.x, 1.18.x, 1.19.x ] platform: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.platform }} steps: diff --git a/.golangci.yml b/.golangci.yml index 631e3692..479ac812 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,16 +9,13 @@ linters-settings: linters: enable: - - deadcode + - unused - errcheck - gosimple - govet - ineffassign - staticcheck - - structcheck - typecheck - - unused - - varcheck - nakedret - gofmt - rowserrcheck diff --git a/README.md b/README.md index d018ad53..35b1f416 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Package git-module is a Go module for Git access through shell commands. ## Requirements -- Go version must be at least **1.13**. +- Go version must be at least **1.16**. - Git version must be no less than **1.8.3**. - For Windows users, try to use the latest version of both. diff --git a/diff_test.go b/diff_test.go index eaa1ba93..db8a7b51 100644 --- a/diff_test.go +++ b/diff_test.go @@ -102,8 +102,8 @@ func TestDiffFile(t *testing.T) { LeftLine: 0, RightLine: 1, }, { - Type: DiffLineAdd, - Content: `+ path = gogs/docs-api`, + Type: DiffLineAdd, + Content: `+ path = gogs/docs-api`, LeftLine: 0, RightLine: 2, }, @@ -203,13 +203,13 @@ index 0000000..6b08f76 LeftLine: 0, RightLine: 1, }, { - Type: DiffLineAdd, - Content: `+ path = gogs/docs-api`, + Type: DiffLineAdd, + Content: `+ path = gogs/docs-api`, LeftLine: 0, RightLine: 2, }, { - Type: DiffLineAdd, - Content: `+ url = https://github.com/gogs/docs-api.git`, + Type: DiffLineAdd, + Content: `+ url = https://github.com/gogs/docs-api.git`, LeftLine: 0, RightLine: 3, }, @@ -719,8 +719,8 @@ index 0000000..6abde17 LeftLine: 0, RightLine: 1, }, { - Type: DiffLineAdd, - Content: `+ path = gogs/docs-api`, + Type: DiffLineAdd, + Content: `+ path = gogs/docs-api`, LeftLine: 0, RightLine: 2, }, @@ -783,8 +783,8 @@ index 0000000..6b08f76 LeftLine: 0, RightLine: 1, }, { - Type: DiffLineAdd, - Content: `+ path = gogs/docs-api`, + Type: DiffLineAdd, + Content: `+ path = gogs/docs-api`, LeftLine: 0, RightLine: 2, }, diff --git a/go.mod b/go.mod index 345890ac..6da0097b 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ module github.com/gogs/git-module -go 1.13 +go 1.16 require ( github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75 - github.com/stretchr/testify v1.8.0 + github.com/stretchr/testify v1.8.1 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e ) diff --git a/go.sum b/go.sum index 2941a4d2..f414adcb 100644 --- a/go.sum +++ b/go.sum @@ -7,9 +7,11 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/signature.go b/signature.go index 981a4919..a35f7bab 100644 --- a/signature.go +++ b/signature.go @@ -23,8 +23,10 @@ type Signature struct { // parseSignature parses signature information from the (uncompressed) commit // line, which looks like the following but without the "author " at the // beginning: -// author Patrick Gundlach 1378823654 +0200 -// author Patrick Gundlach Thu Apr 07 22:13:13 2005 +0200 +// +// author Patrick Gundlach 1378823654 +0200 +// author Patrick Gundlach Thu Apr 07 22:13:13 2005 +0200 +// // This method should only be used for parsing author and committer. func parseSignature(line []byte) (*Signature, error) { emailStart := bytes.IndexByte(line, '<') From 58d9f16a4fa0fbf13841d84e878cd53ca6dc6e3f Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Sun, 30 Oct 2022 22:44:58 -0400 Subject: [PATCH 4/4] fix: check for error before reading parent (#84) Co-authored-by: Joe Chen --- repo_diff.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/repo_diff.go b/repo_diff.go index 03d4f2bc..a7550b93 100644 --- a/repo_diff.go +++ b/repo_diff.go @@ -45,7 +45,10 @@ func (r *Repository) Diff(rev string, maxFiles, maxFileLines, maxLineChars int, AddOptions(opt.CommandOptions). AddArgs("--full-index", rev) } else { - c, _ := commit.Parent(0) + c, err := commit.Parent(0) + if err != nil { + return nil, err + } cmd = cmd.AddArgs("diff"). AddOptions(opt.CommandOptions). AddArgs("--full-index", "-M", c.ID.String(), rev) @@ -111,7 +114,10 @@ func (r *Repository) RawDiff(rev string, diffType RawDiffFormat, w io.Writer, op AddOptions(opt.CommandOptions). AddArgs("--full-index", rev) } else { - c, _ := commit.Parent(0) + c, err := commit.Parent(0) + if err != nil { + return err + } cmd = cmd.AddArgs("diff"). AddOptions(opt.CommandOptions). AddArgs("--full-index", "-M", c.ID.String(), rev) @@ -122,7 +128,10 @@ func (r *Repository) RawDiff(rev string, diffType RawDiffFormat, w io.Writer, op AddOptions(opt.CommandOptions). AddArgs("--full-index", "--no-signature", "--stdout", "--root", rev) } else { - c, _ := commit.Parent(0) + c, err := commit.Parent(0) + if err != nil { + return err + } cmd = cmd.AddArgs("format-patch"). AddOptions(opt.CommandOptions). AddArgs("--full-index", "--no-signature", "--stdout", rev+"..."+c.ID.String())