From 8c6068bb9f66e0b67bacbb90fc6ec104441edfde Mon Sep 17 00:00:00 2001 From: "sas.fajri" Date: Wed, 24 Jun 2026 11:47:39 +0700 Subject: [PATCH] 3Z4LPN - fix devcpone sync agar semua commit ter-push ikut tersync --- .githooks/pre-push | 2 +- scripts/devcpone_sync.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index 54e04c2..f368e46 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -29,7 +29,7 @@ while read -r local_ref local_sha remote_ref remote_sha; do esac repo_root=$(git rev-parse --show-toplevel) - if ! "$repo_root/scripts/devcpone_sync.sh" "$branch"; then + if ! "$repo_root/scripts/devcpone_sync.sh" "$branch" "$remote_sha" "$local_sha"; then printf '%s\n' "devcpone sync failed; blocking push" >&2 exit 1 fi diff --git a/scripts/devcpone_sync.sh b/scripts/devcpone_sync.sh index f2848c6..dc48e96 100755 --- a/scripts/devcpone_sync.sh +++ b/scripts/devcpone_sync.sh @@ -3,6 +3,8 @@ set -eu repo_root=$(git rev-parse --show-toplevel) branch=${1:-$(git symbolic-ref --quiet --short HEAD 2>/dev/null || true)} +old_sha=${2:-} +new_sha=${3:-HEAD} case "$branch" in master) @@ -22,8 +24,11 @@ trap 'rm -rf "$tmpdir"' EXIT HUP INT TERM manifest="$tmpdir/files.list" verify_list="$tmpdir/files.verify" -if git rev-parse --verify HEAD^ >/dev/null 2>&1; then - git diff -M --name-only -z --diff-filter=ACMR HEAD^ HEAD > "$manifest" +zero_sha="0000000000000000000000000000000000000000" +if [ -n "$old_sha" ] && [ "$old_sha" != "$zero_sha" ]; then + git diff -M --name-only -z --diff-filter=ACMR "$old_sha" "$new_sha" > "$manifest" +elif git rev-parse --verify "${new_sha}^" >/dev/null 2>&1; then + git diff -M --name-only -z --diff-filter=ACMR "${new_sha}^" "$new_sha" > "$manifest" else git ls-files -z > "$manifest" fi