Skip to content

Commit

Permalink
Add dt git hook to avoid rawspeed change.
Browse files Browse the repository at this point in the history
  • Loading branch information
TurboGit committed May 24, 2019
1 parent 0a2edd6 commit 31b8d61
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .githooks/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
To activate:

$ git config core.hooksPath .githooks
31 changes: 31 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Hash using its key as a search Regex, and its value as associated
# error message.

declare -A PATTERNS;
PATTERNS['src/external/rawspeed']="use --no-verify to change rawspeed";

# Loop over staged files and check for any specific pattern listed in
# PATTERNS keys.
# Filter only added (A), copied (C), modified (M) files

declare -a errors

for file in $(git diff --staged --name-only --diff-filter=ACM --no-color); do
for elem in ${!PATTERNS[*]} ; do
if [ ! -z "${PATTERNS[${file}]}" ]; then
errors+=("${PATTERNS[${file}]}")
fi
done
done

# Print errors
for error in "${errors[@]}"; do
echo -e "\033[1;31m${error}\033[0m"
done

# If there is any error, then stop commit creation
if ! [ ${#errors[@]} -eq 0 ]; then
exit 1
fi
1 change: 0 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
path = src/external/rawspeed
url = https://github.com/darktable-org/rawspeed.git
branch = develop
ignore = all
4 changes: 3 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

set -e

# setup local hooks
git config core.hooksPath .githooks

DT_SRC_DIR=$(dirname "$0")
DT_SRC_DIR=$(cd "$DT_SRC_DIR" && pwd -P)

Expand Down Expand Up @@ -327,4 +330,3 @@ fi

# install the binaries
eval "$cmd_install"

0 comments on commit 31b8d61

Please sign in to comment.