Skip to content

Commit

Permalink
fix staticcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 19, 2021
1 parent 94da8f4 commit 7d5d3ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions git.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ func parsePersonInfo(line []byte) (*PersonInfo, error) {

for {
if at == len(parts) {
return nil, fmt.Errorf("invalid personInfo: %s\n", line)
return nil, fmt.Errorf("invalid personInfo: %s", line)
}
part := parts[at]
if len(part) != 0 {
Expand All @@ -377,7 +377,7 @@ func parsePersonInfo(line []byte) (*PersonInfo, error) {
var email string
for {
if at == len(parts) {
return nil, fmt.Errorf("invalid personInfo: %s\n", line)
return nil, fmt.Errorf("invalid personInfo: %s", line)
}
part := parts[at]
if part[0] == '<' {
Expand Down
18 changes: 15 additions & 3 deletions git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ func testNode(t *testing.T, nd node.Node) error {
assert(t, lnk != nil || err.Error() == "index out of range")
assert(t, len(rest) == 0)

mt, rest, err := commit.Resolve([]string{"mergetag"})
mt, _, err := commit.Resolve([]string{"mergetag"})
assert(t, err == nil)
if len(mt.([]*MergeTag)) > 0 {
mtag, rest, err := commit.Resolve([]string{"mergetag", "0"})
mtag, _, err := commit.Resolve([]string{"mergetag", "0"})
assert(t, err == nil)
tag, ok := mtag.(*MergeTag)
if !ok {
t.Fatal("Invalid mergetag")
Expand Down Expand Up @@ -240,7 +242,8 @@ func testNode(t *testing.T, nd node.Node) error {
assert(t, obj != nil)
assert(t, rest != nil)
assert(t, len(rest) == 1)
assert(t, rest[0] == "aoeu")
//lint:ignore SA5011 see lines above
assert(t, rest[0] == "aoeu")
case "[git tree object]":
tree, ok := nd.(*Tree)
if !ok {
Expand Down Expand Up @@ -344,21 +347,30 @@ func TestParsePersonInfo(t *testing.T) {
assert(t, pi.String() == "Someone <[email protected]>")

pi, err = parsePersonInfo([]byte("prefix Łukasz Magiera <[email protected]> 1546187652 +0100"))
assert(t, err == nil)
piJSON, err := pi.MarshalJSON()
assert(t, err == nil)
date, _, err := pi.resolve([]string{"date"})
assert(t, err == nil)
assert(t, string(piJSON) == `{"date":"2018-12-30T17:34:12+01:00","email":"[email protected]","name":"Łukasz Magiera"}`)
assert(t, date == "2018-12-30T17:34:12+01:00")

pi, err = parsePersonInfo([]byte("prefix Sameer <[email protected]> 1545162499 -0500"))
assert(t, err == nil)
piJSON, err = pi.MarshalJSON()
assert(t, err == nil)
assert(t, string(piJSON) == `{"date":"2018-12-18T14:48:19-05:00","email":"[email protected]","name":"Sameer"}`)

pi, err = parsePersonInfo([]byte("prefix Łukasz Magiera <[email protected]> 1546187652 +0122"))
assert(t, err == nil)
piJSON, err = pi.MarshalJSON()
assert(t, err == nil)
assert(t, string(piJSON) == `{"date":"2018-12-30T17:56:12+01:22","email":"[email protected]","name":"Łukasz Magiera"}`)

pi, err = parsePersonInfo([]byte("prefix Sameer <[email protected]> 1545162499 -0545"))
assert(t, err == nil)
piJSON, err = pi.MarshalJSON()
assert(t, err == nil)
assert(t, string(piJSON) == `{"date":"2018-12-18T14:03:19-05:45","email":"[email protected]","name":"Sameer"}`)
}

Expand Down
2 changes: 1 addition & 1 deletion tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (t *Tree) Tree(p string, depth int) []string {
}

var out []string
for k, _ := range t.entries {
for k := range t.entries {
out = append(out, k, k+"/mode", k+"/type", k+"/hash")
}
return out
Expand Down

0 comments on commit 7d5d3ec

Please sign in to comment.