Skip to content

Commit

Permalink
Fix git hooks in coding guidelines
Browse files Browse the repository at this point in the history
Before, they used a mac os specific alias (`ggrep`) to the `grep` utility.
Now, it uses `grep`.
  • Loading branch information
Jakob-Unfried committed Dec 10, 2024
1 parent fb5439e commit 8a240e8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions docs/guidelines/code_style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feel free to use the following git hooks (this is Jakobs current setup for the c
for file in $(git diff --name-only --diff-filter=ACM @{push} @); do
# note: only the last grep should be quiet (-q)!
# the first one should return the matches, the last only the exit code
if git show :0:"$file" | ggrep -E "^\+" | ggrep -Eq "^[<>=]{7}"; then
if git show :0:"$file" | grep -E "^\+" | grep -Eq "^[<>=]{7}"; then
echo -e "\033[1;31mLeftover conflict markers in $file\033[0m"
STOP_PUSH=true
fi
Expand Down Expand Up @@ -80,11 +80,11 @@ Feel free to use the following git hooks (this is Jakobs current setup for the c
# check for leftover conflict markers in *whole file*
# note: only the last grep should be quiet (-q)!
# the first one should return the matches, the last only the exit code
if git show :0:"$file" | ggrep -E "^\+" | ggrep -Eq "^[<>=]{7}"; then
if git show :0:"$file" | grep -E "^\+" | grep -Eq "^[<>=]{7}"; then
echo -e "\033[1;31mLeftover conflict markers in $file\033[0m"
STOP_COMMIT=true
fi
if git diff --staged $file | ggrep -E "^\+" | ggrep -Eq "breakpoint()|set_trace()"; then
if git diff --staged $file | grep -E "^\+" | grep -Eq "breakpoint()|set_trace()"; then
echo -e "\033[1;31mDebugging breakpoint in $file\033[0m"
STOP_COMMIT=true
fi
Expand Down Expand Up @@ -118,4 +118,10 @@ Feel free to use the following git hooks (this is Jakobs current setup for the c
echo -e "\033[1;31mCommit blocked.\033[0m Use '--no-verify' to circumvent the hook and commit anyway."
exit 1
fi
```
```

3. On MacOS only, note that the builtin ``grep`` command does not support the features used above.
Use the GNU version from `homebrew <https://formulae.brew.sh/formula/grep>` instead.
Note that ``brew`` installs the command under the different name ``ggrep`` by default,
so either adjust the hook accordingly or add ``$HOMEBREW_PREFIX/opt/grep/libexec/gnubin``
to your ``$PATH``.

0 comments on commit 8a240e8

Please sign in to comment.