Skip to content

Match indent of templated items to pass brew audit#55

Merged
Justintime50 merged 7 commits intoJustintime50:mainfrom
overhacked:fix-formula-test-indent
Apr 27, 2025
Merged

Match indent of templated items to pass brew audit#55
Justintime50 merged 7 commits intoJustintime50:mainfrom
overhacked:fix-formula-test-indent

Conversation

@overhacked
Copy link
Copy Markdown
Contributor

If templated strings are multiline, like test and install, then they should be adjusted to match the indent of the formula yaml, or brew audit will complain.

If templated strings are multiline, like `test` and `install`, then they
should be adjusted to match the indent of the formula yaml, or `brew
audit` will complain.

Signed-off-by: Ross Williams <ross@ross-williams.net>
@Justintime50
Copy link
Copy Markdown
Owner

Awesome! Do you mind sharing a quick example of before the fix and after? Want to see it in action.

Signed-off-by: Ross Williams <ross@ross-williams.net>
Signed-off-by: Ross Williams <ross@ross-williams.net>
Signed-off-by: Ross Williams <ross@ross-williams.net>
@overhacked
Copy link
Copy Markdown
Contributor Author

I pushed some unit tests that prompted me to fix an issue. The commit log is noisy, so let me know if you'd like me to squash before you merge. A comparison of output before and after the change:

Diff of output:

--- test/formulas/test_generate_formula_multiline_test.rb 	2025-04-25 16:58:27
+++ test/formulas/test_generate_formula_multiline_test.rb	2025-04-25 16:57:31
@@ -18,10 +18,10 @@
 
   test do
     output = shell_output(%Q(
-  for test_case in case1 case2 case3; do
-    run_case $test_case
-  done
-))
-assert_match("my script output", output)
+      for test_case in case1 case2 case3; do
+        run_case $test_case
+      done
+    ))
+    assert_match("my script output", output)
   end
 end

Before:

# typed: true
# frozen_string_literal: true

# This file was generated by Homebrew Releaser. DO NOT EDIT.
class TestGenerateFormulaMultilineTest < Formula
  desc "Release scripts, binaries, and executables to github"
  homepage "https://github.com/Justintime50/test-generate-formula-multiline-test"
  url "https://github.com/Justintime50/test-generate-formula-multiline-test/archive/refs/tags/v0.1.0.tar.gz"
  sha256 "0000000000000000000000000000000000000000000000000000000000000000"
  license "MIT"

  depends_on "bash" => :build
  depends_on "gcc"

  def install
    bin.install "src/secure-browser-kiosk.sh" => "secure-browser-kiosk"
  end

  test do
    output = shell_output(%Q(
  for test_case in case1 case2 case3; do
    run_case $test_case
  done
))
assert_match("my script output", output)
  end
end

After:

# typed: true
# frozen_string_literal: true

# This file was generated by Homebrew Releaser. DO NOT EDIT.
class TestGenerateFormulaMultilineTest < Formula
  desc "Release scripts, binaries, and executables to github"
  homepage "https://github.com/Justintime50/test-generate-formula-multiline-test"
  url "https://github.com/Justintime50/test-generate-formula-multiline-test/archive/refs/tags/v0.1.0.tar.gz"
  sha256 "0000000000000000000000000000000000000000000000000000000000000000"
  license "MIT"

  depends_on "bash" => :build
  depends_on "gcc"

  def install
    bin.install "src/secure-browser-kiosk.sh" => "secure-browser-kiosk"
  end

  test do
    output = shell_output(%Q(
      for test_case in case1 case2 case3; do
        run_case $test_case
      done
    ))
    assert_match("my script output", output)
  end
end

Copy link
Copy Markdown
Owner

@Justintime50 Justintime50 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: this is great work, thanks for putting up this PR and adding tests! I have a couple small items. Once addressed I'll merge in and release!

Comment thread test/unit/test_formula.py Outdated
Comment thread test/unit/test_formula.py
Comment thread homebrew_releaser/formula.py Outdated
Comment thread homebrew_releaser/formula.py
@overhacked
Copy link
Copy Markdown
Contributor Author

Right on with the feedback. I'm glad I've got you as a solid reviewer looking over this, because apparently I've got the Friday sloppies. Let me get some recharge, and I'll come back and tighten it up.

Fix doc comment and type hints, also.

Signed-off-by: Ross Williams <ross@ross-williams.net>
Signed-off-by: Ross Williams <ross@ross-williams.net>
`brew audit` didn't like `%Q()` when the quoted string did not contain
both single and double quotes, so add some unnecessary shell quoting to
the example, since it's just a non-working snippet to test string indent
handling.

Signed-off-by: Ross Williams <ross@ross-williams.net>
@Justintime50 Justintime50 merged commit 471d5a6 into Justintime50:main Apr 27, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants