aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2020-07-16 21:29:58 +0200
committerGitHub <noreply@github.com>2020-07-16 21:29:58 +0200
commit641ee1dd69d3b8616127623e4b9341f4f4196d12 (patch)
treec37ce033ec64f0378acc2cde8ae59a54cdd74667
parent7906922c319b6077e8e66b70711073fb59a08a20 (diff)
parent8b8e4561eec882fad6e93d8e4257a9dc21311f3e (diff)
downloadgo-git-641ee1dd69d3b8616127623e4b9341f4f4196d12.tar.gz
Merge pull request #125 from cristaloleg/minor-linter-fixes
*: minor linter fixes
-rw-r--r--internal/revision/parser.go6
-rw-r--r--plumbing/filemode/filemode.go2
-rw-r--r--plumbing/format/index/decoder.go2
-rw-r--r--plumbing/object/change.go2
-rw-r--r--plumbing/protocol/packp/capability/list.go5
-rw-r--r--remote.go9
-rw-r--r--repository.go12
-rw-r--r--repository_test.go2
-rw-r--r--storage/transactional/reference.go2
9 files changed, 18 insertions, 24 deletions
diff --git a/internal/revision/parser.go b/internal/revision/parser.go
index 3efe5d7..8facf17 100644
--- a/internal/revision/parser.go
+++ b/internal/revision/parser.go
@@ -297,7 +297,7 @@ func (p *Parser) parseAt() (Revisioner, error) {
}
if t != cbrace {
- return nil, &ErrInvalidRevision{fmt.Sprintf(`missing "}" in @{-n} structure`)}
+ return nil, &ErrInvalidRevision{s: `missing "}" in @{-n} structure`}
}
return AtCheckout{n}, nil
@@ -419,7 +419,7 @@ func (p *Parser) parseCaretBraces() (Revisioner, error) {
case re == "" && tok == emark && nextTok == minus:
negate = true
case re == "" && tok == emark:
- return nil, &ErrInvalidRevision{fmt.Sprintf(`revision suffix brace component sequences starting with "/!" others than those defined are reserved`)}
+ return nil, &ErrInvalidRevision{s: `revision suffix brace component sequences starting with "/!" others than those defined are reserved`}
case re == "" && tok == slash:
p.unscan()
case tok != slash && start:
@@ -490,7 +490,7 @@ func (p *Parser) parseColonSlash() (Revisioner, error) {
case re == "" && tok == emark && nextTok == minus:
negate = true
case re == "" && tok == emark:
- return nil, &ErrInvalidRevision{fmt.Sprintf(`revision suffix brace component sequences starting with "/!" others than those defined are reserved`)}
+ return nil, &ErrInvalidRevision{s: `revision suffix brace component sequences starting with "/!" others than those defined are reserved`}
case tok == eof:
p.unscan()
reg, err := regexp.Compile(re)
diff --git a/plumbing/filemode/filemode.go b/plumbing/filemode/filemode.go
index 594984f..b848a97 100644
--- a/plumbing/filemode/filemode.go
+++ b/plumbing/filemode/filemode.go
@@ -118,7 +118,7 @@ func isSetSymLink(m os.FileMode) bool {
func (m FileMode) Bytes() []byte {
ret := make([]byte, 4)
binary.LittleEndian.PutUint32(ret, uint32(m))
- return ret[:]
+ return ret
}
// IsMalformed returns if the FileMode should not appear in a git packfile,
diff --git a/plumbing/format/index/decoder.go b/plumbing/format/index/decoder.go
index d341d59..036b636 100644
--- a/plumbing/format/index/decoder.go
+++ b/plumbing/format/index/decoder.go
@@ -188,7 +188,7 @@ func (d *Decoder) doReadEntryNameV4() (string, error) {
func (d *Decoder) doReadEntryName(len uint16) (string, error) {
name := make([]byte, len)
- _, err := io.ReadFull(d.r, name[:])
+ _, err := io.ReadFull(d.r, name)
return string(name), err
}
diff --git a/plumbing/object/change.go b/plumbing/object/change.go
index c9d1615..8b119bc 100644
--- a/plumbing/object/change.go
+++ b/plumbing/object/change.go
@@ -75,7 +75,7 @@ func (c *Change) Files() (from, to *File, err error) {
func (c *Change) String() string {
action, err := c.Action()
if err != nil {
- return fmt.Sprintf("malformed change")
+ return "malformed change"
}
return fmt.Sprintf("<Action: %s, Path: %s>", action, c.name())
diff --git a/plumbing/protocol/packp/capability/list.go b/plumbing/protocol/packp/capability/list.go
index 9609211..f41ec79 100644
--- a/plumbing/protocol/packp/capability/list.go
+++ b/plumbing/protocol/packp/capability/list.go
@@ -86,10 +86,7 @@ func (l *List) Get(capability Capability) []string {
// Set sets a capability removing the previous values
func (l *List) Set(capability Capability, values ...string) error {
- if _, ok := l.m[capability]; ok {
- delete(l.m, capability)
- }
-
+ delete(l.m, capability)
return l.Add(capability, values...)
}
diff --git a/remote.go b/remote.go
index 2c5d806..39da24e 100644
--- a/remote.go
+++ b/remote.go
@@ -498,10 +498,8 @@ func (r *Remote) deleteReferences(rs config.RefSpec,
if _, ok := refsDict[rs.Dst(ref.Name()).String()]; ok {
return nil
}
- } else {
- if rs.Dst("") != ref.Name() {
- return nil
- }
+ } else if rs.Dst("") != ref.Name() {
+ return nil
}
cmd := &packp.Command{
@@ -1048,12 +1046,11 @@ func (r *Remote) List(o *ListOptions) (rfs []*plumbing.Reference, err error) {
}
func objectsToPush(commands []*packp.Command) []plumbing.Hash {
- var objects []plumbing.Hash
+ objects := make([]plumbing.Hash, 0, len(commands))
for _, cmd := range commands {
if cmd.New == plumbing.ZeroHash {
continue
}
-
objects = append(objects, cmd.New)
}
return objects
diff --git a/repository.go b/repository.go
index 66c0918..9dd35be 100644
--- a/repository.go
+++ b/repository.go
@@ -1440,9 +1440,9 @@ func (r *Repository) ResolveRevision(rev plumbing.Revision) (*plumbing.Hash, err
var commit *object.Commit
for _, item := range items {
- switch item.(type) {
+ switch item := item.(type) {
case revision.Ref:
- revisionRef := item.(revision.Ref)
+ revisionRef := item
var tryHashes []plumbing.Hash
@@ -1491,7 +1491,7 @@ func (r *Repository) ResolveRevision(rev plumbing.Revision) (*plumbing.Hash, err
}
case revision.CaretPath:
- depth := item.(revision.CaretPath).Depth
+ depth := item.Depth
if depth == 0 {
break
@@ -1519,7 +1519,7 @@ func (r *Repository) ResolveRevision(rev plumbing.Revision) (*plumbing.Hash, err
commit = c
case revision.TildePath:
- for i := 0; i < item.(revision.TildePath).Depth; i++ {
+ for i := 0; i < item.Depth; i++ {
c, err := commit.Parents().Next()
if err != nil {
@@ -1531,8 +1531,8 @@ func (r *Repository) ResolveRevision(rev plumbing.Revision) (*plumbing.Hash, err
case revision.CaretReg:
history := object.NewCommitPreorderIter(commit, nil, nil)
- re := item.(revision.CaretReg).Regexp
- negate := item.(revision.CaretReg).Negate
+ re := item.Regexp
+ negate := item.Negate
var c *object.Commit
diff --git a/repository_test.go b/repository_test.go
index 112561e..6a6ab9e 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -713,7 +713,7 @@ func (s *RepositorySuite) TestPlainCloneContextNonExistentWithNotEmptyDir(c *C)
c.Assert(err, IsNil)
dummyFile := filepath.Join(repoDirPath, "dummyFile")
- err = ioutil.WriteFile(dummyFile, []byte(fmt.Sprint("dummyContent")), 0644)
+ err = ioutil.WriteFile(dummyFile, []byte("dummyContent"), 0644)
c.Assert(err, IsNil)
r, err := PlainCloneContext(ctx, repoDirPath, false, &CloneOptions{
diff --git a/storage/transactional/reference.go b/storage/transactional/reference.go
index c3a727c..3b009e2 100644
--- a/storage/transactional/reference.go
+++ b/storage/transactional/reference.go
@@ -27,7 +27,7 @@ func NewReferenceStorage(base, temporal storer.ReferenceStorer) *ReferenceStorag
ReferenceStorer: base,
temporal: temporal,
- deleted: make(map[plumbing.ReferenceName]struct{}, 0),
+ deleted: make(map[plumbing.ReferenceName]struct{}),
}
}