Update gp
This commit is contained in:
21
gp
21
gp
@@ -30,6 +30,7 @@ OPTIONS:
|
||||
-h, --help Show this help message
|
||||
-n, --dry-run Show what would be committed without actually doing it
|
||||
-f, --force Skip safety checks (use with caution)
|
||||
-y, --yes Auto-answer yes to all prompts
|
||||
-b, --branch Specify branch to push to (default: current branch)
|
||||
-a, --add-all Add all files including untracked (default)
|
||||
--staged-only Only commit staged changes (don't add untracked files)
|
||||
@@ -42,6 +43,7 @@ EXAMPLES:
|
||||
gp "Fix bug in parser" # Add all files with custom commit message
|
||||
gp --dry-run # Preview what would be committed
|
||||
gp --staged-only # Only commit staged changes (don't add untracked)
|
||||
gp -y # Auto-answer yes to all prompts
|
||||
gp -b develop # Push to develop branch instead of current
|
||||
|
||||
EOF
|
||||
@@ -417,8 +419,8 @@ show_status_and_confirm() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Confirmation for file additions (unless forced or dry-run)
|
||||
if [ "$ADD_ALL" = true ] && [ "$FORCE" = false ] && [ "$DRY_RUN" = false ]; then
|
||||
# Confirmation for file additions (unless forced, auto-yes, or dry-run)
|
||||
if [ "$ADD_ALL" = true ] && [ "$FORCE" = false ] && [ "$AUTO_YES" = false ] && [ "$DRY_RUN" = false ]; then
|
||||
if [ "$has_unstaged_changes" = true ] || [ "$has_untracked_files" = true ]; then
|
||||
echo
|
||||
read -p "Add these files and continue? [y/N] " -n 1 -r
|
||||
@@ -474,13 +476,14 @@ do_commit_and_push() {
|
||||
autocomplete() {
|
||||
local args=("$@")
|
||||
if [ ${#args[@]} -eq 0 ]; then
|
||||
printf "%s\n" "--help" "--dry-run" "--force" "--add-all" "--staged-only" "--branch" "-h" "-n" "-f" "-a" "-b"
|
||||
printf "%s\n" "--help" "--dry-run" "--force" "--yes" "--add-all" "--staged-only" "--branch" "-h" "-n" "-f" "-y" "-a" "-b"
|
||||
fi
|
||||
}
|
||||
|
||||
# Default values
|
||||
DRY_RUN=false
|
||||
FORCE=false
|
||||
AUTO_YES=false
|
||||
ADD_ALL=true # Default to adding all files
|
||||
CUSTOM_MESSAGE=""
|
||||
TARGET_BRANCH=""
|
||||
@@ -514,6 +517,10 @@ while [[ $# -gt 0 ]]; do
|
||||
FORCE=true
|
||||
shift
|
||||
;;
|
||||
-y|--yes)
|
||||
AUTO_YES=true
|
||||
shift
|
||||
;;
|
||||
-a|--add-all)
|
||||
ADD_ALL=true # Explicitly set (though it's default)
|
||||
shift
|
||||
@@ -566,8 +573,8 @@ main() {
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Safety confirmation for push-only (unless forced)
|
||||
if [ "$FORCE" = false ]; then
|
||||
# Safety confirmation for push-only (unless forced or auto-yes)
|
||||
if [ "$FORCE" = false ] && [ "$AUTO_YES" = false ]; then
|
||||
echo
|
||||
read -p "Push existing commits to origin/$TARGET_BRANCH? [y/N] " -n 1 -r
|
||||
echo
|
||||
@@ -626,8 +633,8 @@ main() {
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Safety confirmation (unless forced)
|
||||
if [ "$FORCE" = false ]; then
|
||||
# Safety confirmation (unless forced or auto-yes)
|
||||
if [ "$FORCE" = false ] && [ "$AUTO_YES" = false ]; then
|
||||
echo
|
||||
read -p "Proceed with commit and push? [y/N] " -n 1 -r
|
||||
echo
|
||||
|
||||
Reference in New Issue
Block a user