Skip to content

fix(cli): task-setup uses --path-format=absolute for git-common-dir#900

Merged
buremba merged 1 commit into
mainfrom
fix/task-setup-absolute-path
May 19, 2026
Merged

fix(cli): task-setup uses --path-format=absolute for git-common-dir#900
buremba merged 1 commit into
mainfrom
fix/task-setup-absolute-path

Conversation

@buremba
Copy link
Copy Markdown
Member

@buremba buremba commented May 19, 2026

Summary

Follow-up to #899. The previous fix called git rev-parse --git-common-dir without forcing absolute output. From inside a checkout, git returns a path relative to its cwd (../.git), and dirname of that resolves against whatever directory the caller happens to be in. Net result:

cd ~/Code/lobu                    # main repo
make task-setup NAME=foo
# resolves repo to /Users/burakemre/Code   ← parent of lobu, wrong!
# worktree created at /Users/burakemre/Code/.claude/worktrees/foo

Fix

Pass --path-format=absolute so git always returns the full path (e.g. /Users/burakemre/Code/lobu/.git). dirname of an absolute path is invariant to cwd.

-repo="$(cd "$(dirname "$(git -C "$script_dir" rev-parse --git-common-dir)")" && pwd)"
+repo="$(dirname "$(git -C "$script_dir" rev-parse --path-format=absolute --git-common-dir)")"

Verification

from main:      /Users/burakemre/Code/lobu  ✓
from worktree:  /Users/burakemre/Code/lobu  ✓

Caught while validating #899 — same logic but two cwds wrong.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed incorrect worktree placement when the setup script is invoked from within an existing worktree.

Review Change Stack

The previous fix (#899) called `git rev-parse --git-common-dir` without
forcing absolute output. Without that, git returns a path relative to its
cwd ("../.git"), and `dirname` of that resolves against whatever the
caller's cwd happens to be — so running `make task-setup` from the main
repo landed worktrees at /Users/burakemre/Code/.claude/worktrees/<name>/
(parent of the lobu checkout) instead of /Users/burakemre/Code/lobu/.claude/worktrees/<name>/.

Fix: pass `--path-format=absolute` so git always returns the full path.
`dirname` of an absolute /.../lobu/.git is reliably the main checkout.

Verified by hand:
  from main:      /Users/burakemre/Code/lobu
  from worktree:  /Users/burakemre/Code/lobu
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ca8be538-98cc-42fc-869a-06f49562a9e5

📥 Commits

Reviewing files that changed from the base of the PR and between 8e26abd and 6baac7e.

📒 Files selected for processing (1)
  • scripts/task-setup.sh

📝 Walkthrough

Walkthrough

The script now resolves the repo path using git rev-parse --path-format=absolute --git-common-dir followed by dirname, replacing the previous cd ... && pwd approach. This ensures the computed worktree target path resolution is independent of the caller's current working directory, preventing nested or incorrect worktree placement when invoked from within an existing worktree.

Changes

Worktree Path Resolution

Layer / File(s) Summary
Repo path resolution using git rev-parse
scripts/task-setup.sh
The repo path calculation is changed from a relative cd ... && pwd method to an absolute git rev-parse --path-format=absolute --git-common-dir approach, making it invariant to the caller's current worktree context.

🎯 2 (Simple) | ⏱️ ~5 minutes

🐰 A script lost in worktree tangles, now hops straight home with git's absolute gaze—no more nested spirals, just one true way! 🎯✨

✨ 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/task-setup-absolute-path

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

@buremba buremba merged commit f200751 into main May 19, 2026
19 of 20 checks passed
@buremba buremba deleted the fix/task-setup-absolute-path branch May 19, 2026 00:56
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

buremba added a commit that referenced this pull request May 19, 2026
…et route + SPA copy (#909)

* feat(server,scripts): local-first polish — magic-link gating, task-use bug, no_user_yet route

Five small gaps from the post-passkey audit, bundled per @burak's
request to ship together.

Server changes:

1. auth/config.ts: magic-link is now hidden when RESEND_API_KEY is
   unset, regardless of NODE_ENV. Previously `magicLink: hasValue(RESEND_API_KEY) || !isProduction`
   rendered the "Send me a magic link" button in dev — clicking it logged
   the URL to server stdout but didn't email anything. Operators staring
   at their inbox never found it. Now `magicLink: hasValue(env.RESEND_API_KEY)`
   — visible exactly when delivery actually works.

2. auth/routes.ts /api/local-init: the no_user_yet response's signup_url
   was "/sign-up", but Owletto's SPA routes signup via /auth/sign-up
   (the /auth/$pathname.tsx shim → /auth/login?intent=sign-up). Bare
   /sign-up fell into the $owner catch-all and looped through the login
   redirect. Codex caught this on the polish PR's review. Fixed to
   "/auth/sign-up".

Scripts:

3. task-use.sh: same $script_dir/.. bug fixed in task-setup.sh by
   PR #900. Without it, running task-use from inside a worktree
   retargets the chrome/mac symlinks at nested paths inside the
   calling worktree instead of the main checkout. Fix is the
   identical one-liner: `git rev-parse --path-format=absolute --git-common-dir`.

Submodule bump:

4. packages/owletto → 19221e9 (lobu-ai/owletto#191):
   - login.tsx branches copy on singleUserMode + auto-enrolls a passkey
     after first signup.
   - AppState.swift handles no_user_yet by opening the browser at the
     signup URL (using URL APIs, not string concat).

Verified:
- make typecheck clean
- bun test packages/server/src/__tests__/unit — 201 pass
- xcodebuild Owletto Debug — BUILD SUCCEEDED
- Codex reviewed; caught the /sign-up route mismatch + unsafe URL
  concat; both fixed before push.

* chore(submodule): bump owletto to 2b74ac24ca3a98ac5193cfd0b7f106e6fcded0ce (polish merged)
buremba added a commit that referenced this pull request May 19, 2026
… PORT (#912)

Three small dev-script fixes shaped by codex review of the worktree workflow.

- task-clean.sh repo resolution: invoking from inside a worktree resolved
  $repo to that worktree (not the main checkout), so the worktree_dir +
  branch deletion paths targeted the wrong place. Switch to
  `git rev-parse --git-common-dir --path-format=absolute`, matching the
  fix task-setup.sh (#900) and task-use.sh already use.
- task-clean.sh: warn when `lobu context rm` fails or when the CLI isn't
  on PATH, mirroring task-setup.sh:188's symmetry. Silent failure left
  stale context entries after a clean.
- task-use.sh: drop the active/mac symlink. The Mac menubar reads
  ~/.config/lobu/config.json on every popover expand and shows each
  context's apiUrl independently (AppState.swift:456 refreshContexts) —
  per-worktree contexts already appear in the picker. Devs open Xcode at
  the worktree's packages/owletto/apps/mac directly. The remaining Chrome
  symlink is the only one task-use manages now.
- task-use.sh: read PORT from the worktree's .env.local and print it in
  the success message. The Chrome ext's gateway URL (sidepanel "Server
  URL" → chrome.storage.local) and the source symlink are independent
  switches; surfacing PORT every invocation makes the "still talking to
  the old worktree's gateway" footgun visible.

Tested locally: ran `bash scripts/task-use.sh task-script-fixes` end-to-end
inside this worktree; chrome symlink retargets, PORT (8789) appears in
the reminder.
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