Skip to content

Commit 86e2a83

Browse files
authored
Merge pull request #30 from stranma/fix/git-permission-friction
fix: move common git commands from ask to allow
2 parents 566e9cd + 0a820e0 commit 86e2a83

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

.claude/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"Bash(git branch *)", "Bash(git checkout *)", "Bash(git status *)",
1212
"Bash(git diff *)", "Bash(git log *)", "Bash(git show *)",
1313
"Bash(git merge *)", "Bash(git stash *)",
14+
"Bash(git restore *)", "Bash(git reset *)", "Bash(git rm *)",
15+
"Bash(git mv *)", "Bash(git worktree *)",
1416
"Bash(git remote *)", "Bash(git submodule *)", "Bash(git tag *)",
1517
"Bash(git switch *)", "Bash(git rev-parse *)", "Bash(git cherry-pick *)",
1618
"Bash(git blame *)", "Bash(git reflog *)", "Bash(git ls-files *)",
@@ -41,8 +43,7 @@
4143
"Bash(gh workflow enable *)", "Bash(gh workflow disable *)",
4244
"Bash(gh issue create *)", "Bash(gh issue comment *)",
4345
"Bash(gh issue close *)", "Bash(gh issue edit *)",
44-
"Bash(git reset *)", "Bash(git init *)", "Bash(git clone *)",
45-
"Bash(git rm *)", "Bash(git mv *)", "Bash(git restore *)", "Bash(git worktree *)",
46+
"Bash(git init *)", "Bash(git clone *)",
4647
"Bash(uv remove *)", "Bash(uv cache *)", "Bash(uv init *)",
4748
"WebFetch"
4849
]

tests/test_permissions.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,21 @@ def test_pr_merge_requires_confirmation(self, settings: dict[str, Any]) -> None:
328328
def test_workflow_run_requires_confirmation(self, settings: dict[str, Any]) -> None:
329329
assert evaluate("Bash(gh workflow run deploy.yml)", settings) == "ask"
330330

331-
def test_git_reset_requires_confirmation(self, settings: dict[str, Any]) -> None:
332-
assert evaluate("Bash(git reset --hard HEAD~1)", settings) == "ask"
333-
assert evaluate("Bash(git reset HEAD file.py)", settings) == "ask"
331+
def test_git_reset_is_allowed(self, settings: dict[str, Any]) -> None:
332+
assert evaluate("Bash(git reset --hard HEAD~1)", settings) == "allow"
333+
assert evaluate("Bash(git reset HEAD file.py)", settings) == "allow"
334334

335-
def test_git_destructive_operations_require_confirmation(self, settings: dict[str, Any]) -> None:
336-
for cmd in ["git init", "git clone https://github.com/repo", "git rm file.py", "git mv a.py b.py"]:
335+
def test_git_init_clone_require_confirmation(self, settings: dict[str, Any]) -> None:
336+
for cmd in ["git init", "git clone https://github.com/repo"]:
337337
assert evaluate(f"Bash({cmd})", settings) == "ask", f"{cmd} should require confirmation"
338338

339-
def test_git_restore_requires_confirmation(self, settings: dict[str, Any]) -> None:
340-
assert evaluate("Bash(git restore file.py)", settings) == "ask"
341-
assert evaluate("Bash(git restore --staged file.py)", settings) == "ask"
339+
def test_git_rm_mv_are_allowed(self, settings: dict[str, Any]) -> None:
340+
for cmd in ["git rm file.py", "git mv a.py b.py"]:
341+
assert evaluate(f"Bash({cmd})", settings) == "allow", f"{cmd} should be allowed"
342+
343+
def test_git_restore_is_allowed(self, settings: dict[str, Any]) -> None:
344+
assert evaluate("Bash(git restore file.py)", settings) == "allow"
345+
assert evaluate("Bash(git restore --staged file.py)", settings) == "allow"
342346

343347
def test_gh_issue_mutations_require_confirmation(self, settings: dict[str, Any]) -> None:
344348
for cmd in [
@@ -359,8 +363,8 @@ def test_gh_workflow_enable_disable_requires_confirmation(self, settings: dict[s
359363
assert evaluate("Bash(gh workflow enable deploy.yml)", settings) == "ask"
360364
assert evaluate("Bash(gh workflow disable deploy.yml)", settings) == "ask"
361365

362-
def test_git_worktree_requires_confirmation(self, settings: dict[str, Any]) -> None:
363-
assert evaluate("Bash(git worktree add ../feature)", settings) == "ask"
366+
def test_git_worktree_is_allowed(self, settings: dict[str, Any]) -> None:
367+
assert evaluate("Bash(git worktree add ../feature)", settings) == "allow"
364368

365369
def test_uv_init_requires_confirmation(self, settings: dict[str, Any]) -> None:
366370
assert evaluate("Bash(uv init my-project)", settings) == "ask"

0 commit comments

Comments
 (0)