Skip to content

Commit 31b8d61

Browse files
committed
Add dt git hook to avoid rawspeed change.
1 parent 0a2edd6 commit 31b8d61

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

.githooks/README

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
To activate:
2+
3+
$ git config core.hooksPath .githooks

.githooks/pre-commit

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# Hash using its key as a search Regex, and its value as associated
4+
# error message.
5+
6+
declare -A PATTERNS;
7+
PATTERNS['src/external/rawspeed']="use --no-verify to change rawspeed";
8+
9+
# Loop over staged files and check for any specific pattern listed in
10+
# PATTERNS keys.
11+
# Filter only added (A), copied (C), modified (M) files
12+
13+
declare -a errors
14+
15+
for file in $(git diff --staged --name-only --diff-filter=ACM --no-color); do
16+
for elem in ${!PATTERNS[*]} ; do
17+
if [ ! -z "${PATTERNS[${file}]}" ]; then
18+
errors+=("${PATTERNS[${file}]}")
19+
fi
20+
done
21+
done
22+
23+
# Print errors
24+
for error in "${errors[@]}"; do
25+
echo -e "\033[1;31m${error}\033[0m"
26+
done
27+
28+
# If there is any error, then stop commit creation
29+
if ! [ ${#errors[@]} -eq 0 ]; then
30+
exit 1
31+
fi

.gitmodules

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
path = src/external/rawspeed
33
url = https://github.com/darktable-org/rawspeed.git
44
branch = develop
5-
ignore = all

build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
set -e
44

5+
# setup local hooks
6+
git config core.hooksPath .githooks
7+
58
DT_SRC_DIR=$(dirname "$0")
69
DT_SRC_DIR=$(cd "$DT_SRC_DIR" && pwd -P)
710

@@ -327,4 +330,3 @@ fi
327330

328331
# install the binaries
329332
eval "$cmd_install"
330-

0 commit comments

Comments
 (0)