aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--plumbing/format/packfile/decoder.go4
-rw-r--r--plumbing/format/packfile/scanner.go5
-rw-r--r--plumbing/format/packfile/scanner_test.go5
-rw-r--r--plumbing/format/pktline/scanner_test.go2
-rw-r--r--plumbing/object/change_adaptor.go9
-rw-r--r--plumbing/object/change_test.go5
-rw-r--r--remote.go2
-rw-r--r--utils/merkletrie/difftree_test.go2
-rw-r--r--utils/merkletrie/internal/fsnoder/new.go2
-rw-r--r--utils/merkletrie/iter_test.go6
11 files changed, 22 insertions, 21 deletions
diff --git a/.travis.yml b/.travis.yml
index 0086733..c2e1da4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -45,6 +45,7 @@ script:
- export PATH=$GIT_DIST_PATH:$PATH
- git version
- make test-coverage
+ - go vet ./...
after_success:
- bash <(curl -s https://codecov.io/bash) \ No newline at end of file
diff --git a/plumbing/format/packfile/decoder.go b/plumbing/format/packfile/decoder.go
index f3328ef..21ddbbf 100644
--- a/plumbing/format/packfile/decoder.go
+++ b/plumbing/format/packfile/decoder.go
@@ -310,13 +310,13 @@ func (d *Decoder) DecodeObjectAt(offset int64) (plumbing.EncodedObject, error) {
return nil, ErrNonSeekable
}
- beforeJump, err := d.s.Seek(offset)
+ beforeJump, err := d.s.SeekFromStart(offset)
if err != nil {
return nil, err
}
defer func() {
- _, seekErr := d.s.Seek(beforeJump)
+ _, seekErr := d.s.SeekFromStart(beforeJump)
if err == nil {
err = seekErr
}
diff --git a/plumbing/format/packfile/scanner.go b/plumbing/format/packfile/scanner.go
index d8cece6..97512d1 100644
--- a/plumbing/format/packfile/scanner.go
+++ b/plumbing/format/packfile/scanner.go
@@ -300,8 +300,9 @@ func (s *Scanner) copyObject(w io.Writer) (int64, error) {
return io.Copy(w, s.zr)
}
-// Seek sets a new offset from start, returns the old position before the change
-func (s *Scanner) Seek(offset int64) (previous int64, err error) {
+// SeekFromStart sets a new offset from start, returns the old position before
+// the change.
+func (s *Scanner) SeekFromStart(offset int64) (previous int64, err error) {
// if seeking we assume that you are not interested on the header
if s.version == 0 {
s.version = VersionSupported
diff --git a/plumbing/format/packfile/scanner_test.go b/plumbing/format/packfile/scanner_test.go
index f2aa5fb..1ca8b6e 100644
--- a/plumbing/format/packfile/scanner_test.go
+++ b/plumbing/format/packfile/scanner_test.go
@@ -4,9 +4,10 @@ import (
"bytes"
"io"
- . "gopkg.in/check.v1"
- "github.com/src-d/go-git-fixtures"
"gopkg.in/src-d/go-git.v4/plumbing"
+
+ "github.com/src-d/go-git-fixtures"
+ . "gopkg.in/check.v1"
)
type ScannerSuite struct {
diff --git a/plumbing/format/pktline/scanner_test.go b/plumbing/format/pktline/scanner_test.go
index b8a78ec..048ea38 100644
--- a/plumbing/format/pktline/scanner_test.go
+++ b/plumbing/format/pktline/scanner_test.go
@@ -218,7 +218,7 @@ func ExampleScanner() {
for s.Scan() {
payload := s.Bytes()
if len(payload) == 0 { // zero sized payloads correspond to flush-pkts.
- fmt.Println("FLUSH-PKT DETECTED\n")
+ fmt.Println("FLUSH-PKT DETECTED")
} else { // otherwise, you will be able to access the full payload.
fmt.Printf("PAYLOAD = %q\n", string(payload))
}
diff --git a/plumbing/object/change_adaptor.go b/plumbing/object/change_adaptor.go
index cf8de6c..49b6545 100644
--- a/plumbing/object/change_adaptor.go
+++ b/plumbing/object/change_adaptor.go
@@ -1,6 +1,7 @@
package object
import (
+ "errors"
"fmt"
"gopkg.in/src-d/go-git.v4/utils/merkletrie"
@@ -15,11 +16,11 @@ func newChange(c merkletrie.Change) (*Change, error) {
var err error
if ret.From, err = newChangeEntry(c.From); err != nil {
- return nil, fmt.Errorf("From field: ", err)
+ return nil, fmt.Errorf("From field: %s", err)
}
if ret.To, err = newChangeEntry(c.To); err != nil {
- return nil, fmt.Errorf("To field: ", err)
+ return nil, fmt.Errorf("To field: %s", err)
}
return ret, nil
@@ -32,7 +33,7 @@ func newChangeEntry(p noder.Path) (ChangeEntry, error) {
asTreeNoder, ok := p.Last().(*treeNoder)
if !ok {
- return ChangeEntry{}, fmt.Errorf("cannot transform non-TreeNoders")
+ return ChangeEntry{}, errors.New("cannot transform non-TreeNoders")
}
return ChangeEntry{
@@ -52,7 +53,7 @@ func newChanges(src merkletrie.Changes) (Changes, error) {
for i, e := range src {
ret[i], err = newChange(e)
if err != nil {
- return nil, fmt.Errorf("change #%d: %s", err)
+ return nil, fmt.Errorf("change #%d: %s", i, err)
}
}
diff --git a/plumbing/object/change_test.go b/plumbing/object/change_test.go
index 005ceb0..bfd4613 100644
--- a/plumbing/object/change_test.go
+++ b/plumbing/object/change_test.go
@@ -236,10 +236,7 @@ func (s *ChangeSuite) TestNoFileFilemodes(c *C) {
c.Assert(err, IsNil)
for _, change := range changes {
_, _, err := change.Files()
- if err != nil {
- panic(err)
- c.Assert(err, IsNil)
- }
+ c.Assert(err, IsNil)
}
prev = commit
diff --git a/remote.go b/remote.go
index ca6b33e..ae8a544 100644
--- a/remote.go
+++ b/remote.go
@@ -41,7 +41,7 @@ func (r *Remote) String() string {
fetch := r.c.URL
push := r.c.URL
- return fmt.Sprintf("%s\t%s (fetch)\n%[1]s\t%s (push)", r.c.Name, fetch, push)
+ return fmt.Sprintf("%s\t%s (fetch)\n%[1]s\t%[3]s (push)", r.c.Name, fetch, push)
}
// Fetch fetches references from the remote to the local repository.
diff --git a/utils/merkletrie/difftree_test.go b/utils/merkletrie/difftree_test.go
index dd5b11d..9f033b1 100644
--- a/utils/merkletrie/difftree_test.go
+++ b/utils/merkletrie/difftree_test.go
@@ -120,7 +120,7 @@ func newChanges(original merkletrie.Changes) (changes, error) {
path: c.From.String(),
}
default:
- panic(fmt.Sprintf("unsupported action %d", c.Action))
+ panic(fmt.Sprintf("unsupported action %d", action))
}
}
diff --git a/utils/merkletrie/internal/fsnoder/new.go b/utils/merkletrie/internal/fsnoder/new.go
index 1e33020..ab749fd 100644
--- a/utils/merkletrie/internal/fsnoder/new.go
+++ b/utils/merkletrie/internal/fsnoder/new.go
@@ -34,7 +34,7 @@ func decodeDir(data []byte, isRoot bool) (*dir, error) {
var name string
switch end := bytes.IndexRune(data, dirStartMark); end {
case -1:
- return nil, fmt.Errorf("%c not found")
+ return nil, fmt.Errorf("%c not found", dirStartMark)
case 0:
if isRoot {
name = ""
diff --git a/utils/merkletrie/iter_test.go b/utils/merkletrie/iter_test.go
index ba28f0b..7e8c302 100644
--- a/utils/merkletrie/iter_test.go
+++ b/utils/merkletrie/iter_test.go
@@ -65,7 +65,7 @@ func (t test) run(c *C, iter *merkletrie.Iter,
var obtained noder.Path
var err error
- for i := range t.operations {
+ for i, b := range t.operations {
comment := Commentf("\ntree: %q\ntest #%d (%q)\noperation #%d (%q)",
treeDescription, testNumber, t.operations, i, t.operations[i])
@@ -81,8 +81,8 @@ func (t test) run(c *C, iter *merkletrie.Iter,
c.Assert(err, IsNil)
}
default:
- c.Fatalf("unknown operation at test %d, operation %d (%s)\n",
- testNumber, i, t.operations[i])
+ c.Fatalf("unknown operation at test %d, operation %d (%c)\n",
+ testNumber, i, b)
}
if i >= len(expectedChunks) {
c.Assert(err, Equals, io.EOF, comment)