Skip to content

Commit

Permalink
Merge pull request #51 from augmentable-dev/golangci-lint-action
Browse files Browse the repository at this point in the history
Add the golangci lint action
  • Loading branch information
patrickdevivo authored Jun 12, 2020
2 parents e107b33 + 742c6e4 commit b99e051
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 37 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
name: tests
on: [push, pull_request]
jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.12
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.13.1
go-version: 1.14.3
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Build
run: go build -v cmd/tickgit.go
- name: Vet
run: go vet -v ./...

- name: Test
run: go test -v ./...

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v1
with:
version: v1.26
3 changes: 2 additions & 1 deletion cmd/commands/todos.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ var todosCmd = &cobra.Command{
handleError(err, s)

} else {
todos.WriteTodos(foundToDos, os.Stdout)
err := todos.WriteTodos(foundToDos, os.Stdout)
handleError(err, s)
}

},
Expand Down
6 changes: 5 additions & 1 deletion pkg/comments/comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func SearchCommit(commit *object.Commit, cb func(*Comment)) error {
return err
}
defer fileIter.Close()
fileIter.ForEach(func(file *object.File) error {
err = fileIter.ForEach(func(file *object.File) error {
if file.Mode.IsFile() {
wg.Add(1)
go func() {
Expand All @@ -138,6 +138,10 @@ func SearchCommit(commit *object.Commit, cb func(*Comment)) error {
return nil
})

if err != nil {
return err
}

wg.Wait()
return nil
}
29 changes: 0 additions & 29 deletions pkg/todos/todos.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package todos

import (
"bufio"
"context"
"strings"

"github.com/augmentable-dev/tickgit/pkg/blame"
"github.com/augmentable-dev/tickgit/pkg/comments"
"github.com/dustin/go-humanize"
"gopkg.in/src-d/go-git.v4/plumbing/object"
)

// ToDo represents a ToDo item
Expand Down Expand Up @@ -100,33 +98,6 @@ func (t ToDos) CountWithCommits() (count int) {
return count
}

func (t *ToDo) existsInCommit(commit *object.Commit) (bool, error) {
f, err := commit.File(t.FilePath)
if err != nil {
if err == object.ErrFileNotFound {
return false, nil
}
return false, err
}
r, err := f.Reader()
if err != nil {
return false, err
}
defer r.Close()
s := bufio.NewScanner(r)
for s.Scan() {
line := s.Text()
if strings.Contains(line, t.Comment.String()) {
return true, nil
}
}
err = s.Err()
if err != nil {
return false, err
}
return false, nil
}

// FindBlame sets the blame information on each todo in a set of todos
func (t *ToDos) FindBlame(ctx context.Context, dir string) error {
fileMap := make(map[string]ToDos)
Expand Down

0 comments on commit b99e051

Please sign in to comment.