summaryrefslogtreecommitdiff
path: root/mac/.local/bin/ppts
blob: bde60df67f480cf3d527fad49b421f368fd9d8f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

# Wrapper script for git push that handles content/ directory exclusion
# Usage: ppts <remote> <branch> [other git push options]

remote="$1"
shift

# Run git push
git push "$remote" "$@"
push_exit_code=$?

# If push was successful and we pushed to origin, restore content/
if [ "$push_exit_code" -eq 0 ] && [ "$remote" = "origin" ]; then
  if [ -f .git/hooks/.pre-push-state ]; then
    echo "Restoring content/ directory..."

    # Read the stored HEAD and temp commit
    original_head=$(head -n 1 .git/hooks/.pre-push-state)

    # Reset to original HEAD (this will restore content/)
    if [ -n "$original_head" ] && git rev-parse --verify "$original_head" >/dev/null 2>&1; then
      git reset --soft "$original_head" >/dev/null 2>&1
      echo "content/ directory restored to git index"
    fi

    # Clean up state file
    rm -f .git/hooks/.pre-push-state
  fi
fi

exit "$push_exit_code"