Skip to content

Replace Homebrew bump action with direct formula update - #184

Merged
helizaga merged 2 commits into
mainfrom
fix-homebrew-bump-303
Jun 12, 2026
Merged

Replace Homebrew bump action with direct formula update#184
helizaga merged 2 commits into
mainfrom
fix-homebrew-bump-303

Conversation

@helizaga

@helizaga helizaga commented Jun 12, 2026

Copy link
Copy Markdown
Member

The homebrew workflow failed on the v2.8.0 release with unexpected HTTP 303 response. GitHub started returning 303 redirects on tarball URLs and bump-homebrew-formula-action rejects them (mislav/bump-homebrew-formula-action#340, fix unmerged, latest release predates it). The v2.8.0 formula had to be bumped by hand.

This drops the action and does the bump directly in a script step: download the release tarball, sha256 it, update url + sha256 in the tap formula via the contents API with the existing HOMEBREW_TAP_TOKEN. Same commit message format the action used. Skips cleanly if the formula is already at the tag, so reruns are safe. No third-party action left in the workflow.

Also adds workflow_dispatch with a tag-name input so a failed bump can be rerun manually instead of editing the tap by hand.

Tested every path:

  • container dry-runs of the exact script: v2.7.3 output is byte-identical to the real v2.7.3 tap commit; bad tag and unexpected formula format both exit non-zero
  • live dispatches from this branch with the real secret: v2.8.0 hits the already-current guard, v9.9.9 fails the run on curl 404, and a v2.7.3v2.8.0 round trip wrote real commits to the tap (f177412, 04e2f45) that diff clean against the historical 2.7.3 and current 2.8.0 formulas
  • brew fetch coderabbitai/tap/git-gtr checks out after the round trip
  • actionlint clean

@helizaga
helizaga requested a review from NatoBoram as a code owner June 12, 2026 17:51
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds a manual workflow_dispatch input (tag-name) and replaces the external Homebrew bump action with an inline shell script that computes the release tarball URL and SHA-256, fetches and decodes Formula/git-gtr.rb, conditionally updates url and sha256, and commits the change to the tap via the GitHub contents API.

Changes

Homebrew Formula Update Automation

Layer / File(s) Summary
Add manual trigger input
.github/workflows/homebrew.yml
Adds workflow_dispatch with a required tag-name input used to select which release/tag to bump the formula to.
Inline Homebrew formula update script
.github/workflows/homebrew.yml
Replaces mislav/bump-homebrew-formula-action with an inline bash script that builds the tarball URL, downloads and hashes the tarball, retrieves and base64-decodes Formula/git-gtr.rb from the tap using HOMEBREW_TAP_TOKEN, exits if the formula already references the tarball URL, otherwise updates url and sha256, re-encodes the file, and commits it back via a GitHub contents API PUT.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through YAML, tag in paw,
Replaced an action with my own shell law,
I fetch the tar, I hash, I peep,
Update the tap if changes creep,
Commit a carrot-coded draw. 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: replacing a third-party Homebrew action with an inline script for direct formula updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-homebrew-bump-303

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/homebrew.yml:
- Around line 20-26: TAG_NAME is inserted directly into url and later used in
sed substitutions; validate or escape it before use. Add a validation step for
TAG_NAME (e.g., require a safe pattern like an optional leading "v" followed by
alphanumerics, ., _, -) and exit with an error if it doesn't match;
alternatively, escape sed metacharacters in TAG_NAME (and derived version/url)
before any sed command by replacing characters like | / & \ with escaped
versions so the sed substitution won't break. Ensure these checks/escapes are
applied to the TAG_NAME -> version/url flow and before the sed commands that
reference those variables.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 27bc6891-6ee9-48ce-94e6-653e329bd3e6

📥 Commits

Reviewing files that changed from the base of the PR and between 8580233 and 9009031.

📒 Files selected for processing (1)
  • .github/workflows/homebrew.yml

Comment on lines +20 to +26
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
TAG_NAME: ${{ github.event.release.tag_name }}
run: |
set -euo pipefail

version="${TAG_NAME#v}"
url="https://github.com/coderabbitai/git-worktree-runner/archive/refs/tags/${TAG_NAME}.tar.gz"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate or escape TAG_NAME before use in sed patterns.

TAG_NAME originates from github.event.release.tag_name and is embedded directly into the url variable, which is later used unescaped in sed substitution patterns (lines 40-41). Git tags can contain characters like | (the sed delimiter), & (replacement metacharacter), or backslashes that could break the sed command or cause unintended substitutions.

While the curl download will likely fail for malformed URLs (providing implicit validation), consider adding explicit validation:

Proposed fix: validate tag format
          set -euo pipefail

+         # Validate tag format (vX.Y.Z)
+         if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+           echo "Invalid tag format: $TAG_NAME" >&2
+           exit 1
+         fi
+
          version="${TAG_NAME#v}"
          url="https://github.com/coderabbitai/git-worktree-runner/archive/refs/tags/${TAG_NAME}.tar.gz"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
TAG_NAME: ${{ github.event.release.tag_name }}
run: |
set -euo pipefail
version="${TAG_NAME#v}"
url="https://github.com/coderabbitai/git-worktree-runner/archive/refs/tags/${TAG_NAME}.tar.gz"
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
TAG_NAME: ${{ github.event.release.tag_name }}
run: |
set -euo pipefail
# Validate tag format (vX.Y.Z)
if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid tag format: $TAG_NAME" >&2
exit 1
fi
version="${TAG_NAME#v}"
url="https://github.com/coderabbitai/git-worktree-runner/archive/refs/tags/${TAG_NAME}.tar.gz"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/homebrew.yml around lines 20 - 26, TAG_NAME is inserted
directly into url and later used in sed substitutions; validate or escape it
before use. Add a validation step for TAG_NAME (e.g., require a safe pattern
like an optional leading "v" followed by alphanumerics, ., _, -) and exit with
an error if it doesn't match; alternatively, escape sed metacharacters in
TAG_NAME (and derived version/url) before any sed command by replacing
characters like | / & \ with escaped versions so the sed substitution won't
break. Ensure these checks/escapes are applied to the TAG_NAME -> version/url
flow and before the sed commands that reference those variables.

@helizaga
helizaga merged commit ad7a3c5 into main Jun 12, 2026
7 of 8 checks passed
@helizaga
helizaga deleted the fix-homebrew-bump-303 branch June 12, 2026 18:05
ddullah added a commit to TigerEye-Enterprise/git-worktree-runner that referenced this pull request Aug 14, 2026
* Detect and recover locked worktree entries with missing directories (coderabbitai#182)

git worktree prune skips locked entries by design, so a locked worktree
whose directory was deleted (e.g. a crashed agent session) lingers in the
registry and keeps its branch checked out. clean now detects this, offers
to unlock and prune (auto-confirmed by --force/--yes, previewed by
--dry-run), and prints the manual recovery command when declined.

* feat(clean): support closed PR cleanup (coderabbitai#183)

* feat(clean): support closed PR cleanup

Assisted-by: pi:gpt-5.5
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>

* fix(clean): address closed cleanup review nits

Assisted-by: pi:gpt-5.5
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>

* fix(clean): match GitLab head_sha fallback

Assisted-by: pi:gpt-5.5
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>

---------

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>

* Release v2.8.0

* Replace Homebrew bump action with direct formula update (coderabbitai#184)

* Replace Homebrew bump action with direct formula update

* Allow manual formula bump via workflow_dispatch

* Return non-zero when git gtr rm fails (coderabbitai#190)

* Fix rm exit status on removal failures

* Test public rm failure status

* chore: prepare v2.8.1 release

* fix(copy): bound includeDirs discovery (coderabbitai#191)

* fix(copy): bound includeDirs discovery

* test(copy): allow filesystem result order

* fix(copy): preserve basename fallback

* chore: prepare v2.8.2 release

* feat: inherit sparse-checkout in new worktrees (coderabbitai#186)

* feat: inherit sparse-checkout in new worktrees

When creating a new worktree from one with sparse-checkout enabled,
the new worktree inherits the cone pattern automatically. Controlled
by gtr.sparse.inherit config (default on) and --sparse/--no-sparse
flags. Adds reusable helpers for sparse-checkout replication.

* fix(sparse): address CodeRabbit review feedback on sparse-checkout inheritance

- Preserve slash-separated branch paths in _worktree_path_for_ref
- Allow fallback to top-level worktree when matching worktree is not sparse
- Add Git 2.25+ guard for sparse-checkout support with full checkout fallback
- Fix non-cone mode to use init --no-cone (git defaults to cone mode)
- Improve error handling: failed sparse inheritance now falls back to full
  checkout and hard-errors if that fails, instead of leaving --no-checkout
  worktree empty
- Add tests for slash refs, non-cone inheritance, and sparse config precedence

* fix: harden sparse-checkout inheritance

* fix: support pre-2.20 config lookup

* fix: align sparse sources with git refs

---------

Co-authored-by: Tom Elizaga <tom.elizaga@gmail.com>

* Add PR worktree checkout command (coderabbitai#187)

* feat: add pull request worktree command

Assisted-by: pi:gpt-5.5
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>

* fix: make pr worktrees gh-aware

Assisted-by: pi:gpt-5.5
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>

* fix: harden pr worktree checkout

Assisted-by: pi:gpt-5.5
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>

* fix: address pr review feedback

Assisted-by: pi:gpt-5.5
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>

---------

Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Co-authored-by: Tom Elizaga <tom.elizaga@gmail.com>

* Run CI on fork pull requests (coderabbitai#185)

* Run CI on fork pull requests

* fix(ci): minimize fork pull request permissions

* chore: prepare v2.9.0 release

* feat: add machine-readable worktree creation for agents (coderabbitai#192)

Adds stable porcelain output and hook disposition reporting for shell-native agent integrations, with tests and documentation.

* chore: prepare v2.10.0 release

* perf: avoid per-worktree path resolution in list

* fix: complete v2.10 integration artifacts

---------

Co-authored-by: Tom Elizaga <tom.elizaga@gmail.com>
Co-authored-by: scarf <greenscarf005@gmail.com>
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Co-authored-by: Adam Wettreich <80975389+adamwett@users.noreply.github.com>
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.

1 participant