Skip to content

Commit

Permalink
when no changes are found, auto will return an error
Browse files Browse the repository at this point in the history
* this applies to batch auto and next auto
  • Loading branch information
miniscruff committed Jan 26, 2023
1 parent d647e7b commit 3db0afb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
## Getting Started
* User documentation is available on the [website](https://changie.dev/).
* Specifically, the [guide](https://changie.dev/guide/) is a good place to start.
* There is also a [Changie GitHub Action](https://github.com/miniscruff/changie-action) you can use
* View Changie's [Changelog](CHANGELOG.md) for an example.

## Need help?
Expand Down
9 changes: 7 additions & 2 deletions core/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
)

var (
ErrBadVersionOrPart = errors.New("part string is not a supported version or version increment")
ErrMissingAutoLevel = errors.New("kind config missing auto level value for auto bumping")
ErrBadVersionOrPart = errors.New("part string is not a supported version or version increment")
ErrMissingAutoLevel = errors.New("kind config missing auto level value for auto bumping")
ErrNoChangesFoundForAuto = errors.New("no unreleased changes found for automatic bumping")
)

func AppendFile(opener shared.OpenFiler, rootFile io.Writer, path string) error {
Expand Down Expand Up @@ -93,6 +94,10 @@ func ValidBumpLevel(level string) bool {
}

func HighestAutoLevel(config Config, allChanges []Change) (string, error) {
if len(allChanges) == 0 {
return "", ErrNoChangesFoundForAuto
}

highestLevel := PatchLevel

for _, change := range allChanges {
Expand Down
13 changes: 13 additions & 0 deletions core/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,19 @@ func TestErrorHighestAutoLevelMissingKindConfig(t *testing.T) {
then.Err(t, ErrMissingAutoLevel, err)
}

func TestErrorHighestAutoLevelWithNoChanges(t *testing.T) {
cfg := Config{
Kinds: []KindConfig{
{
Label: "missing",
},
},
}
changes := []Change{}
_, err := HighestAutoLevel(cfg, changes)
then.Err(t, ErrNoChangesFoundForAuto, err)
}

func TestGetAllChanges(t *testing.T) {
cfg := utilsTestConfig()
_, afs := then.WithAferoFSConfig(t, cfg)
Expand Down

0 comments on commit 3db0afb

Please sign in to comment.