summaryrefslogtreecommitdiff
path: root/Omni/Ide/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'Omni/Ide/hooks')
-rwxr-xr-xOmni/Ide/hooks/commit-msg7
-rwxr-xr-xOmni/Ide/hooks/post-applypatch6
-rwxr-xr-xOmni/Ide/hooks/post-checkout20
-rwxr-xr-xOmni/Ide/hooks/post-commit6
-rwxr-xr-xOmni/Ide/hooks/post-merge6
-rwxr-xr-xOmni/Ide/hooks/post-rewrite6
-rwxr-xr-xOmni/Ide/hooks/pre-auto-gc6
-rwxr-xr-xOmni/Ide/hooks/pre-commit21
-rwxr-xr-xOmni/Ide/hooks/pre-push22
-rwxr-xr-xOmni/Ide/hooks/reference-transaction12
10 files changed, 112 insertions, 0 deletions
diff --git a/Omni/Ide/hooks/commit-msg b/Omni/Ide/hooks/commit-msg
new file mode 100755
index 0000000..e07d1f4
--- /dev/null
+++ b/Omni/Ide/hooks/commit-msg
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+if ! gitlint --ignore-stdin --staged --msg-filename "$1" run-hook; then
+ backup="$CODEROOT"/.git/COMMIT_EDITMSG.backup
+ cp "$CODEROOT"/.git/COMMIT_EDITMSG "$backup"
+ echo "error: gitlint failed, saved your commit msg as $backup"
+ exit 1
+fi
diff --git a/Omni/Ide/hooks/post-applypatch b/Omni/Ide/hooks/post-applypatch
new file mode 100755
index 0000000..5071dc5
--- /dev/null
+++ b/Omni/Ide/hooks/post-applypatch
@@ -0,0 +1,6 @@
+#!/bin/sh
+## START BRANCHLESS CONFIG
+
+git branchless hook post-applypatch "$@"
+
+## END BRANCHLESS CONFIG
diff --git a/Omni/Ide/hooks/post-checkout b/Omni/Ide/hooks/post-checkout
new file mode 100755
index 0000000..85541a2
--- /dev/null
+++ b/Omni/Ide/hooks/post-checkout
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+set -e
+function MakeTags {
+ ${CODEROOT:?}/Omni/Ide/MakeTags.py
+}
+old=$1
+new=$2
+# filter out only the changed haskell files
+mapfile -t changed < <(git diff --diff-filter=d --name-only "$old" "$new" -- '*.hs')
+if [[ ! -r tags ]] || [[ ! -r TAGS ]]
+then
+ MakeTags "$CODEROOT"/**/*
+elif [[ ${#changed[@]} -gt 0 ]]
+then
+ MakeTags "${changed[@]}"
+fi
+## START BRANCHLESS CONFIG
+
+git branchless hook post-checkout "$@"
+## END BRANCHLESS CONFIG
diff --git a/Omni/Ide/hooks/post-commit b/Omni/Ide/hooks/post-commit
new file mode 100755
index 0000000..cd1f195
--- /dev/null
+++ b/Omni/Ide/hooks/post-commit
@@ -0,0 +1,6 @@
+#!/bin/sh
+## START BRANCHLESS CONFIG
+
+git branchless hook post-commit "$@"
+
+## END BRANCHLESS CONFIG
diff --git a/Omni/Ide/hooks/post-merge b/Omni/Ide/hooks/post-merge
new file mode 100755
index 0000000..fcfd314
--- /dev/null
+++ b/Omni/Ide/hooks/post-merge
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+"${CODEROOT:?}"/Omni/Ide/hooks/post-checkout 'HEAD@{1}' HEAD
+## START BRANCHLESS CONFIG
+
+git branchless hook post-merge "$@"
+## END BRANCHLESS CONFIG
diff --git a/Omni/Ide/hooks/post-rewrite b/Omni/Ide/hooks/post-rewrite
new file mode 100755
index 0000000..8b3237a
--- /dev/null
+++ b/Omni/Ide/hooks/post-rewrite
@@ -0,0 +1,6 @@
+#!/bin/sh
+## START BRANCHLESS CONFIG
+
+git branchless hook post-rewrite "$@"
+
+## END BRANCHLESS CONFIG
diff --git a/Omni/Ide/hooks/pre-auto-gc b/Omni/Ide/hooks/pre-auto-gc
new file mode 100755
index 0000000..c92a844
--- /dev/null
+++ b/Omni/Ide/hooks/pre-auto-gc
@@ -0,0 +1,6 @@
+#!/bin/sh
+## START BRANCHLESS CONFIG
+
+git branchless hook pre-auto-gc "$@"
+
+## END BRANCHLESS CONFIG
diff --git a/Omni/Ide/hooks/pre-commit b/Omni/Ide/hooks/pre-commit
new file mode 100755
index 0000000..06f1716
--- /dev/null
+++ b/Omni/Ide/hooks/pre-commit
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+#
+# - prevent frozen code from being checked in
+# - guard against lint errors
+##
+ set -e
+ mapfile -t changed < <(git diff-index --cached --name-only HEAD)
+ for ns in "${changed[@]}"
+ do
+ version=$("${CODEROOT:?}"/Omni/Ide/version.sh "$ns")
+ if [[ $version -eq -1 ]]; then
+ echo "info: version: $ns: deleted"
+ elif [[ $version -lt 1 ]]; then
+ echo "fail: version: $ns: $version"
+ exit 1
+ else
+ echo "info: version: $ns: $version"
+ fi
+ done
+ lint "${changed[@]}"
+##
diff --git a/Omni/Ide/hooks/pre-push b/Omni/Ide/hooks/pre-push
new file mode 100755
index 0000000..00110bd
--- /dev/null
+++ b/Omni/Ide/hooks/pre-push
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+set -euo pipefail
+remote="$1"
+z40=0000000000000000000000000000000000000000
+IFS=" "
+while read local_ref local_sha remote_ref remote_sha
+do
+ if [ "$local_sha" = $z40 ]
+ then
+ # delete, do nothing
+ continue
+ elif [ "$remote_sha" = $z40 ]
+ then
+ # new branch, test all commits since ci was implemented
+ range="11d95581fb178a5d21e88dfd8030a61886cc2519..$local_sha"
+ else
+ range="$remote_sha..$local_sha"
+ fi
+done
+gitlint --commits "$range" lint
+git test run --command ci "$range"
+git push "$remote" refs/notes/ci --no-verify
diff --git a/Omni/Ide/hooks/reference-transaction b/Omni/Ide/hooks/reference-transaction
new file mode 100755
index 0000000..ea0cce6
--- /dev/null
+++ b/Omni/Ide/hooks/reference-transaction
@@ -0,0 +1,12 @@
+#!/bin/sh
+## START BRANCHLESS CONFIG
+
+# Avoid canceling the reference transaction in the case that `branchless` fails
+# for whatever reason.
+git branchless hook reference-transaction "$@" || (
+echo 'branchless: Failed to process reference transaction!'
+echo 'branchless: Some events (e.g. branch updates) may have been lost.'
+echo 'branchless: This is a bug. Please report it.'
+)
+
+## END BRANCHLESS CONFIG