File: check-version.hook

package info (click to toggle)
ceccomp 3.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,528 kB
  • sloc: ansic: 3,154; python: 653; makefile: 240; sh: 226
file content (35 lines) | stat: -rwxr-xr-x 1,043 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
#!/bin/bash

COMMIT_MSG_FILE="$1"

if [[ $COMMIT_MSG_FILE == "install" ]]; then
    ln -sf ../../scripts/$(basename $0) .git/hooks/commit-msg
    echo "commit-msg hook installed"
    exit 0
fi

VERSION_REGEX='\b[0-9]+\.[0-9]+\b'

print_highlight() {
    echo -e "\x1b[33m$1\x1b[0m" >&2
}

if grep -qE "$VERSION_REGEX" "$COMMIT_MSG_FILE"; then
    print_highlight "========================================"
    print_highlight "Version update detected!"
    print_highlight "Please check if updated configure"
    print_highlight "========================================"
    print_highlight
    python3 scripts/complete-url.py --check > /dev/null
    action_req=$?
    if [ $action_req -eq 1 ]; then
        print_highlight "========================================"
        print_highlight "There are raw reference to issues/pulls in CHANGELOG!"
        print_highlight "Please run scripts/complete-url.py to format"
        print_highlight "========================================"
        print_highlight
        exit 1
    fi
fi

exit 0