Skip to content
Open
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
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,22 @@ NAME:
cob - Continuous Benchmark for Go project

USAGE:
cob [global options] command [command options] [arguments...]
cob [global options] command [command options]

COMMANDS:
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
--only-degression Show only benchmarks with worse score (default: false)
--threshold value The program fails if the benchmark gets worse than the threshold (default: 0.2)
--base value Specify a base commit compared with HEAD (default: "HEAD~1")
--compare value Which score to compare (default: "ns/op,B/op")
--bench-cmd value Specify a command to measure benchmarks (default: "go")
--bench-args value Specify arguments passed to -cmd (default: "test -run '^$' -bench . -benchmem ./...")
--help, -h show help (default: false)
--only-degression Show only benchmarks with worse score (default: false)
--fail-without-results Exit with an error if the parsing fails (default: false)
--overwrite-changes Overwrite uncommitted changes in the git repository (default: false)
--threshold value The program fails if the benchmark gets worse than the threshold (default: 0.2)
--base value Specify a base commit compared with HEAD (default: "HEAD~1")
--compare value Which score to compare (default: "ns/op,B/op")
--bench-cmd value Specify a command to measure benchmarks (default: "go")
--bench-args value Specify arguments passed to -cmd (default: "test -run '^$' -bench . -benchmem ./...")
--git-path value Specify the path of the git repo (default: ".")
--help, -h show help
```

# Q&A
Expand Down
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
type config struct {
onlyDegression bool
failWithoutResults bool
overwriteChanges bool
threshold float64
base string
compare []string
Expand All @@ -21,6 +22,7 @@ func newConfig(c *cli.Context) config {
return config{
onlyDegression: c.Bool("only-degression"),
failWithoutResults: c.Bool("fail-without-results"),
overwriteChanges: c.Bool("overwrite-changes"),
threshold: c.Float64("threshold"),
base: c.String("base"),
compare: strings.Split(c.String("compare"), ","),
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func main() {
Name: "fail-without-results",
Usage: "Exit with an error if the parsing fails",
},
&cli.BoolFlag{
Name: "overwrite-changes",
Usage: "Overwrite uncommitted changes in the git repository",
},
&cli.Float64Flag{
Name: "threshold",
Usage: "The program fails if the benchmark gets worse than the threshold",
Expand Down Expand Up @@ -120,7 +124,7 @@ func run(c config) error {
return xerrors.Errorf("unable to get the working tree status: %w", err)
}

if !s.IsClean() {
if !c.overwriteChanges && !s.IsClean() {
return xerrors.New("the repository is dirty: commit all changes before running 'cob'")
}

Expand Down
Loading