Skip to content

Commit 97c1ce4

Browse files
authored
feat: color output, per-command help, and 62 new tests (#120)
1 parent 438c9cb commit 97c1ce4

File tree

16 files changed

+1118
-31
lines changed

16 files changed

+1118
-31
lines changed

.github/workflows/homebrew.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Update Homebrew Formula
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
homebrew:
9+
name: Bump Homebrew formula
10+
runs-on: ubuntu-latest
11+
if: ${{ !github.event.release.prerelease }}
12+
steps:
13+
- uses: mislav/bump-homebrew-formula-action@v3
14+
with:
15+
formula-name: git-gtr
16+
formula-path: Formula/git-gtr.rb
17+
homebrew-tap: coderabbitai/homebrew-tap
18+
tag-name: ${{ github.event.release.tag_name }}
19+
create-pullrequest: false
20+
commit-message: |
21+
{{formulaName}} {{version}}
22+
23+
Automated update from https://github.com/coderabbitai/git-worktree-runner
24+
env:
25+
COMMITTER_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@
4242

4343
## Quick Start
4444

45-
**Install:**
45+
**Homebrew (macOS):**
46+
47+
```bash
48+
brew tap coderabbitai/tap
49+
brew install git-gtr
50+
```
51+
52+
**Script installer (macOS / Linux):**
4653

4754
```bash
4855
git clone https://github.com/coderabbitai/git-worktree-runner.git
@@ -51,13 +58,7 @@ cd git-worktree-runner
5158
```
5259

5360
<details>
54-
<summary><b>Manual installation options</b></summary>
55-
56-
**macOS (Apple Silicon with Homebrew):**
57-
58-
```bash
59-
ln -s "$(pwd)/bin/git-gtr" "$(brew --prefix)/bin/git-gtr"
60-
```
61+
<summary><b>Other installation options</b></summary>
6162

6263
**macOS (Intel) / Linux:**
6364

@@ -336,6 +337,9 @@ git gtr config add gtr.hook.postCreate "npm install"
336337

337338
# Re-source environment after gtr cd (runs in current shell)
338339
git gtr config add gtr.hook.postCd "source ./vars.sh"
340+
341+
# Disable color output (or use "always" to force it)
342+
git gtr config set gtr.ui.color never
339343
```
340344

341345
### Team Configuration (.gtrconfig)

bin/gtr

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
set -e
66

7+
# Debug: show file:line:function on set -e failures
8+
if [ -n "${GTR_DEBUG:-}" ]; then
9+
trap 'printf "ERROR at %s:%s in %s()\n" "${BASH_SOURCE[0]}" "$LINENO" "${FUNCNAME[0]:-main}" >&2' ERR
10+
fi
11+
712
# Version
813
GTR_VERSION="2.2.0"
914

@@ -24,6 +29,7 @@ resolve_script_dir() {
2429
. "$GTR_DIR/lib/ui.sh"
2530
. "$GTR_DIR/lib/args.sh"
2631
. "$GTR_DIR/lib/config.sh"
32+
_ui_apply_color_config
2733
. "$GTR_DIR/lib/platform.sh"
2834
. "$GTR_DIR/lib/core.sh"
2935
. "$GTR_DIR/lib/copy.sh"
@@ -44,6 +50,9 @@ main() {
4450
local cmd="${1:-help}"
4551
shift 2>/dev/null || true
4652

53+
# Set for per-command help (used by show_command_help in ui.sh)
54+
_GTR_CURRENT_COMMAND="$cmd"
55+
4756
case "$cmd" in
4857
new)
4958
cmd_create "$@"
@@ -94,7 +103,7 @@ main() {
94103
echo "git gtr version $GTR_VERSION"
95104
;;
96105
help|--help|-h)
97-
cmd_help
106+
cmd_help "$@"
98107
;;
99108
*)
100109
log_error "Unknown command: $cmd"

completions/_git-gtr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ _git-gtr() {
174174
'--local[Use local git config]' \
175175
'--global[Use global git config]' \
176176
'--system[Use system git config]' \
177-
'*:config key:(gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider)'
177+
'*:config key:(gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider gtr.ui.color)'
178178
;;
179179
set|add|unset)
180180
# Write operations only support --local and --global
181181
# (--system may require root or appropriate file permissions)
182182
_arguments \
183183
'--local[Use local git config]' \
184184
'--global[Use global git config]' \
185-
'*:config key:(gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider)'
185+
'*:config key:(gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider gtr.ui.color)'
186186
;;
187187
esac
188188
fi

completions/git-gtr.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ complete -f -c git -n '__fish_git_gtr_using_command config' -a "
139139
gtr.worktrees.prefix 'Worktree folder prefix'
140140
gtr.defaultBranch 'Default branch'
141141
gtr.provider 'Hosting provider (github, gitlab)'
142+
gtr.ui.color 'Color output mode (auto, always, never)'
142143
"
143144

144145
# Helper function to get branch names and special '1' for main repo

completions/gtr.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ _git_gtr() {
131131
if [[ "$cur" == -* ]]; then
132132
COMPREPLY=($(compgen -W "--local --global --system" -- "$cur"))
133133
else
134-
COMPREPLY=($(compgen -W "gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider" -- "$cur"))
134+
COMPREPLY=($(compgen -W "gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider gtr.ui.color" -- "$cur"))
135135
fi
136136
;;
137137
set|add|unset)
138138
# Write operations only support --local and --global (--system requires root)
139139
if [[ "$cur" == -* ]]; then
140140
COMPREPLY=($(compgen -W "--local --global" -- "$cur"))
141141
else
142-
COMPREPLY=($(compgen -W "gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider" -- "$cur"))
142+
COMPREPLY=($(compgen -W "gtr.copy.include gtr.copy.exclude gtr.copy.includeDirs gtr.copy.excludeDirs gtr.hook.postCreate gtr.hook.preRemove gtr.hook.postRemove gtr.hook.postCd gtr.editor.default gtr.editor.workspace gtr.ai.default gtr.worktrees.dir gtr.worktrees.prefix gtr.defaultBranch gtr.provider gtr.ui.color" -- "$cur"))
143143
fi
144144
;;
145145
esac

docs/configuration.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- [File Copying](#file-copying)
1818
- [Directory Copying](#directory-copying)
1919
- [Hooks](#hooks)
20+
- [UI Settings](#ui-settings)
2021
- [Shell Completions](#shell-completions)
2122
- [Configuration Examples](#configuration-examples)
2223
- [Environment Variables](#environment-variables)
@@ -337,6 +338,28 @@ git gtr config add gtr.hook.postCreate "cargo build"
337338

338339
---
339340

341+
## UI Settings
342+
343+
Control color output behavior.
344+
345+
| Git Config Key | `.gtrconfig` Key | Description | Values |
346+
| -------------- | ---------------- | ----------------- | ----------------------------------- |
347+
| `gtr.ui.color` | `ui.color` | Color output mode | `auto` (default), `always`, `never` |
348+
349+
```bash
350+
# Disable color output
351+
git gtr config set gtr.ui.color never
352+
353+
# Force color output (e.g., when piping to a pager)
354+
git gtr config set gtr.ui.color always
355+
```
356+
357+
**Precedence**: `NO_COLOR` env (highest) > `GTR_COLOR` env > `gtr.ui.color` config > auto-detect (TTY).
358+
359+
The `NO_COLOR` environment variable ([no-color.org](https://no-color.org)) always wins regardless of other settings.
360+
361+
---
362+
340363
## Shell Completions
341364

342365
Enable tab completion using the built-in `completion` command.
@@ -420,15 +443,17 @@ git gtr config set gtr.ai.default claude --global
420443

421444
## Environment Variables
422445

423-
| Variable | Description | Default |
424-
| --------------------- | ------------------------------------------------------ | -------------------------- |
425-
| `GTR_DIR` | Override script directory location | Auto-detected |
426-
| `GTR_WORKTREES_DIR` | Override base worktrees directory | `gtr.worktrees.dir` config |
427-
| `GTR_EDITOR_CMD` | Custom editor command (e.g., `emacs`) | None |
428-
| `GTR_EDITOR_CMD_NAME` | First word of `GTR_EDITOR_CMD` for availability checks | None |
429-
| `GTR_AI_CMD` | Custom AI tool command (e.g., `copilot`) | None |
430-
| `GTR_AI_CMD_NAME` | First word of `GTR_AI_CMD` for availability checks | None |
431-
| `GTR_PROVIDER` | Override hosting provider (`github` or `gitlab`) | Auto-detected from URL |
446+
| Variable | Description | Default |
447+
| --------------------- | -------------------------------------------------------------------- | -------------------------- |
448+
| `GTR_DIR` | Override script directory location | Auto-detected |
449+
| `GTR_WORKTREES_DIR` | Override base worktrees directory | `gtr.worktrees.dir` config |
450+
| `GTR_EDITOR_CMD` | Custom editor command (e.g., `emacs`) | None |
451+
| `GTR_EDITOR_CMD_NAME` | First word of `GTR_EDITOR_CMD` for availability checks | None |
452+
| `GTR_AI_CMD` | Custom AI tool command (e.g., `copilot`) | None |
453+
| `GTR_AI_CMD_NAME` | First word of `GTR_AI_CMD` for availability checks | None |
454+
| `GTR_COLOR` | Override color output (`always`, `never`, `auto`) | `auto` |
455+
| `GTR_PROVIDER` | Override hosting provider (`github` or `gitlab`) | Auto-detected from URL |
456+
| `NO_COLOR` | Disable color output when set ([no-color.org](https://no-color.org)) | Unset |
432457

433458
**Hook environment variables** (available in hook scripts):
434459

0 commit comments

Comments
 (0)