Fixing bug for command mixer upstream-format

Mixer upstream-format should run with optional flag --new-format. If
--new-format is not set, the default new format should be current
format+1. This default behaviour was not getting set for the current mixer version.
Fixed the behaviour to reflect the default behaviour.

Signed-off-by: Ashlesha Atrey <ashlesha.atrey@intel.com>
This commit is contained in:
Ashlesha Atrey
2019-10-07 15:45:10 +00:00
committed by Rodrigo Chiossi
parent 1c0a851818
commit ca60ef2e53
+37
View File
@@ -167,6 +167,21 @@ var buildUpstreamFormatCmd = &cobra.Command{
fail(err)
}
// check if --new-format flag is set, if not set it to prevFormat +1
if buildFlags.newFormat == "" {
newFormat, err := strconv.Atoi(b.State.Mix.Format)
if err != nil {
fail(err)
}
newFormat = newFormat + 1
buildFlags.newFormat = strconv.Itoa(newFormat)
}
_, err = strconv.Atoi(buildFlags.newFormat)
if err != nil {
fail(errors.New("Please supply a valid format version with --new-format"))
}
// Don't print any more warnings about being behind formats when we loop
silent := true
bumpNeeded := true
@@ -218,6 +233,10 @@ var buildFormatBumpCmd = &cobra.Command{
if buildFlags.newFormat == "" {
fail(errors.New("Please supply the next format version with --new-format"))
}
_, err := strconv.Atoi(buildFlags.newFormat)
if err != nil {
fail(errors.New("Please supply a valid format version with --new-format"))
}
cmdStr := fmt.Sprintf("mixer build format-bump old --new-format %s --retries %d --native", buildFlags.newFormat, buildFlags.downloadRetries)
cmdToRun := strings.Split(cmdStr, " ")
@@ -243,6 +262,15 @@ var buildFormatOldCmd = &cobra.Command{
Short: "Build the +10 version in the old format for the format bump",
Long: `Build the +10 version in the old format for the format bump`,
Run: func(cmd *cobra.Command, args []string) {
if buildFlags.newFormat == "" {
fail(errors.New("Please supply the next format version with --new-format"))
}
_, err := strconv.Atoi(buildFlags.newFormat)
if err != nil {
fail(errors.New("Please supply a valid format version with --new-format"))
}
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)
@@ -341,6 +369,15 @@ var buildFormatNewCmd = &cobra.Command{
Short: "Build the +20 version in the new format for the format bump",
Long: `Build the +20 version in the new format for the format bump`,
Run: func(cmd *cobra.Command, args []string) {
if buildFlags.newFormat == "" {
fail(errors.New("Please supply the next format version with --new-format"))
}
_, err := strconv.Atoi(buildFlags.newFormat)
if err != nil {
fail(errors.New("Please supply a valid format version with --new-format"))
}
b, err := builder.NewFromConfig(configFile)
if err != nil {
fail(err)