Skip to content

Conversation

@helizaga
Copy link
Collaborator

@helizaga helizaga commented Dec 27, 2025

Summary by CodeRabbit

  • New Features

    • Added an automated installer script with platform-aware placement and post-install verification
    • Added interactive "Manual installation options" with platform-specific commands and PATH guidance
  • Documentation

    • Reworded Quick Start install instructions for clarity
    • Reformatted and expanded Hook execution order reference with explicit timing and use cases
    • Expanded Troubleshooting with concrete error-resolution steps, worktree fixes, and remediation guidance

✏️ Tip: You can customize this high-level summary in your review settings.

@helizaga helizaga requested a review from NatoBoram as a code owner December 27, 2025 09:26
@coderabbitai
Copy link

coderabbitai bot commented Dec 27, 2025

Walkthrough

Adds a platform-aware install.sh that creates and verifies a symlink for git-gtr, plus expanded README manual-install options and troubleshooting (including "git: 'gtr' is not a git command" and worktree creation guidance).

Changes

Cohort / File(s) Summary
Documentation
README.md
Rewrote Quick Start install heading; added interactive "Manual installation options" with platform-specific commands (macOS Apple Silicon, macOS Intel / Linux, user-local), clarified PATH guidance; replaced hook table with an aligned table including headers and updated timing/use-cases; added troubleshooting subsections for git: 'gtr' is not a git command and Worktree Creation Fails, plus extended diagnostic commands and remediation steps.
Installer Script
install.sh
New platform-detecting installer that chooses install dir (Homebrew bin, /usr/local/bin, or ~/bin), verifies git-gtr binary presence, creates/updates symlink (uses sudo when needed), handles existing symlinks/files, emits colored logs, and runs post-install verification (verify_installation).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant install.sh as Installer
  participant FS as Filesystem
  participant Shell as Shell/PATH
  participant Git as git-gtr

  Note over User,Installer: user runs ./install.sh
  User->>Installer: execute script
  Installer->>Installer: detect platform & select target dir
  Installer->>FS: check script-local git-gtr binary
  alt binary missing
    Installer->>User: error & exit
  else binary present
    Installer->>FS: ensure target dir exists (mkdir / sudo if needed)
    Installer->>FS: check existing target path
    alt existing symlink -> same target
      Installer->>User: report already installed
    else existing symlink -> different
      Installer->>FS: replace symlink (warn)
    else non-symlink file
      Installer->>User: error & exit
    end
    Installer->>FS: create symlink (may invoke sudo)
    Installer->>Shell: verify PATH contains target dir
    Installer->>Git: run `git gtr version` to validate
    alt success
      Installer->>User: success message + usage hints
    else failure
      Installer->>User: warning + PATH remediation steps
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 A tiny link I made,

across machines it hopped,
with README lights to guide,
the install path now popped,
git-gtr leaps — all set, let's stop!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: adding an install script with platform detection logic, which matches the primary content of install.sh.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/install-path-detection

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
install.sh (2)

60-82: Remove unused platform parameter.

The platform parameter is declared but never used in the function body. The installation directory selection logic doesn't vary by platform, so this parameter is unnecessary.

🔎 Proposed fix
 # Find the best installation directory
 find_install_dir() {
-  local platform="$1"
-
   # Option 1: Homebrew bin (if Homebrew is installed)
   if command -v brew >/dev/null 2>&1; then

Also update the caller at line 109:

-  install_dir="$(find_install_dir "$platform")"
+  install_dir="$(find_install_dir)"

156-165: Consider detecting the user's shell for targeted guidance.

The script assumes zsh or bash by suggesting ~/.zshrc or ~/.bashrc. While these cover the majority of users, you could detect the current shell via $SHELL and provide shell-specific instructions (e.g., ~/.config/fish/config.fish for Fish users).

🔎 Example enhancement
if ! in_path "$install_dir"; then
  log_warn "$install_dir is not in your PATH"
  echo
  
  local shell_config
  case "$SHELL" in
    */zsh)
      shell_config="~/.zshrc"
      ;;
    */bash)
      shell_config="~/.bashrc"
      ;;
    */fish)
      shell_config="~/.config/fish/config.fish"
      echo "Add this to $shell_config:"
      echo "  set -gx PATH \"$install_dir\" \$PATH"
      return
      ;;
    *)
      shell_config="your shell configuration file (~/.zshrc or ~/.bashrc)"
      ;;
  esac
  
  echo "Add this to $shell_config:"
  echo
  echo "  export PATH=\"$install_dir:\$PATH\""
  echo
  echo "Then restart your terminal or run: source $shell_config"
  echo
fi
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 03ff84a and 072e764.

📒 Files selected for processing (2)
  • README.md
  • install.sh
🧰 Additional context used
📓 Path-based instructions (2)
**/*.sh

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.sh: Always quote paths to handle spaces and special characters; avoid unguarded globbing
Keep set -e active in shell scripts; ensure non-critical failures are guarded with command || true

**/*.sh: Use shebang #!/usr/bin/env bash (not /bin/bash or /bin/sh) for all shell scripts
Use snake_case naming for all functions and local variables in Bash scripts
Use UPPER_CASE naming for constants and environment variables in Bash scripts
Use 2-space indentation (no tabs) in all Bash scripts
Always quote variables and paths in Bash scripts (e.g., use "$var" not $var)
Check return codes and use || exit 1 or || return 1 for error handling in Bash scripts
Use local keyword for function-scoped variables in Bash scripts
Maintain POSIX-compatible Bash patterns targeting Bash 3.2+ compatibility
Git worktree operations must work cross-platform on macOS, Linux, and Windows Git Bash
All code must only use git and basic POSIX shell utilities - no external dependencies
Use set -e for error handling in Bash scripts where appropriate

Files:

  • install.sh
**/*.{bash,fish,sh}

📄 CodeRabbit inference engine (.github/instructions/sh.instructions.md)

**/*.{bash,fish,sh}: Bash 3.2+ compatible (macOS default), but 4.0+ features allowed where appropriate
Always quote variables: use "$var" not $var
Use function-scoped variables: local var="value"
Check return codes; functions return 1 on failure
Use snake_case for functions and variables, UPPER_CASE for constants
Prefer [ ] over [[ ]] for POSIX portability; use [[ only when needed
Always quote glob inputs; disable unintended globbing with set -f temporarily if required
Avoid associative arrays in shell scripts; use simple string/loop constructs for Bash 3.2+ compatibility
Avoid readarray and process substitution unsupported in older Bash
Debug with bash -x ./bin/gtr <cmd> or wrap suspicious blocks with set -x / set +x
Check function presence with declare -f create_worktree or declare -f resolve_target
Use stderr for variable inspection: echo "DEBUG var=$var" >&2 to keep stdout clean for command substitution
Keep dependencies minimal: only use git, sed, awk, find, grep; avoid jq/curl unless justified
Check availability of external commands before use when adding new tools
Use "${var}" for variable expansion; for line loops use while IFS= read -r line; do ... done to preserve spaces
Sanitize branch names via sanitize_branch_name function; do NOT duplicate logic elsewhere
Everything is sourced at startup with set -e enabled; functions call each other directly; no subshells except for hooks and AI tools

Files:

  • install.sh
🔇 Additional comments (7)
install.sh (4)

1-15: LGTM! Clean setup following shell script guidelines.

The shebang, error handling with set -e, and UPPER_CASE constants all follow the coding guidelines correctly.


85-88: LGTM! Clean permission check.

The function correctly uses POSIX-compatible [ ] tests and proper variable quoting.


115-135: LGTM! Robust symlink handling.

The code correctly handles existing symlinks, uses || true to prevent premature exit with set -e, and appropriately uses sudo when needed. The distinction between symlinks and regular files is properly managed.


170-197: LGTM! Thorough installation verification with helpful guidance.

The function properly checks both PATH availability and functional operation of git gtr, provides clear success/warning messages, and offers actionable next steps. Variable usage and quoting follow guidelines correctly.

README.md (3)

24-57: LGTM! Clear installation instructions with proper shell practices.

The documentation correctly references the new install.sh script and provides platform-specific manual installation options. All command examples use proper quoting ("$(pwd)/bin/git-gtr") and the PATH export correctly escapes $PATH. The collapsible manual options section is a nice UX touch.


500-504: LGTM! Clear hook timing documentation.

The updated table clearly explains when each hook executes and typical use cases. The formatting is clean and easy to read.


723-747: LGTM! Comprehensive troubleshooting guidance with correct shell commands.

The troubleshooting section provides practical verification steps that follow shell best practices:

  • Proper use of 2>/dev/null for silent fallbacks
  • Clean PATH inspection with tr ':' '\n'
  • PATH export guidance matches the install.sh script

The debugging workflow is logical and should help users quickly identify installation issues.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
install.sh (2)

36-39: Consider using grep -F for literal path matching.

The current grep -qx treats the path as a regex pattern. If a directory path contains special regex characters, it could cause false matches or failures. Use grep -Fqx for fixed/literal string matching.

🔎 Proposed fix
 in_path() {
-  echo "$PATH" | tr ':' '\n' | grep -qx "$1"
+  echo "$PATH" | tr ':' '\n' | grep -Fqx "$1"
 }

89-111: LGTM! Clean initial setup logic.

The validation, platform detection, and directory selection logic are sound. All variables use proper scoping and quoting.

Optional: Consider checking executability.

Line 94 could use -x in addition to -f to verify that git-gtr is executable, catching configuration issues earlier.

🔎 Optional improvement
-  if [ ! -f "$GIT_GTR_PATH" ]; then
+  if [ ! -f "$GIT_GTR_PATH" ] || [ ! -x "$GIT_GTR_PATH" ]; then
     log_error "Could not find git-gtr at: $GIT_GTR_PATH"
+    log_error "Make sure the file exists and is executable."
     log_error "Please run this script from the git-worktree-runner directory."
     exit 1
   fi
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 072e764 and f88ebb1.

📒 Files selected for processing (1)
  • install.sh
🧰 Additional context used
📓 Path-based instructions (2)
**/*.sh

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.sh: Always quote paths to handle spaces and special characters; avoid unguarded globbing
Keep set -e active in shell scripts; ensure non-critical failures are guarded with command || true

**/*.sh: Use shebang #!/usr/bin/env bash (not /bin/bash or /bin/sh) for all shell scripts
Use snake_case naming for all functions and local variables in Bash scripts
Use UPPER_CASE naming for constants and environment variables in Bash scripts
Use 2-space indentation (no tabs) in all Bash scripts
Always quote variables and paths in Bash scripts (e.g., use "$var" not $var)
Check return codes and use || exit 1 or || return 1 for error handling in Bash scripts
Use local keyword for function-scoped variables in Bash scripts
Maintain POSIX-compatible Bash patterns targeting Bash 3.2+ compatibility
Git worktree operations must work cross-platform on macOS, Linux, and Windows Git Bash
All code must only use git and basic POSIX shell utilities - no external dependencies
Use set -e for error handling in Bash scripts where appropriate

Files:

  • install.sh
**/*.{bash,fish,sh}

📄 CodeRabbit inference engine (.github/instructions/sh.instructions.md)

**/*.{bash,fish,sh}: Bash 3.2+ compatible (macOS default), but 4.0+ features allowed where appropriate
Always quote variables: use "$var" not $var
Use function-scoped variables: local var="value"
Check return codes; functions return 1 on failure
Use snake_case for functions and variables, UPPER_CASE for constants
Prefer [ ] over [[ ]] for POSIX portability; use [[ only when needed
Always quote glob inputs; disable unintended globbing with set -f temporarily if required
Avoid associative arrays in shell scripts; use simple string/loop constructs for Bash 3.2+ compatibility
Avoid readarray and process substitution unsupported in older Bash
Debug with bash -x ./bin/gtr <cmd> or wrap suspicious blocks with set -x / set +x
Check function presence with declare -f create_worktree or declare -f resolve_target
Use stderr for variable inspection: echo "DEBUG var=$var" >&2 to keep stdout clean for command substitution
Keep dependencies minimal: only use git, sed, awk, find, grep; avoid jq/curl unless justified
Check availability of external commands before use when adding new tools
Use "${var}" for variable expansion; for line loops use while IFS= read -r line; do ... done to preserve spaces
Sanitize branch names via sanitize_branch_name function; do NOT duplicate logic elsewhere
Everything is sourced at startup with set -e enabled; functions call each other directly; no subshells except for hooks and AI tools

Files:

  • install.sh
🔇 Additional comments (9)
install.sh (9)

1-18: LGTM! Excellent setup.

The shebang, error handling, color constants, and path detection follow all coding guidelines correctly. Variables are properly quoted, and ${BASH_SOURCE[0]} is the right approach for locating the script directory.


20-34: LGTM! Clean logging abstraction.

The logging functions follow snake_case naming conventions and properly quote all variables. The color-coded output will improve user experience.


41-57: LGTM! Comprehensive platform detection.

The platform detection correctly handles macOS, Linux, and Windows (Git Bash environments: MINGW/MSYS/CYGWIN), with a sensible fallback for unknown platforms.


59-80: LGTM! Well-designed installation directory selection.

The priority order (Homebrew → /usr/local/bin~/bin) is sensible, and the logic properly validates directory existence and permissions before selection. The fallback to ~/bin ensures installation can proceed without elevated privileges in most cases.


82-86: LGTM! Correct sudo detection logic.

The function correctly identifies when elevated privileges are needed by checking if the directory exists but is not writable. Proper use of local variables and quoting.


112-133: LGTM! Robust handling of existing installations.

The logic correctly handles three scenarios: symlink to correct target (already installed), symlink to wrong target (replace), and non-symlink file (error with clear guidance). Proper use of || true for readlink error handling with set -e active, and conditional sudo usage.


152-166: LGTM! Clear PATH configuration guidance.

The PATH check and user instructions are well-designed. The \$PATH is properly escaped in the echo statement so users can copy-paste the export command directly. Good UX to call verify_installation at the end.


168-195: LGTM! Comprehensive installation verification.

The verification logic properly checks both git-gtr availability and git gtr command execution, with helpful success messages and troubleshooting guidance. Good use of command -v for POSIX compatibility.


197-197: LGTM! Proper script execution.

Correctly invokes the main function with properly quoted arguments.

Comment on lines +135 to +151
# Create directory if needed
if [ ! -d "$install_dir" ]; then
log_info "Creating directory: $install_dir"
mkdir -p "$install_dir"
fi

# Create symlink
if needs_sudo "$install_dir"; then
log_info "Creating symlink (requires sudo)..."
sudo ln -s "$GIT_GTR_PATH" "$symlink_path"
else
log_info "Creating symlink..."
ln -s "$GIT_GTR_PATH" "$symlink_path"
fi

log_success "Symlink created: $symlink_path -> $GIT_GTR_PATH"
echo
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, let's run the test script to check platform capabilities
#!/bin/bash
echo "=== Platform Information ==="
uname -s
echo

echo "=== Checking sudo availability ==="
if command -v sudo >/dev/null 2>&1; then
  echo "sudo: available"
  sudo -V | head -n1
else
  echo "sudo: NOT available"
fi
echo

echo "=== Checking symlink support ==="
test_dir=$(mktemp -d)
test_file="$test_dir/test_target"
test_link="$test_dir/test_link"

echo "test" > "$test_file"
if ln -s "$test_file" "$test_link" 2>/dev/null; then
  echo "Symlink creation: SUCCESS"
  if [ -L "$test_link" ]; then
    echo "Symlink verification: SUCCESS"
    target=$(readlink "$test_link" 2>/dev/null || echo "readlink failed")
    echo "readlink result: $target"
  else
    echo "Symlink verification: FAILED"
  fi
else
  echo "Symlink creation: FAILED"
fi

rm -rf "$test_dir"

Repository: coderabbitai/git-worktree-runner

Length of output: 305


🏁 Script executed:

# Locate and examine install.sh
fd -t f "install.sh" | head -5

Repository: coderabbitai/git-worktree-runner

Length of output: 86


🏁 Script executed:

# Find the needs_sudo function in install.sh
rg -n "needs_sudo" --type sh -A 5 -B 1

Repository: coderabbitai/git-worktree-runner

Length of output: 942


🏁 Script executed:

# Get context around lines 135-151 in install.sh
fd -t f "install.sh" -x wc -l {} \; 2>/dev/null | head -1

Repository: coderabbitai/git-worktree-runner

Length of output: 92


🏁 Script executed:

# Read the install.sh file to examine the needs_sudo function and context
fd -t f "install.sh" -x cat -n {} \; 2>/dev/null | sed -n '110,160p'

Repository: coderabbitai/git-worktree-runner

Length of output: 1995


🏁 Script executed:

# Check find_install_dir function to understand how install_dir is determined
rg -n "find_install_dir" --type sh -A 20 -B 2

Repository: coderabbitai/git-worktree-runner

Length of output: 2074


🏁 Script executed:

# Look for Windows-specific handling or documentation
rg -i "windows|msys|git.bash|cygwin" --type sh --type md

Repository: coderabbitai/git-worktree-runner

Length of output: 1534


🏁 Script executed:

# Check if there's a README or docs mentioning platform support
fd -t f "README|CONTRIBUTING|INSTALL|docs" -i | head -10

Repository: coderabbitai/git-worktree-runner

Length of output: 112


🏁 Script executed:

# Examine what GIT_GTR_PATH is and how install_dir is constructed
rg -n "GIT_GTR_PATH|symlink_path|install_dir" --type sh -B 1 | head -40

Repository: coderabbitai/git-worktree-runner

Length of output: 1757


Critical Windows Git Bash compatibility issue: symlink creation and sudo handling will fail.

The install script lacks Windows-specific handling for ln -s and sudo, despite Windows Git Bash being explicitly listed as a supported platform in README.md.

Specific problems:

  • sudo command does not exist in Windows Git Bash; when needs_sudo returns true, sudo ln -s will fail with "command not found"
  • ln -s on Windows Git Bash requires Developer Mode or admin privileges; without them, it fails silently
  • mkdir -p at line 138 attempts directory creation without sudo, which will fail if installing to a system directory without admin rights
  • No error handling or platform detection to guide users on Windows

The code should either detect Windows and provide platform-specific installation instructions, skip symlink creation on Windows with alternative PATH setup guidance, or add explicit error handling for symlink creation failures with helpful messages for Windows users.

🤖 Prompt for AI Agents
In install.sh around lines 135-151, the symlink and sudo logic is incompatible
with Windows Git Bash and lacks error handling; update the script to detect
Windows/MSYS/CYGWIN (via uname or $MSYSTEM), branch: on Windows avoid using sudo
and skip ln -s (or attempt ln -s but check for failure), on non-Windows use
needs_sudo to run mkdir/symlink under sudo when required; ensure mkdir uses sudo
when installing to protected dirs, wrap ln -s and mkdir calls with immediate
exit-on-error checks and user-friendly messages that explain Windows
alternatives (add PATH update instructions or suggest running with
Administrator/Developer Mode or copying the binary), and log actionable guidance
when symlink creation fails on Windows instead of letting the commands silently
fail.

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