File: code-style-git-post-commit-hook

package info (click to toggle)
network-manager 1.54.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 71,424 kB
  • sloc: ansic: 483,661; python: 11,632; xml: 8,546; sh: 5,555; perl: 596; cpp: 178; javascript: 130; ruby: 107; makefile: 60; lisp: 22
file content (21 lines) | stat: -rwxr-xr-x 413 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

set -e

DISABLED=${NM_HOOK_DISABLED:0}

if [ "$DISABLED" == 1 ]; then
    echo "COMMIT HOOK DISABLED"
    exit 0
fi

FORMATTER=contrib/scripts/nm-code-format.sh

# Filter only C source files
CHANGED_FILES=$(git log --pretty='' --name-only -n1 | grep -E '\.c$|\.h$' | tr '\n' ' ')

echo $CHANGED_FILES

if [ -x "$FORMATTER" ] && [ ! -z "$CHANGED_FILES" ]; then
    "$FORMATTER" -n "${CHANGED_FILES}"
fi