File: pre-commit.hook

package info (click to toggle)
libheif 1.3.2-2~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,696 kB
  • sloc: cpp: 10,880; sh: 4,550; python: 3,016; ansic: 283; makefile: 235; xml: 10
file content (47 lines) | stat: -rwxr-xr-x 1,592 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
set -e
#
# HEIF codec.
# Copyright (c) 2018 struktur AG, Joachim Bauch <bauch@struktur.de>
#
# This file is part of libheif.
#
# libheif is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# libheif is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with libheif.  If not, see <http://www.gnu.org/licenses/>.
#
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Assume running from ".git/hooks" folder.
CPPLINT="$ROOT/../../scripts/cpplint.py"
if [ ! -x "$CPPLINT" ]; then
    # Running from "scripts" folder.
    CPPLINT="$ROOT/cpplint.py"
fi

# Run cpplint against changed C/C++ files.
check_enums=
for file in `git diff-index --cached --name-only HEAD --diff-filter=ACMR| grep -E "\.cc$|\.h$|\.c$"` ; do
    "$CPPLINT" "$file"
    if [ "$file" = "libheif/heif.h" ] || [ "$file" = "libheif/heif_emscripten.h" ] ; then
        check_enums=1
    fi
done

if [ "$check_enums" = "1" ]; then
    CHECK_EMSCRIPTEN="$ROOT/../../scripts/check-emscripten-enums.sh"
    if [ ! -x "$CHECK_EMSCRIPTEN" ]; then
        # Running from "scripts" folder.
        CHECK_EMSCRIPTEN="$ROOT/check-emscripten-enums.sh"
    fi
    "$CHECK_EMSCRIPTEN"
fi