File: pre-commit.hook

package info (click to toggle)
obfuscate 0.0.10-13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: sh: 26; makefile: 21; xml: 13
file content (27 lines) | stat: -rwxr-xr-x 694 bytes parent folder | download | duplicates (4)
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
#!/bin/sh
# Source: https://gitlab.gnome.org/GNOME/fractal/blob/master/hooks/pre-commit.hook

if ! which rustup &> /dev/null; then
    curl https://sh.rustup.rs -sSf  | sh -s -- -y
    export PATH=$PATH:$HOME/.cargo/bin
    if ! which rustup &> /dev/null; then
        echo "Failed to install rustup"
    fi
fi

if ! rustup component list|grep rustfmt &> /dev/null; then
    echo "Installing rustfmt.."
    rustup component add rustfmt
fi

echo "--Checking style--"
cargo fmt --all -- --check
if test $? != 0; then
    echo "--Checking style fail--"
    echo "Please fix the above issues, either manually or by running: cargo fmt --all"

    exit -1
else
    echo "--Checking style pass--"
fi