safe-push
v0.6.0
Published
Git push safety checker - blocks pushes to forbidden areas
Downloads
358
Readme
safe-push
A Bun CLI tool for safe Git push operations. Detects changes to forbidden areas (default: .github/) and blocks pushes based on configurable conditions.
Installation
bun install
bun run buildGlobal installation:
bun linkUsage
Check Push Permission
safe-push check # Display result in human-readable format
safe-push check --json # Output result as JSONExecute Push
safe-push push # Check and push if allowed
safe-push push --force # Bypass safety checks
safe-push push --dry-run # Show result without actually pushingConfiguration Management
safe-push config init # Initialize configuration file
safe-push config init -f # Overwrite existing configuration
safe-push config show # Show current configuration
safe-push config path # Show configuration file pathPush Permission Rules
Push Allowed = (No forbidden changes) AND (New branch OR Last commit is yours)| Forbidden Changes | New Branch | Last Commit Yours | Result | |-------------------|------------|-------------------|---------| | No | Yes | - | Allowed | | No | No | Yes | Allowed | | No | No | No | Blocked | | Yes | - | - | Blocked |
Configuration
Path: ~/.config/safe-push/config.jsonc
{
// Forbidden paths (glob patterns)
"forbiddenPaths": [".github/"],
// Behavior on forbidden changes: "error" | "prompt"
"onForbidden": "error"
}Options
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| forbiddenPaths | string[] | [".github/"] | Paths to block changes (glob patterns) |
| onForbidden | "error" \| "prompt" | "error" | Behavior when forbidden changes detected |
error: Display error and exitprompt: Ask user for confirmation
Author Detection
Local email is determined by the following priority:
- Environment variable
SAFE_PUSH_EMAIL git config user.email
Development
# Run in development
bun run dev -- check
# Type check
bun run typecheck
# Build
bun run buildLicense
MIT
