Skip to content

Address review of projects-as-worktree (#34): git-repo check, doc comments, docs#36

Merged
cloudmanic merged 1 commit into
mainfrom
review-fixes-projects-worktree
Jul 5, 2026
Merged

Address review of projects-as-worktree (#34): git-repo check, doc comments, docs#36
cloudmanic merged 1 commit into
mainfrom
review-fixes-projects-worktree

Conversation

@cloudmanic

Copy link
Copy Markdown
Owner

Follow-up to #34 (thanks again @dvic!) addressing the review notes on the ctrl+g "open highlighted project as a git worktree" feature.

Changes

Correctness / UX

  • Removed dead code: the !filepath.IsAbs(dir) check in openProjectAsWorktree could never be true — filepath.Abs already returns an absolute path (or an error, already handled).
  • Friendlier error for non-repos: openProjectAsWorktree now pre-checks that the directory is inside a git work tree via isInsideGitWorkTree. ctrl+g on a project whose working_dir isn't a git repo now returns not a git repository: … (opening as a worktree requires one) instead of herdr's raw worktree_create_failed. The check defers to herdr when git itself can't run, so a missing git never wrongly blocks.

Docs / consistency

  • Doc comments added to the new functions/methods that lacked them (worktreeCreate, PluginConfig, configFilePath, loadPluginConfig, openProjectAsWorktree, resolveWorktreeBranch, updateBranch, promptWorktreeBranch, branchView), matching the rest of the codebase.
  • README clarified: opening a project as a worktree fills its tabs from a matching worktrees/ worktree auto-layoutnot the project's own [[tabs]] — and opens bare without one. This coupling was previously invisible.
  • Fixed stale copied-header dates on the new files.

Tests

  • projects_test.go covers isInsideGitWorkTree (plain dir vs git init).

Verification

go build, go test, and go vet all pass; the new git check test does a real git init and passes.

Note: the "tabs come from the worktree layout, not the project" behavior is documented rather than changed — falling back to the project's own tabs would risk double-applying against the worktree.created event handler. Happy to add that fallback separately if we want ctrl+g to work standalone without a worktrees/ file.

Follow-ups from reviewing the ctrl+g "open project as a git worktree" feature:

- projects.go: drop the dead filepath.IsAbs check (Abs already returns an
  absolute path), and pre-check that the directory is inside a git work tree so
  ctrl+g on a non-repo project gives a clear "not a git repository" error instead
  of herdr's raw worktree_create_failed. The check defers to herdr when git
  itself can't run.
- Add doc comments to the new functions/methods that were missing them
  (worktreeCreate, PluginConfig, configFilePath, loadPluginConfig,
  openProjectAsWorktree, resolveWorktreeBranch, updateBranch,
  promptWorktreeBranch, branchView), matching the rest of the codebase.
- README: clarify that opening a project as a worktree fills its tabs from a
  matching worktrees/ layout, NOT the project's own [[tabs]] — and opens bare
  without one.
- Fix stale copied-header dates on the new files.
- projects_test.go: cover isInsideGitWorkTree.
@cloudmanic cloudmanic merged commit f9b2530 into main Jul 5, 2026
2 checks passed
@cloudmanic cloudmanic deleted the review-fixes-projects-worktree branch July 5, 2026 16:20
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