diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-04-26 15:49:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-26 15:49:34 +0200 |
commit | e85778eecc8df3356a238396933c1303ab79124c (patch) | |
tree | 898fcce1fa5f6ddceaf102a408d8319bf4bdd1ae /plumbing | |
parent | df8b1cb8a8d4b3d53cbe64ae306d72bde29b56b0 (diff) | |
parent | bca4f9541ae0620ff203bde6da5e3126cfa16f04 (diff) | |
download | go-git-e85778eecc8df3356a238396933c1303ab79124c.tar.gz |
Merge pull request #360 from smola/go-vet
fix go vet issues, add go vet to CI
Diffstat (limited to 'plumbing')
-rw-r--r-- | plumbing/format/packfile/decoder.go | 4 | ||||
-rw-r--r-- | plumbing/format/packfile/scanner.go | 5 | ||||
-rw-r--r-- | plumbing/format/packfile/scanner_test.go | 5 | ||||
-rw-r--r-- | plumbing/format/pktline/scanner_test.go | 2 | ||||
-rw-r--r-- | plumbing/object/change_adaptor.go | 9 | ||||
-rw-r--r-- | plumbing/object/change_test.go | 5 |
6 files changed, 15 insertions, 15 deletions
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 |