Skip to content

Commit f1795fd

Browse files
committed
Updated items based on CONTRIBUTING.md
1 parent 80453c7 commit f1795fd

File tree

6 files changed

+45
-3
lines changed

6 files changed

+45
-3
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,16 @@ git gtr clean --merged --force --yes # Force-clean and auto-confirm
340340

341341
**Note:** The `--merged` mode auto-detects your hosting provider (GitHub or GitLab) from the `origin` remote URL and requires the corresponding CLI tool (`gh` or `glab`) to be installed and authenticated. For self-hosted instances, set the provider explicitly: `git gtr config set gtr.provider gitlab`.
342342

343+
### `git gtr trust`
344+
345+
Review and approve hook commands defined in the repository's `.gtrconfig` file. Hooks from `.gtrconfig` are **not executed** until explicitly trusted — this prevents malicious contributors from injecting arbitrary shell commands via shared config files.
346+
347+
```bash
348+
git gtr trust # Review and approve .gtrconfig hooks
349+
```
350+
351+
Trust is stored per content hash and must be re-approved if hooks change. Hooks from your local git config (`.git/config`, `~/.gitconfig`) are always trusted.
352+
343353
### Other Commands
344354

345355
- `git gtr doctor` - Health check (verify git, editors, AI tools)
@@ -390,10 +400,12 @@ git gtr config set gtr.ui.color never
390400
ai = claude
391401
```
392402

403+
**Hook trust:** Hooks defined in `.gtrconfig` require explicit approval before they execute. Run `git gtr trust` after cloning a repository or when `.gtrconfig` hooks change. This protects against malicious hook injection in shared repositories.
404+
393405
**Configuration precedence** (highest to lowest):
394406

395407
1. `git config --local` (`.git/config`) - personal overrides
396-
2. `.gtrconfig` (repo root) - team defaults
408+
2. `.gtrconfig` (repo root) - team defaults (hooks require `git gtr trust`)
397409
3. `git config --global` (`~/.gitconfig`) - user defaults
398410

399411
> For complete configuration reference including all settings, hooks, file copying patterns, and environment variables, see [docs/configuration.md](docs/configuration.md)

completions/_git-gtr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ _git-gtr() {
4545
'config:Manage configuration'
4646
'completion:Generate shell completions'
4747
'init:Generate shell integration for cd support'
48+
'trust:Trust .gtrconfig hooks'
4849
'version:Show version'
4950
'help:Show help'
5051
)

completions/git-gtr.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ complete -f -c git -n '__fish_git_gtr_using_command completion' -a 'bash zsh fis
5454
complete -f -c git -n '__fish_git_gtr_needs_command' -a init -d 'Generate shell integration for cd support'
5555
complete -f -c git -n '__fish_git_gtr_using_command init' -a 'bash zsh fish' -d 'Shell type'
5656
complete -c git -n '__fish_git_gtr_using_command init' -l as -d 'Custom function name' -r
57+
complete -f -c git -n '__fish_git_gtr_needs_command' -a trust -d 'Trust .gtrconfig hooks'
5758
complete -f -c git -n '__fish_git_gtr_needs_command' -a version -d 'Show version'
5859
complete -f -c git -n '__fish_git_gtr_needs_command' -a help -d 'Show help'
5960

completions/gtr.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ _git_gtr() {
2525

2626
# If we're completing the first argument after 'git gtr'
2727
if [ "$cword" -eq 2 ]; then
28-
COMPREPLY=($(compgen -W "new go run copy editor ai rm mv rename ls list clean doctor adapter config completion init help version" -- "$cur"))
28+
COMPREPLY=($(compgen -W "new go run copy editor ai rm mv rename ls list clean doctor adapter config completion init trust help version" -- "$cur"))
2929
return 0
3030
fi
3131

lib/commands/help.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,27 @@ Command palette (gtr cd with no arguments, requires fzf):
401401
EOF
402402
}
403403

404+
_help_trust() {
405+
cat <<'EOF'
406+
git gtr trust - Trust .gtrconfig hooks
407+
408+
Usage: git gtr trust
409+
410+
Reviews and approves hook commands defined in the repository's .gtrconfig
411+
file. Hooks from .gtrconfig are not executed until explicitly trusted.
412+
413+
This prevents malicious contributors from injecting arbitrary shell
414+
commands via shared .gtrconfig files. Trust is stored per content hash
415+
in ~/.config/gtr/trusted/ and must be re-approved if hooks change.
416+
417+
Hooks from your local git config (.git/config, ~/.gitconfig) are always
418+
trusted since you control those files directly.
419+
420+
Examples:
421+
git gtr trust # Review and approve hooks
422+
EOF
423+
}
424+
404425
_help_version() {
405426
cat <<'EOF'
406427
git gtr version - Show version
@@ -572,6 +593,11 @@ SETUP & MAINTENANCE:
572593
--dry-run, -n: show what would be removed without removing
573594
--force, -f: force removal even if worktree has uncommitted changes or untracked files
574595
596+
trust
597+
Review and approve .gtrconfig hook commands
598+
Hooks from .gtrconfig are not executed until trusted
599+
Trust is re-required when hook content changes
600+
575601
completion <shell>
576602
Generate shell completions (bash, zsh, fish)
577603
Usage: eval "$(git gtr completion zsh)"

scripts/generate-completions.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ _git_gtr() {
115115
116116
# If we're completing the first argument after 'git gtr'
117117
if [ "$cword" -eq 2 ]; then
118-
COMPREPLY=($(compgen -W "new go run copy editor ai rm mv rename ls list clean doctor adapter config completion init help version" -- "$cur"))
118+
COMPREPLY=($(compgen -W "new go run copy editor ai rm mv rename ls list clean doctor adapter config completion init trust help version" -- "$cur"))
119119
return 0
120120
fi
121121
@@ -304,6 +304,7 @@ _git-gtr() {
304304
'config:Manage configuration'
305305
'completion:Generate shell completions'
306306
'init:Generate shell integration for cd support'
307+
'trust:Trust .gtrconfig hooks'
307308
'version:Show version'
308309
'help:Show help'
309310
)
@@ -529,6 +530,7 @@ complete -f -c git -n '__fish_git_gtr_using_command completion' -a 'bash zsh fis
529530
complete -f -c git -n '__fish_git_gtr_needs_command' -a init -d 'Generate shell integration for cd support'
530531
complete -f -c git -n '__fish_git_gtr_using_command init' -a 'bash zsh fish' -d 'Shell type'
531532
complete -c git -n '__fish_git_gtr_using_command init' -l as -d 'Custom function name' -r
533+
complete -f -c git -n '__fish_git_gtr_needs_command' -a trust -d 'Trust .gtrconfig hooks'
532534
complete -f -c git -n '__fish_git_gtr_needs_command' -a version -d 'Show version'
533535
complete -f -c git -n '__fish_git_gtr_needs_command' -a help -d 'Show help'
534536

0 commit comments

Comments
 (0)