chore: fix lint with error

main
sudo pacman -Syu 2022-07-03 22:34:18 +07:00 committed by sudo pacman -Syu
parent da1af6f096
commit e17893651e
1 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package cli
import (
"errors"
"fmt"
"os"
"path/filepath"
@ -19,6 +20,11 @@ import (
"golang.org/x/mod/semver"
)
var (
ErrUnknownFiletype = errors.New("unknown filetype")
ErrInvalidVersion = errors.New("invalid version")
)
func (a *action) RunGenerate(c *cli.Context) error {
a.getFlags(c)
@ -91,7 +97,7 @@ func (a *action) generateChangelog(commits []convention.Commit) error {
case rstFiletype:
return a.generateRSTChangelog(finalOutput, version, commits)
default:
return fmt.Errorf("unknown filetype %s", a.flags.filetype)
return fmt.Errorf("unknown filetype %s: %w", a.flags.filetype, ErrUnknownFiletype)
}
}
@ -106,7 +112,7 @@ func (a *action) getFinalOutput() string {
func (a *action) getVersion() (string, error) {
if a.flags.version == "" {
return "", fmt.Errorf("empty version")
return "", fmt.Errorf("empty version: %w", ErrInvalidVersion)
}
if !strings.HasPrefix(a.flags.version, "v") {
@ -114,7 +120,7 @@ func (a *action) getVersion() (string, error) {
}
if !semver.IsValid(a.flags.version) {
return "", fmt.Errorf("invalid semver %s", a.flags.version)
return "", fmt.Errorf("invalid semver %s: %w", a.flags.version, ErrInvalidVersion)
}
a.log("version %s", a.flags.version)