Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the golangci lint action #51

Merged
merged 4 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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