-
Notifications
You must be signed in to change notification settings - Fork 1
Configure Codex managed worktrees #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| version = 1 | ||
| name = "Stuff" | ||
|
|
||
| [setup] | ||
| script = ''' | ||
| echo "error: Stuff worktree setup is supported on macOS and Linux only" >&2 | ||
| exit 1 | ||
| ''' | ||
|
|
||
| [setup.darwin] | ||
| script = "./worktree --check-main && ./ide --bootstrap --no-open" | ||
|
|
||
| [setup.linux] | ||
| script = "./worktree --check-main && ./.cursor/install.sh" | ||
|
|
||
| [cleanup] | ||
| script = "" | ||
|
|
||
| [cleanup.darwin] | ||
| script = "./simulator --delete" | ||
|
|
||
| [[actions]] | ||
| name = "Update to latest main" | ||
| icon = "run" | ||
| command = "./worktree --update-main" | ||
|
|
||
| [[actions]] | ||
| name = "Regenerate project" | ||
| icon = "tool" | ||
| command = "./ide --no-open" | ||
| platform = "darwin" | ||
|
|
||
| [[actions]] | ||
| name = "Test affected" | ||
| icon = "test" | ||
| command = "./test" | ||
| platform = "darwin" | ||
|
|
||
| [[actions]] | ||
| name = "Lint formatting" | ||
| icon = "test" | ||
| command = "./swiftformat --lint" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Preserve the machine-local signing choice in Codex-managed worktrees. | ||
| .mise.local.toml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -141,6 +141,12 @@ EOF | |
| exit 1 | ||
| fi | ||
|
|
||
| # Every clone and worktree has a distinct config path, and mise refuses to | ||
| # read an untrusted .mise.toml. Running this explicit bootstrap is the trust | ||
| # boundary, so make fresh checkouts usable without a separate manual step. | ||
| echo "==> mise trust" | ||
| "$MISE" trust | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Reviewer note: this intentionally treats an explicit ./ide --bootstrap invocation as the mise trust boundary. Plain ./ide still never trusts a previously unseen checkout path. |
||
|
|
||
| # Install the pinned tools (Tuist, SwiftFormat, Ruby) from .mise.toml. | ||
| echo "==> mise install" | ||
| "$MISE" install | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| cat <<'EOF' | ||
| Usage: ./worktree --check-main | --update-main | ||
|
|
||
| Checks whether this checkout contains the latest origin/main, or safely | ||
| fast-forwards a checkout that is directly behind it. | ||
|
|
||
| Options: | ||
| --check-main Fetch origin/main and warn when HEAD does not contain it. | ||
| Never changes HEAD or the working tree; a fetch failure warns | ||
| without blocking worktree setup. | ||
| --update-main Fetch origin/main and fast-forward only when HEAD is its | ||
| ancestor. Refuses divergent history. | ||
| -h, --help Show this help. | ||
| EOF | ||
| } | ||
|
|
||
| if [ "$#" -ne 1 ]; then | ||
| usage >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| mode="$1" | ||
| main_ref="refs/remotes/origin/main" | ||
|
|
||
| fetch_main() { | ||
| git fetch --quiet origin '+refs/heads/main:refs/remotes/origin/main' | ||
| } | ||
|
|
||
| short_commit() { | ||
| git rev-parse --short=8 "$1" | ||
| } | ||
|
|
||
| case "$mode" in | ||
| --check-main) | ||
| if ! fetch_main; then | ||
| echo "warning: could not fetch origin/main; main freshness is unknown" >&2 | ||
| exit 0 | ||
| fi | ||
|
|
||
| if git merge-base --is-ancestor "$main_ref" HEAD; then | ||
| echo "==> Checkout contains latest origin/main ($(short_commit "$main_ref"))" | ||
| else | ||
| echo "warning: checkout $(short_commit HEAD) does not contain latest origin/main ($(short_commit "$main_ref"))" >&2 | ||
| echo "warning: run the 'Update to latest main' action if this checkout should be a current main checkout" >&2 | ||
| fi | ||
| ;; | ||
| --update-main) | ||
| echo "==> Fetching origin/main" | ||
| fetch_main | ||
|
|
||
| if git merge-base --is-ancestor "$main_ref" HEAD; then | ||
| echo "==> Checkout already contains latest origin/main ($(short_commit "$main_ref"))" | ||
| exit 0 | ||
| fi | ||
|
|
||
| if ! git merge-base --is-ancestor HEAD "$main_ref"; then | ||
| echo "error: checkout $(short_commit HEAD) has diverged from origin/main ($(short_commit "$main_ref")); refusing to rewrite or merge feature history" >&2 | ||
| echo "error: merge or rebase origin/main explicitly instead" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| git merge --ff-only "$main_ref" | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Reviewer note: the action reaches this fast-forward only after proving HEAD is an ancestor of origin/main. A feature branch that already contains latest main is a no-op; divergent history is refused and left for an explicit merge or rebase. |
||
| echo "==> Fast-forwarded checkout to latest origin/main ($(short_commit HEAD))" | ||
| ;; | ||
| -h|--help) | ||
| usage | ||
| ;; | ||
| *) | ||
| echo "error: unknown option '$mode'" >&2 | ||
| usage >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewer note: the exception is deliberately limited to pure documentation and comments, and skipped checks must be recorded. Semantic changes to configuration, scripts, generator inputs, executable examples, or rendered copy remain behavior-bearing and still require the narrowest applicable validation.