From 2df5e79120945b0a07705d4d616ba5e8ee39db21 Mon Sep 17 00:00:00 2001 From: Nathan Heaps <1282393+nsheaps@users.noreply.github.com> Date: Wed, 21 Jan 2026 12:35:35 -0500 Subject: [PATCH 1/3] refactor: move formula to template file - Create Formula/git-wt.rb.gotmpl template - Update release workflow to use sed substitution - Add .rubocop.yml for formula linting consistency This makes formula maintenance easier by separating the template from the CI workflow logic. Co-Authored-By: Claude Code (User Settings, in: ${CLAUDE_PROJECT_DIR}) --- .github/workflows/release.yaml | 38 +++++++--------------------------- .rubocop.yml | 14 +++++++++++++ Formula/git-wt.rb.gotmpl | 24 +++++++++++++++++++++ 3 files changed, 46 insertions(+), 30 deletions(-) create mode 100644 .rubocop.yml create mode 100644 Formula/git-wt.rb.gotmpl diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index de2243d..2914bfc 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -84,37 +84,15 @@ jobs: run: | gh repo clone nsheaps/homebrew-devsetup homebrew-devsetup - - name: Update formula + - name: Generate formula from template run: | - cd homebrew-devsetup - cat > Formula/git-wt.rb << FORMULA_EOF - # typed: false - # frozen_string_literal: true - - class GitWt < Formula - desc 'Interactive TUI for git worktree management' - homepage 'https://github.com/nsheaps/git-wt' - url 'https://github.com/nsheaps/git-wt/archive/refs/tags/${{ steps.release.outputs.tag }}.tar.gz' - sha256 '${{ steps.release.outputs.sha256 }}' - license 'MIT' - - head do - url 'https://github.com/nsheaps/git-wt.git', branch: 'main' - end - - depends_on 'gum' - - def install - bin.install 'bin/git-wt' - end - - test do - assert_match 'git-wt', shell_output("#{bin}/git-wt --help") - end - end - FORMULA_EOF - # Remove leading whitespace from heredoc - sed -i 's/^ //' Formula/git-wt.rb + TAG="${{ steps.release.outputs.tag }}" + SHA256="${{ steps.release.outputs.sha256 }}" + + # Read template and substitute variables + sed -e "s/{{.Tag}}/${TAG}/g" \ + -e "s/{{.SHA256}}/${SHA256}/g" \ + Formula/git-wt.rb.gotmpl > homebrew-devsetup/Formula/git-wt.rb - name: Create PR to update formula with auto-merge env: diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..7906928 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,14 @@ +--- +AllCops: + NewCops: enable +Metrics/BlockLength: + Enabled: false +Layout/LineLength: + AllowedPatterns: + - "# renovate: .*" +Naming/FileName: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/Documentation: + Enabled: false diff --git a/Formula/git-wt.rb.gotmpl b/Formula/git-wt.rb.gotmpl new file mode 100644 index 0000000..8afd8e1 --- /dev/null +++ b/Formula/git-wt.rb.gotmpl @@ -0,0 +1,24 @@ +# typed: false +# frozen_string_literal: true + +class GitWt < Formula + desc 'Interactive TUI for git worktree management' + homepage 'https://github.com/nsheaps/git-wt' + url 'https://github.com/nsheaps/git-wt/archive/refs/tags/{{.Tag}}.tar.gz' + sha256 '{{.SHA256}}' + license 'MIT' + + head do + url 'https://github.com/nsheaps/git-wt.git', branch: 'main' + end + + depends_on 'gum' + + def install + bin.install 'bin/git-wt' + end + + test do + assert_match 'git-wt', shell_output("#{bin}/git-wt --help") + end +end From 1e0f29cd4eb2c4e5a944037f42f978b622f3885c Mon Sep 17 00:00:00 2001 From: Nathan Heaps <1282393+nsheaps@users.noreply.github.com> Date: Wed, 21 Jan 2026 13:18:49 -0500 Subject: [PATCH 2/3] refactor: use gomplate for formula templating instead of sed --- .github/workflows/release.yaml | 16 +++++++++------- Formula/git-wt.rb.gotmpl | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2914bfc..ce0a45e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -84,15 +84,17 @@ jobs: run: | gh repo clone nsheaps/homebrew-devsetup homebrew-devsetup - - name: Generate formula from template + - name: Install gomplate run: | - TAG="${{ steps.release.outputs.tag }}" - SHA256="${{ steps.release.outputs.sha256 }}" + curl -fsSL https://github.com/hairyhenderson/gomplate/releases/latest/download/gomplate_linux-amd64 -o /usr/local/bin/gomplate + chmod +x /usr/local/bin/gomplate - # Read template and substitute variables - sed -e "s/{{.Tag}}/${TAG}/g" \ - -e "s/{{.SHA256}}/${SHA256}/g" \ - Formula/git-wt.rb.gotmpl > homebrew-devsetup/Formula/git-wt.rb + - name: Generate formula from template + env: + Tag: ${{ steps.release.outputs.tag }} + SHA256: ${{ steps.release.outputs.sha256 }} + run: | + gomplate -f Formula/git-wt.rb.gotmpl -o homebrew-devsetup/Formula/git-wt.rb - name: Create PR to update formula with auto-merge env: diff --git a/Formula/git-wt.rb.gotmpl b/Formula/git-wt.rb.gotmpl index 8afd8e1..2bd5226 100644 --- a/Formula/git-wt.rb.gotmpl +++ b/Formula/git-wt.rb.gotmpl @@ -4,8 +4,8 @@ class GitWt < Formula desc 'Interactive TUI for git worktree management' homepage 'https://github.com/nsheaps/git-wt' - url 'https://github.com/nsheaps/git-wt/archive/refs/tags/{{.Tag}}.tar.gz' - sha256 '{{.SHA256}}' + url 'https://github.com/nsheaps/git-wt/archive/refs/tags/{{ .Env.Tag }}.tar.gz' + sha256 '{{ .Env.SHA256 }}' license 'MIT' head do From 3563170d874f71b1e1117aa92cc00d702beb8614 Mon Sep 17 00:00:00 2001 From: Nathan Heaps <1282393+nsheaps@users.noreply.github.com> Date: Wed, 21 Jan 2026 13:19:28 -0500 Subject: [PATCH 3/3] ci: fetch tags in test workflow for version detection The --version test was failing because git describe returns a commit hash when tags aren't fetched. Adding fetch-depth: 0 ensures tags are available for proper version string generation. Co-Authored-By: Claude Code (User Settings, in: ${CLAUDE_PROJECT_DIR}) --- .github/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ff82d7b..48b7d03 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,6 +21,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup mise uses: jdx/mise-action@v2