mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-12 22:38:50 +00:00
fix: improve user confirmation handling in pre-push hook
- Updated the pre-push hook to read user confirmation directly from /dev/tty, ensuring it works correctly in all terminal contexts. - This change enhances the reliability of the push confirmation process, preventing potential issues with user input in non-interactive environments.
This commit is contained in:
parent
f1fcbf69cf
commit
a895726cbd
@ -44,7 +44,8 @@ if [ -f "$CHANGELOG_SCRIPT" ]; then
|
||||
echo -e "${BLUE}────────────────────────────────────────────────────────────────────────${NOCOLOR}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Do you want to proceed with the push? (yes/no):${NOCOLOR} "
|
||||
read -r confirmation
|
||||
# Read from /dev/tty to ensure we can read from terminal even in git hook context
|
||||
read -r confirmation < /dev/tty
|
||||
|
||||
if [ "$confirmation" != "yes" ]; then
|
||||
echo -e "${RED}Push aborted by user.${NOCOLOR}"
|
||||
|
||||
@ -96,14 +96,17 @@ log "Collecting git diffs..."
|
||||
# Unstaged changes
|
||||
UNSTAGED_DIFF=$(git diff 2>/dev/null || echo "")
|
||||
UNSTAGED_COUNT=$(echo "$UNSTAGED_DIFF" | grep -c "^diff\|^index" 2>/dev/null || echo "0")
|
||||
[ -z "$UNSTAGED_COUNT" ] && UNSTAGED_COUNT="0"
|
||||
|
||||
# Staged changes
|
||||
STAGED_DIFF=$(git diff --cached 2>/dev/null || echo "")
|
||||
STAGED_COUNT=$(echo "$STAGED_DIFF" | grep -c "^diff\|^index" 2>/dev/null || echo "0")
|
||||
[ -z "$STAGED_COUNT" ] && STAGED_COUNT="0"
|
||||
|
||||
# Unpushed commits
|
||||
UNPUSHED_DIFF=$(git diff "$REMOTE_BRANCH"..HEAD 2>/dev/null || echo "")
|
||||
UNPUSHED_COMMITS=$(git rev-list --count "$REMOTE_BRANCH"..HEAD 2>/dev/null || echo "0")
|
||||
[ -z "$UNPUSHED_COMMITS" ] && UNPUSHED_COMMITS="0"
|
||||
|
||||
log "Found: $UNSTAGED_COUNT unstaged file(s), $STAGED_COUNT staged file(s), $UNPUSHED_COMMITS unpushed commit(s)"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user