diff --git a/.githooks/pre-push b/.githooks/pre-push index db60b84..329b572 100644 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -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}" diff --git a/scripts/update_changelog.sh b/scripts/update_changelog.sh index 11b889e..bc31dd1 100755 --- a/scripts/update_changelog.sh +++ b/scripts/update_changelog.sh @@ -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)"