From 3dd8cea8bcd4b1333cf487badfba24dae7fea0bd Mon Sep 17 00:00:00 2001 From: Firas Regaieg Date: Thu, 26 Nov 2026 20:09:16 +0100 Subject: [PATCH 1/2] Adding pre-push hook --- build.gradle | 4 +++- scripts/pre-push | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 scripts/pre-push diff --git a/build.gradle b/build.gradle index 175f552f52..104784a105 100644 --- a/build.gradle +++ b/build.gradle @@ -33,7 +33,9 @@ sonarqube { // Install git hooks tasks.register('installLocalGitHook', Copy) { - from new File(rootProject.rootDir, 'scripts/pre-commit') + from(new File(rootProject.rootDir, 'scripts')) { + include 'pre-commit', 'pre-push' + } into new File(rootProject.rootDir, '.git/hooks') filePermissions { unix("rwxrwxr-x") diff --git a/scripts/pre-push b/scripts/pre-push new file mode 100644 index 0000000000..905cb72e7b --- /dev/null +++ b/scripts/pre-push @@ -0,0 +1,2 @@ +#!/bin/sh +# TODO: pre-push hook \ No newline at end of file From 6896bf685cf73fb132f588e2e12fb0972627dbf8 Mon Sep 17 00:00:00 2001 From: Firas Regaieg Date: Fri, 27 Nov 2026 19:52:16 +0100 Subject: [PATCH 2/2] test commit --- scripts/pre-push | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/scripts/pre-push b/scripts/pre-push index 905cb72e7b..a63a299952 100644 --- a/scripts/pre-push +++ b/scripts/pre-push @@ -1,2 +1,32 @@ #!/bin/sh -# TODO: pre-push hook \ No newline at end of file +# pre-push hook (step 1: skeleton). Classifies pushes, never blocks. + +ZERO_OID="0000000000000000000000000000000000000000" + +log() { + printf '[pre-push] %s\n' "$*" >&2 +} + +classify() { + local_oid=$1 + remote_ref=$2 + remote_oid=$3 + + case "$remote_ref" in refs/heads/*) ;; *) echo "skip (not a branch)"; return ;; esac + [ "$local_oid" = "$ZERO_OID" ] && { echo "skip (deletion)"; return; } + [ "$remote_oid" = "$ZERO_OID" ] && { echo "skip (new branch)"; return; } + if git merge-base --is-ancestor "$remote_oid" "$local_oid" 2>/dev/null; then + echo "fast-forward" + else + echo "NON-FAST-FORWARD (would need review check)" + fi +} + +log "Starting history-rewrite check..." +while read -r _local_ref local_oid remote_ref remote_oid; do + log "${remote_ref#refs/heads/}: $(classify "$local_oid" "$remote_ref" "$remote_oid")" +done +log "Check finished: push allowed." +exit 0 + +# test \ No newline at end of file