az-pim-cli: fix version command

This commit is contained in:
awwpotato 2025-06-04 14:58:06 -07:00
parent 70b8b393e3
commit c0ac87829f
No known key found for this signature in database
2 changed files with 39 additions and 3 deletions

View file

@ -7,7 +7,6 @@
buildPackages,
nix-update-script,
testers,
az-pim-cli,
}:
buildGoModule (finalAttrs: {
pname = "az-pim-cli";
@ -20,12 +19,24 @@ buildGoModule (finalAttrs: {
hash = "sha256-gf4VscHaUr3JtsJO5PAq1nyPeJxIwGPaiH/QdXKpvQ0=";
};
patches = [
# removes info we don't have from version command
./version-build-info.patch
];
vendorHash = "sha256-PHrpUlAG/PBe3NKUGBQ1U7dCcqkSlErWX2dp9ZPB3+8=";
nativeBuildInputs = [
installShellFiles
];
env.CGO_ENABLED = 0;
ldflags = [
"-s"
"-X github.com/netr0m/az-pim-cli/cmd.version=v${finalAttrs.version}"
];
postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
let
emulator = stdenv.hostPlatform.emulator buildPackages;
@ -41,8 +52,9 @@ buildGoModule (finalAttrs: {
passthru = {
updateScript = nix-update-script { };
tests.version = testers.testVersion {
command = "HOME=$TMPDIR az-pim-cli --version";
package = az-pim-cli;
command = "HOME=$TMPDIR az-pim-cli version";
package = finalAttrs.finalPackage;
version = "v${finalAttrs.version}";
};
};

View file

@ -0,0 +1,24 @@
diff --git a/cmd/version.go b/cmd/version.go
index 816f044..ef107be 100644
--- a/cmd/version.go
+++ b/cmd/version.go
@@ -31,8 +31,7 @@ type BuildInfo struct {
}
func (b BuildInfo) String() string {
- return fmt.Sprintf("az-pim-cli version %s (built with %s from %s on %s)",
- b.Version, b.GoVersion, b.Commit, b.Date)
+ return fmt.Sprintf("az-pim-cli version %s", b.Version)
}
func printVersion(w io.Writer, info BuildInfo) {
@@ -47,8 +46,8 @@ func createBuildInfo() BuildInfo {
Date: date,
}
- buildInfo, available := debug.ReadBuildInfo()
- if !available {
+ buildInfo, _ := debug.ReadBuildInfo()
+ if true {
return info
}