Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions git-guards/scripts/main-branch-guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ def main() -> None:
if worktree_root and Path(worktree_root).name == "main":
deny(
f"BLOCKED: File '{file_path}' is in the main worktree. "
"Editing files on the main branch is not allowed.\n\n"
"Editing files in the main worktree is not allowed.\n\n"
"Create a worktree using `/superpowers:using-git-worktrees`.",
)

current_branch = get_current_branch(file_path)
if current_branch == "main":
deny(
f"BLOCKED: Current branch is 'main'. "
"Editing files on the main branch is not allowed.\n\n"
f"BLOCKED: File '{file_path}' is in the main worktree. "
"Editing files in the main worktree is not allowed.\n\n"
"Create a worktree using `/superpowers:using-git-worktrees`.",
)

Expand Down
4 changes: 2 additions & 2 deletions git-guards/scripts/main-branch-guard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [[ -n "$worktree_root" ]] && [[ "$(basename "$worktree_root")" == "main" ]];
hookSpecificOutput: {
hookEventName: "PreToolUse",
permissionDecision: "deny",
permissionDecisionReason: ("BLOCKED: File '\''\($path)'\'' is in the main worktree. Editing files on the main branch is not allowed.\n\nCreate a worktree using `/superpowers:using-git-worktrees`.")
permissionDecisionReason: ("BLOCKED: File '\''\($path)'\'' is in the main worktree. Editing files in the main worktree is not allowed.\n\nCreate a worktree using `/superpowers:using-git-worktrees`.")
}
}' >&2
exit 2
Expand All @@ -48,7 +48,7 @@ if [[ "$current_branch" == "main" ]]; then
hookSpecificOutput: {
hookEventName: "PreToolUse",
permissionDecision: "deny",
permissionDecisionReason: ("BLOCKED: Current branch is '\''main'\''. Editing files on the main branch is not allowed.\n\nCreate a worktree using `/superpowers:using-git-worktrees`.")
permissionDecisionReason: ("BLOCKED: File '\''\($path)'\'' is in the main worktree. Editing files in the main worktree is not allowed.\n\nCreate a worktree using `/superpowers:using-git-worktrees`.")
}
}' >&2
exit 2
Expand Down
Loading