mirror of
https://github.com/ddworken/hishtory.git
synced 2025-06-25 22:42:04 +02:00
Add additional check that checks that the version is valid per semver
This commit is contained in:
parent
acf46893e9
commit
29142df382
@ -19,6 +19,7 @@ import (
|
||||
"github.com/ddworken/hishtory/client/lib"
|
||||
"github.com/ddworken/hishtory/shared"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/mod/semver"
|
||||
)
|
||||
|
||||
var updateCmd = &cobra.Command{
|
||||
@ -36,7 +37,10 @@ var validateBinaryCmd = &cobra.Command{
|
||||
Args: cobra.ExactArgs(3),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx := hctx.MakeContext()
|
||||
version := args[0]
|
||||
version := strings.TrimSpace(args[0])
|
||||
if !semver.IsValid(version) {
|
||||
lib.CheckFatalError(fmt.Errorf("specified version %#v is not a valid version", version))
|
||||
}
|
||||
binaryPath := args[1]
|
||||
attestationPath := args[2]
|
||||
isMacOs, err := cmd.Flags().GetBool("is_macos")
|
||||
|
@ -36,6 +36,7 @@ func checkForDowngrade(currentVersionS, newVersionS string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse updated version %#v", newVersionS)
|
||||
}
|
||||
// TODO: migrate this to the version parser struct
|
||||
if currentVersion > newVersion {
|
||||
return fmt.Errorf("failed to update because the new version (%#v) is a downgrade compared to the current version (%#v)", newVersionS, currentVersionS)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user