Skip to content

Conversation

@helizaga
Copy link
Collaborator

@helizaga helizaga commented Dec 27, 2025

Summary by CodeRabbit

  • New Features

    • Added an interactive, platform-aware installer with symlink handling, verification, and Windows manual guidance
    • Added interactive "Manual installation options" with platform-specific commands and PATH hints
  • Documentation

    • Explicit install execution step added to install docs
    • Reworked hook execution order table for clarity
    • Expanded Troubleshooting with concrete remediation and environment-validation steps (PATH/symlink checks, worktree fixes, verification commands)

✏️ 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 a symlink for git-gtr, verifies the installation and PATH, and updates README.md to run ./install.sh, provide manual platform-specific install options, and expand Troubleshooting with PATH/symlink and worktree remediation.

Changes

Cohort / File(s) Summary
Documentation
README.md
Replaced quick install with Install invoking ./install.sh; added "Manual installation options" for macOS (Apple Silicon), macOS (Intel) / Linux, and user-local installs; reworked Hook execution order header/alignment; expanded Troubleshooting with git: 'gtr' is not a git command, PATH/symlink checks, worktree failure guidance, and remediation examples.
Installer Script
install.sh
New script: detects platform, chooses install dir (Homebrew bin, /usr/local/bin, or ~/bin), validates local git-gtr binary, creates install dir (uses sudo when needed), inspects/handles existing symlinks or conflicting files, creates symlink, warns if install dir not in PATH, and verifies installation via git gtr version with colored logging and a verification flow.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant I as install.sh
  participant FS as Filesystem
  participant SH as Shell / PATH
  participant G as git (git-gtr)

  U->>I: run `./install.sh`
  I->>I: detect OS & choose install_dir
  I->>FS: verify local `git-gtr` binary exists
  alt binary missing
    I->>U: error & exit
  else
    I->>FS: ensure install_dir exists (mkdir or sudo)
    I->>FS: inspect `install_dir/git-gtr`
    alt existing symlink -> same target
      I->>U: report already installed
    else existing symlink -> different target
      I->>U: warn, replace symlink
      I->>FS: update symlink
    else non-symlink file present
      I->>U: error & exit
    end
    I->>FS: create symlink (may use sudo)
    I->>SH: check install_dir in PATH
    I->>G: run `git gtr version`
    alt verification success
      I->>U: success message
    else
      I->>U: warning + PATH remediation steps
    end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped a link from burrow to bin,

a little script to invite you in;
README shows the paths to roam,
symlinks snug to call a home,
install done — I twitch, and grin.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% 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 capabilities. It aligns with the primary modifications in 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

📜 Recent 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 4ea3bb8 and 5e39dad.

📒 Files selected for processing (1)
  • install.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • install.sh

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.

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 (1)
README.md (1)

723-747: Troubleshooting section is practical and covers the most likely root cause.

The diagnostic steps (symlink presence, PATH inclusion, which verification) effectively narrow down the issue. The remediation paths are clear and align with the install options documented above.

Optional refinement: Line 729 checks two potential symlink locations but doesn't indicate which is the "default" or expected location. Consider adding a note like "If neither exists, re-run ./install.sh to create the symlink in the platform-appropriate location." This would make the connection between diagnosis and remediation clearer.

📜 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 f88ebb1 and d2b2831.

📒 Files selected for processing (1)
  • README.md
🧰 Additional context used
📓 Path-based instructions (1)
README.md

📄 CodeRabbit inference engine (CLAUDE.md)

README.md: Update README.md with installation/setup instructions when adding a new editor adapter
Update README.md with installation instructions and use cases when adding a new AI tool adapter

Files:

  • README.md
🔇 Additional comments (2)
README.md (2)

32-57: Manual installation options are technically sound and cover key scenarios.

The three fallback options (Homebrew, system-wide, user-local) are well-chosen and use correct symlink syntax. The PATH guidance for user-local install (lines 53–54) is particularly helpful.

Minor note: Lines 38, 45, and 52 all use "$(pwd)" to reference the bin directory. Ensure the README or install.sh notes that users must run these commands from the repository root, or consider using an explicit path in the documentation if install.sh handles this differently.


24-30: install.sh exists and implements platform detection, symlink creation, and verification as documented.

The script is properly implemented at the repository root and includes:

  • Platform detection via uname for macOS, Linux, and Windows (lines 42–57)
  • Symlink creation using ln -s with automatic sudo handling (lines 141–148)
  • Installation directory prioritization: Homebrew bin → /usr/local/bin~/bin (lines 60–80)
  • Verification steps checking PATH and running git gtr version (lines 168–195)
  • PATH guidance if the install directory is not in PATH (lines 154–162)

Minor note: The README's manual section distinguishes "macOS (Apple Silicon with Homebrew)" from "macOS (Intel) / Linux", but install.sh doesn't explicitly detect Apple Silicon vs Intel architecture—it simply tries Homebrew if installed, regardless of Mac architecture. This is more flexible in practice but differs from the documented distinction.

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 (1)
install.sh (1)

46-85: Excellent fix for the critical Windows compatibility issue!

The dedicated install_windows function successfully addresses the critical issue raised in the previous review by avoiding sudo and automatic symlink creation on Windows Git Bash. The manual guidance approach is the right solution.

However, consider these improvements to the Windows guidance:

Line 67 - mklink path format: The fallback || echo "$GIT_GTR_PATH" will output a Unix-style path if cygpath fails, but mklink requires Windows-style paths. Consider adding a note that the user may need to adjust the path format.

Line 73 - copy destination: The suggestion to copy to /usr/bin/git-gtr might require admin privileges on Windows. Consider suggesting ~/bin or clarifying that this requires elevated permissions.

🔎 Proposed improvements
   echo "  Open an Administrator Command Prompt and run:"
   echo
-  echo "    mklink \"C:\\Program Files\\Git\\usr\\bin\\git-gtr\" \"$(cygpath -w "$GIT_GTR_PATH" 2>/dev/null || echo "$GIT_GTR_PATH")\""
+  echo "    mklink \"C:\\Program Files\\Git\\usr\\bin\\git-gtr\" \"$(cygpath -w "$GIT_GTR_PATH" 2>/dev/null || echo "[Windows-style path to $GIT_GTR_PATH]")\""
   echo
-  echo "  Option 3: Copy the script directly"
+  echo "  Option 3: Copy the script directly (requires admin)"
   echo "  ─────────────────────────────────────────────────────"
   echo "  Copy git-gtr to a directory already in your PATH:"
   echo
-  echo "    cp \"$GIT_GTR_PATH\" /usr/bin/git-gtr"
+  echo "    cp \"$GIT_GTR_PATH\" ~/bin/git-gtr"
+  echo "    # OR to a system directory (requires admin):"
+  echo "    # cp \"$GIT_GTR_PATH\" /usr/bin/git-gtr"
   echo
📜 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 d2b2831 and 3c72efd.

📒 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 Bash scripts
Use snake_case naming for functions in Bash scripts
Use snake_case for local variables and UPPER_CASE for constants/environment variables in Bash scripts
Use 2-space indentation (no tabs) in Bash scripts
Always quote variables and paths in Bash scripts to prevent word splitting and globbing issues
Check return codes and use || exit 1 or || return 1 for error handling in Bash scripts
Use set -e for error handling in Bash scripts
Use local keyword for function-scoped variables in Bash scripts

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 (5)
install.sh (5)

1-19: LGTM! Clean setup following Bash best practices.

The shebang, error handling with set -e, color constants, and script directory detection all follow the coding guidelines correctly.


20-44: Well-implemented utility functions.

The logging helpers provide good user feedback, and in_path correctly uses grep -Fqx for exact PATH matching.


87-132: Solid platform detection and directory selection logic.

The three-tier fallback strategy in find_install_dir is well-designed:

  • Homebrew bin (if installed and writable)
  • /usr/local/bin (if exists and in PATH)
  • ~/bin (user-local fallback)

The needs_sudo function correctly identifies when elevated privileges are required, and the logic ensures that mkdir -p at line 190 only runs for directories that don't require sudo.


134-218: Robust installation logic with proper error handling.

The main installation flow correctly:

  • Validates the git-gtr binary exists before proceeding
  • Detects platform and routes to Windows-specific handling
  • Handles existing installations gracefully (idempotent)
  • Uses sudo only when necessary for protected directories
  • Provides helpful PATH setup guidance when needed

The early Windows exit (line 154) ensures that the Unix-specific symlink/sudo logic never executes on Windows platforms, fully resolving the critical issue from the previous review.


220-249: Thorough verification with helpful user guidance.

The verify_installation function provides valuable feedback by:

  • Checking if git-gtr is discoverable in PATH
  • Testing actual functionality with git gtr version
  • Displaying usage examples on successful installation
  • Gracefully handling partial installation states

The verification correctly handles command failures without triggering set -e exit (since they're in conditional statements), and provides actionable guidance when issues are detected.

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)

36-39: Quote the argument in grep command.

Per coding guidelines, always quote variables to prevent word splitting and globbing issues.

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

41-44: Unused function: is_windows is defined but never called.

The main function uses detect_platform directly and compares with "windows". This function can be removed to reduce dead code.

🔎 Proposed fix
-# Check if running on Windows (Git Bash, MSYS, Cygwin)
-is_windows() {
-  [ "$(detect_platform)" = "windows" ]
-}
-
📜 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 c7c7684 and 03be0d2.

📒 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 Bash scripts
Use snake_case naming for functions in Bash scripts
Use snake_case for local variables and UPPER_CASE for constants/environment variables in Bash scripts
Use 2-space indentation (no tabs) in Bash scripts
Always quote variables and paths in Bash scripts to prevent word splitting and globbing issues
Check return codes and use || exit 1 or || return 1 for error handling in Bash scripts
Use set -e for error handling in Bash scripts
Use local keyword for function-scoped variables in Bash scripts

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 (10)
install.sh (10)

1-18: LGTM!

Proper shebang, set -e for error handling, UPPER_CASE for constants, and correctly quoted path variables.


20-34: LGTM!

Logging functions follow snake_case convention and provide clear, colored output.


46-85: LGTM!

Windows-specific handling is well-designed: provides multiple installation options, uses cygpath with fallback, and verifies PATH status. This properly addresses the Windows compatibility concerns from previous reviews.


87-103: LGTM!

Clean platform detection with appropriate handling for macOS, Linux, and Windows variants (MINGW, MSYS, CYGWIN).


105-126: LGTM!

Sensible priority order: Homebrew bin (if writable) → /usr/local/bin (if in PATH) → ~/bin. The needs_sudo check later handles write permission requirements appropriately.


128-132: LGTM!

Correctly determines if sudo is needed based on directory existence and write permissions.


134-155: LGTM!

Clean entry point with proper validation: verifies git-gtr exists, detects platform, and handles Windows separately.


164-185: LGTM!

Robust symlink handling: detects existing symlinks, handles same/different targets appropriately, and errors gracefully when a non-symlink file blocks installation.


187-218: LGTM!

Directory creation is correctly scoped to ~/bin (since /usr/local/bin is only selected if it already exists). PATH warning with actionable guidance is helpful.


220-249: LGTM!

Thorough verification with clear feedback: confirms PATH availability, tests the actual command, and provides helpful next steps for both success and failure cases.

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 (1)
install.sh (1)

134-139: Consider adding executable permission check.

The script checks if git-gtr exists with -f, but doesn't verify it's executable with -x. If the file exists but lacks execute permission, installation appears to succeed but commands fail later.

Proposed improvement
   # Verify git-gtr exists
-  if [ ! -f "$GIT_GTR_PATH" ]; then
+  if [ ! -f "$GIT_GTR_PATH" ]; then
     log_error "Could not find git-gtr at: $GIT_GTR_PATH"
     log_error "Please run this script from the git-worktree-runner directory."
     exit 1
   fi
+
+  if [ ! -x "$GIT_GTR_PATH" ]; then
+    log_warn "git-gtr is not executable, fixing permissions..."
+    chmod +x "$GIT_GTR_PATH"
+  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 03be0d2 and 4ea3bb8.

📒 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 Bash scripts
Use snake_case naming for functions in Bash scripts
Use snake_case for local variables and UPPER_CASE for constants/environment variables in Bash scripts
Use 2-space indentation (no tabs) in Bash scripts
Always quote variables and paths in Bash scripts to prevent word splitting and globbing issues
Check return codes and use || exit 1 or || return 1 for error handling in Bash scripts
Use set -e for error handling in Bash scripts
Use local keyword for function-scoped variables in Bash scripts

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 (10)
install.sh (10)

1-18: LGTM!

The script setup follows all coding guidelines: correct shebang (#!/usr/bin/env bash), set -e active, UPPER_CASE for constants, and proper quoting for path detection using BASH_SOURCE[0].


20-34: LGTM!

Logging functions follow snake_case naming convention and provide clear, color-coded output for different message types.


36-39: LGTM with minor edge case consideration.

The implementation is correct for typical PATH entries. Note that trailing slashes in PATH entries (e.g., /usr/local/bin/ vs /usr/local/bin) could cause false negatives, but this is rare in practice.


41-80: Good Windows handling approach.

The script correctly avoids automatic symlink creation on Windows Git Bash and provides clear manual installation options. The cygpath fallback at line 62 properly handles cases where the command isn't available.


82-98: LGTM!

Platform detection covers all expected environments with appropriate pattern matching for Windows variants (MINGW, MSYS, CYGWIN).


100-121: LGTM!

The installation directory priority is well-thought-out: writable Homebrew bin takes precedence, followed by existing /usr/local/bin, with ~/bin as a safe fallback. The checks ensure appropriate directory selection without requiring sudo unless necessary.


123-127: LGTM!

The sudo check logic is correct: returns true only when the directory exists but isn't writable by the current user.


159-180: LGTM!

Existing target handling is comprehensive: correctly identifies same-target symlinks, replaces different-target symlinks with warning, and errors appropriately for non-symlink files. The || true guard on readlink follows the coding guidelines for non-critical failures.


182-213: LGTM!

Directory and symlink creation logic correctly uses sudo only when needed. The PATH warning provides actionable guidance with shell-specific configuration file suggestions.


215-244: LGTM!

The verification function provides good feedback by checking both command -v availability and actual git gtr version execution, with helpful guidance when the command isn't immediately available.

@helizaga helizaga merged commit 588e24a into main Jan 5, 2026
1 check passed
@helizaga helizaga deleted the fix/install-path-detection branch January 5, 2026 22:32
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