Skip to content

Commit 2298fbc

Browse files
nsheapsclaude
andauthored
refactor: move formula to template file (#9)
Co-authored-by: Claude Code (User Settings, in: ${CLAUDE_PROJECT_DIR}) <noreply@anthropic.com>
1 parent 5bc6185 commit 2298fbc

4 files changed

Lines changed: 50 additions & 30 deletions

File tree

.github/workflows/release.yaml

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -84,37 +84,17 @@ jobs:
8484
run: |
8585
gh repo clone nsheaps/homebrew-devsetup homebrew-devsetup
8686
87-
- name: Update formula
87+
- name: Install gomplate
8888
run: |
89-
cd homebrew-devsetup
90-
cat > Formula/git-wt.rb << FORMULA_EOF
91-
# typed: false
92-
# frozen_string_literal: true
93-
94-
class GitWt < Formula
95-
desc 'Interactive TUI for git worktree management'
96-
homepage 'https://github.com/nsheaps/git-wt'
97-
url 'https://github.com/nsheaps/git-wt/archive/refs/tags/${{ steps.release.outputs.tag }}.tar.gz'
98-
sha256 '${{ steps.release.outputs.sha256 }}'
99-
license 'MIT'
100-
101-
head do
102-
url 'https://github.com/nsheaps/git-wt.git', branch: 'main'
103-
end
104-
105-
depends_on 'gum'
106-
107-
def install
108-
bin.install 'bin/git-wt'
109-
end
110-
111-
test do
112-
assert_match 'git-wt', shell_output("#{bin}/git-wt --help")
113-
end
114-
end
115-
FORMULA_EOF
116-
# Remove leading whitespace from heredoc
117-
sed -i 's/^ //' Formula/git-wt.rb
89+
curl -fsSL https://github.com/hairyhenderson/gomplate/releases/latest/download/gomplate_linux-amd64 -o /usr/local/bin/gomplate
90+
chmod +x /usr/local/bin/gomplate
91+
92+
- name: Generate formula from template
93+
env:
94+
Tag: ${{ steps.release.outputs.tag }}
95+
SHA256: ${{ steps.release.outputs.sha256 }}
96+
run: |
97+
gomplate -f Formula/git-wt.rb.gotmpl -o homebrew-devsetup/Formula/git-wt.rb
11898
11999
- name: Create PR to update formula with auto-merge
120100
env:

.github/workflows/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
2426

2527
- name: Setup mise
2628
uses: jdx/mise-action@v2

.rubocop.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
AllCops:
3+
NewCops: enable
4+
Metrics/BlockLength:
5+
Enabled: false
6+
Layout/LineLength:
7+
AllowedPatterns:
8+
- "# renovate: .*"
9+
Naming/FileName:
10+
Enabled: false
11+
Style/FrozenStringLiteralComment:
12+
Enabled: false
13+
Style/Documentation:
14+
Enabled: false

Formula/git-wt.rb.gotmpl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# typed: false
2+
# frozen_string_literal: true
3+
4+
class GitWt < Formula
5+
desc 'Interactive TUI for git worktree management'
6+
homepage 'https://github.com/nsheaps/git-wt'
7+
url 'https://github.com/nsheaps/git-wt/archive/refs/tags/{{ .Env.Tag }}.tar.gz'
8+
sha256 '{{ .Env.SHA256 }}'
9+
license 'MIT'
10+
11+
head do
12+
url 'https://github.com/nsheaps/git-wt.git', branch: 'main'
13+
end
14+
15+
depends_on 'gum'
16+
17+
def install
18+
bin.install 'bin/git-wt'
19+
end
20+
21+
test do
22+
assert_match 'git-wt', shell_output("#{bin}/git-wt --help")
23+
end
24+
end

0 commit comments

Comments
 (0)