Unverified Commit 169f6c98 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

shfmt: 3.12.0 -> 3.13.0 (#498222)

parents 6112af7f a519847a
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -3,28 +3,35 @@
  buildGoModule,
  fetchFromGitHub,
  installShellFiles,
  replaceVars,
  scdoc,
  versionCheckHook,
}:

buildGoModule (finalAttrs: {
  pname = "shfmt";
  version = "3.12.0";
  version = "3.13.0";

  src = fetchFromGitHub {
    owner = "mvdan";
    repo = "sh";
    rev = "v${finalAttrs.version}";
    hash = "sha256-3a0N5GsqZvJVx1qhsTzwtC2SBtexdXJMalerM+joNIc=";
    hash = "sha256-VFLnQNhySXB/VE0u9u2X4jAHq+083+QjhWM7vfyxhM8=";
  };

  vendorHash = "sha256-jvsX0nn9cHq2cZUrD9E1eMtOiy5I4wfpngAc+6qUbEE=";
  vendorHash = "sha256-WLGHcmBslXJO4OKdUK7HqimdUCOtdCdK+AOdlo4hgWk=";

  patches = [
    (replaceVars ./version.patch {
      inherit (finalAttrs) version;
    })
  ];

  subPackages = [ "cmd/shfmt" ];

  ldflags = [
    "-s"
    "-w"
    "-X main.version=${finalAttrs.version}"
  ];

  nativeBuildInputs = [
@@ -37,6 +44,10 @@ buildGoModule (finalAttrs: {
    installManPage shfmt.1
  '';

  doInstallCheck = true;
  nativeInstallCheckInputs = [ versionCheckHook ];
  versionCheckProgramArg = "--version";

  meta = {
    homepage = "https://github.com/mvdan/sh";
    description = "Shell parser and formatter";
+37 −0
Original line number Diff line number Diff line
diff --git a/cmd/shfmt/main.go b/cmd/shfmt/main.go
index c6c08e37..e59128ec 100644
--- a/cmd/shfmt/main.go
+++ b/cmd/shfmt/main.go
@@ -153,13 +153,12 @@ For more information and to report bugs, see https://github.com/mvdan/sh.
 	flag.Parse()
 
 	if versionFlag.val {
-		version := "(unknown)"
+		version := "@version@"
 		if info, ok := debug.ReadBuildInfo(); ok {
 			mod := &info.Main
 			if mod.Replace != nil {
 				mod = mod.Replace
 			}
-			version = mod.Version
 		}
 		fmt.Println(version)
 		return
diff --git a/cmd/shfmt/testdata/script/flags.txtar b/cmd/shfmt/testdata/script/flags.txtar
index 012912cb..54305a03 100644
--- a/cmd/shfmt/testdata/script/flags.txtar
+++ b/cmd/shfmt/testdata/script/flags.txtar
@@ -9,11 +9,11 @@ exec shfmt --help
 stderr 'usage: shfmt'
 
 exec shfmt -version
-stdout 'devel|v3'
+stdout '@version@'
 ! stderr .
 
 exec shfmt --version
-stdout 'devel|v3'
+stdout '@version@'
 ! stderr .
 
 ! exec shfmt -ln=bash -p