Skip to content

Commit

Permalink
feat: skip running cob (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
knqyf263 authored Apr 19, 2020
1 parent f2a3428 commit 582a053
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,17 @@ Comparison

</details>

## Skip running cob
If your commit message contains `[skip cob]`, cob is skipped.

```
$ git add README.md
$ git commit -m "[skip cob] update README.md"
$ cob
2020/04/19 12:46:57 [skip cob] is detected, so the benchmark is skipped
```


# Usage

```
Expand Down
15 changes: 12 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import (
"os/exec"
"strings"

"gopkg.in/src-d/go-git.v4/plumbing"

"golang.org/x/xerrors"
git "gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"

"github.com/olekukonko/tablewriter"
"github.com/urfave/cli/v2"
"golang.org/x/tools/benchmark/parse"
"gopkg.in/src-d/go-git.v4"
)

type result struct {
Expand Down Expand Up @@ -87,6 +86,16 @@ func run(c config) error {
return xerrors.Errorf("unable to get the reference where HEAD is pointing to: %w", err)
}

commit, err := r.CommitObject(head.Hash())
if err != nil {
return xerrors.Errorf("unable to get the head commit: %w", err)
}

if strings.Contains(strings.ToLower(commit.Message), "[skip cob]") {
log.Println("[skip cob] is detected, so the benchmark is skipped")
return nil
}

prev, err := r.ResolveRevision(plumbing.Revision(c.base))
if err != nil {
return xerrors.Errorf("unable to resolves revision to corresponding hash: %w", err)
Expand Down

0 comments on commit 582a053

Please sign in to comment.