Skip to content

Commit

Permalink
feat: add additionnal exit code
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Vernin <olivier.vernin@suse.com>
  • Loading branch information
olblak committed Jan 1, 2024
1 parent 746cbf7 commit 1ede12f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/spf13/cobra"
"github.com/updatecli/releasepost/internal/core/config"
"github.com/updatecli/releasepost/internal/core/engine"
"github.com/updatecli/releasepost/internal/core/result"
)

var (
Expand All @@ -19,13 +20,15 @@ var (
err := e.Init()
if err != nil {
fmt.Printf("Failed to initialize releasepost: %v", err)
os.Exit(1)
os.Exit(2)
}
err = e.Run()
if err != nil {
fmt.Printf("Failed to run releasepost: %v", err)
os.Exit(1)
os.Exit(2)
}

os.Exit(result.ChangelogResult.ExitCode())
},
Use: "releasepost",
Short: "Releasepost is a release note town crier",
Expand Down
7 changes: 7 additions & 0 deletions internal/core/result/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@ func (c Changelog) String() {
}
}
}

func (c Changelog) ExitCode() int {
if len(c.Created) == 0 && len(c.Modified) == 0 {
return 1
}
return 0
}

0 comments on commit 1ede12f

Please sign in to comment.