main: --version includes git commit

Include the commit of the build (if available in the build environment),
also include the version of `images` in the build; if available.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
Simon de Vlieger 2025-06-23 08:36:41 +02:00
parent f52041ab67
commit 3021afb9f7
3 changed files with 71 additions and 5 deletions

View file

@ -28,9 +28,8 @@ import (
)
var (
osStdout io.Writer = os.Stdout
osStderr io.Writer = os.Stderr
BuildVersion = "DEVEL"
osStdout io.Writer = os.Stdout
osStderr io.Writer = os.Stderr
)
// basenameFor returns the basename for directory and filenames
@ -423,11 +422,13 @@ image-type and blueprint.
Image-builder builds operating system images for a range of predefined
operating systems like Fedora, CentOS and RHEL with easy customizations support.`,
SilenceErrors: true,
Version: BuildVersion,
Version: prettyVersion(),
CompletionOptions: cobra.CompletionOptions{
HiddenDefaultCmd: true,
},
}
rootCmd.SetVersionTemplate(prettyVersion())
rootCmd.PersistentFlags().String("data-dir", "", `Override the default data directory for e.g. custom repositories/*.json data`)
rootCmd.PersistentFlags().StringArray("extra-repo", nil, `Add an extra repository during build (will *not* be gpg checked and not be part of the final image)`)
rootCmd.PersistentFlags().StringArray("force-repo", nil, `Override the base repositories during build (these will not be part of the final image)`)