Skip to content
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
7 changes: 4 additions & 3 deletions cmd/gitmono/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ func run() int {
}
}

// parse options and trigger command
// parse options to trigger command
// errors are logged by the flags library
_, err = flagsParser.Parse()
if exit, code := checkError(err); exit {
return code
if err != nil {
return 1
}
return 0
}
Expand Down
13 changes: 11 additions & 2 deletions cmd/gitmono/main_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
)

// TestCommand uses google/go-cmdtest to run commands and verify output
//
// Use UPDATE_TESTDATA=true to perform update of testdata file from test output.
// By default go-cmdtest runs in compare mode which compares testdata with actual test output.
func TestCommand(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -56,7 +59,7 @@ func TestCommand(t *testing.T) {
assert.Nil(t, err)

ts.Commands["gitmono"] = cmdtest.InProcessProgram("gitmono", run)
ts.Run(t, false)
ts.Run(t, isUpdateTestdataMode())
}
}

Expand All @@ -68,7 +71,13 @@ func TestCommandFailures(t *testing.T) {
assert.Nil(t, err)

ts.Commands["gitmono"] = cmdtest.InProcessProgram("gitmono", run)
ts.Run(t, false)
ts.Run(t, isUpdateTestdataMode())
}

func isUpdateTestdataMode() bool {
updateMode, found := os.LookupEnv("UPDATE_TESTDATA")
return found && updateMode == "true"

}

func setupRepo(t *testing.T) func() {
Expand Down
20 changes: 0 additions & 20 deletions cmd/gitmono/testdata/diff/diff.ct
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,3 @@ Help Options:
diff:
-f= The starting point of reference range
-t= The ending point of reference range (default: HEAD)

Usage:
gitmono [OPTIONS] diff [diff-OPTIONS]

Application Options:
-p= The project directory to operate on (default: .)
-v Enable verbose loggging
--dry-run Do not persist any write action
--commit-scheme= The scheme parse commit messages with (common,
conventional) (default: conventional)
--version-prefix= The prefix to prepend to version

Help Options:
-h, --help Show this help message

[diff command options]

diff:
-f= The starting point of reference range
-t= The ending point of reference range (default: HEAD)
21 changes: 0 additions & 21 deletions cmd/gitmono/testdata/help/help.ct
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,3 @@ Available commands:
log
release
version

Usage:
gitmono [OPTIONS] <command>

Application Options:
-p= The project directory to operate on (default: .)
-v Enable verbose loggging
--dry-run Do not persist any write action
--commit-scheme= The scheme parse commit messages with (common,
conventional) (default: conventional)
--version-prefix= The prefix to prepend to version

Help Options:
-h, --help Show this help message

Available commands:
diff
init
log
release
version
21 changes: 0 additions & 21 deletions cmd/gitmono/testdata/init/init.ct
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,3 @@ Help Options:
-c= The commit ID to release initial versions on (default:
HEAD)
--print-tag Print tag instead of version

Usage:
gitmono [OPTIONS] init [init-OPTIONS]

Application Options:
-p= The project directory to operate on (default: .)
-v Enable verbose loggging
--dry-run Do not persist any write action
--commit-scheme= The scheme parse commit messages with (common,
conventional) (default: conventional)
--version-prefix= The prefix to prepend to version

Help Options:
-h, --help Show this help message

[init command options]

init:
-c= The commit ID to release initial versions on (default:
HEAD)
--print-tag Print tag instead of version
20 changes: 0 additions & 20 deletions cmd/gitmono/testdata/log/log.ct
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,3 @@ Help Options:
log:
-f= The starting point of reference range
-t= The ending point of reference range (default: HEAD)

Usage:
gitmono [OPTIONS] log [log-OPTIONS]

Application Options:
-p= The project directory to operate on (default: .)
-v Enable verbose loggging
--dry-run Do not persist any write action
--commit-scheme= The scheme parse commit messages with (common,
conventional) (default: conventional)
--version-prefix= The prefix to prepend to version

Help Options:
-h, --help Show this help message

[log command options]

log:
-f= The starting point of reference range
-t= The ending point of reference range (default: HEAD)
21 changes: 0 additions & 21 deletions cmd/gitmono/testdata/release/release.ct
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
$ gitmono release -p project-released --> FAIL
no commits to release
no commits to release

$ gitmono release -p project-breaking-change --version-prefix=v -c HEAD --dry-run
v1.0.0
Expand Down Expand Up @@ -33,23 +32,3 @@ Help Options:
release:
-c= The commit ID to release versions on (default: HEAD)
--print-tag Print tag instead of version

Usage:
gitmono [OPTIONS] release [release-OPTIONS]

Application Options:
-p= The project directory to operate on (default: .)
-v Enable verbose loggging
--dry-run Do not persist any write action
--commit-scheme= The scheme parse commit messages with (common,
conventional) (default: conventional)
--version-prefix= The prefix to prepend to version

Help Options:
-h, --help Show this help message

[release command options]

release:
-c= The commit ID to release versions on (default: HEAD)
--print-tag Print tag instead of version
20 changes: 0 additions & 20 deletions cmd/gitmono/testdata/version/version.ct
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,3 @@ Help Options:
version:
--print-tag Print the tag of the current version
--print-commit Print the commit of the current version

Usage:
gitmono [OPTIONS] version [version-OPTIONS]

Application Options:
-p= The project directory to operate on (default: .)
-v Enable verbose loggging
--dry-run Do not persist any write action
--commit-scheme= The scheme parse commit messages with (common,
conventional) (default: conventional)
--version-prefix= The prefix to prepend to version

Help Options:
-h, --help Show this help message

[version command options]

version:
--print-tag Print the tag of the current version
--print-commit Print the commit of the current version
7 changes: 7 additions & 0 deletions pkg/gitmono/commit_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ func Test_conventionalCommitParse(t *testing.T) {
},
want: majorBumper,
},
{
name: "use breaking change with exclamation",
args: args{
msg: "fix!: bug that introduces breaking API change\nAPI change",
},
want: majorBumper,
},
{
name: "feature implmenentation",
args: args{
Expand Down