Commit a6775491 authored by Felix Häcker's avatar Felix Häcker

add pre-commit hook for rustfmt

parent 24e57e07
Pipeline #64520 passed with stages
in 6 minutes and 49 seconds
......@@ -20,3 +20,16 @@ resources.gresource
tags.*
wip
src/config.rs
/_build/
/target/
**/*.rs.bk
/tags
/.idea/
.buildconfig
**/#*.glade#
**/*.glade~
**/*.json~
**/*.ui~
**/*.gresource
**/#*#
**/tags.*
hook_conf = configuration_data()
hook_conf.set_quoted('CARGO_HOME', join_paths(meson.build_root(), 'target', 'cargo-home'))
hook = configure_file(
input: 'pre-commit.in',
output: 'pre-commit',
configuration: hook_conf
)
message('Setting up pre-commit hook...')
run_command('cp', '-f',
join_paths(meson.build_root(), 'hooks', 'pre-commit'),
join_paths(meson.source_root(), '.git', 'hooks', 'pre-commit')
)
message('Making pre-commit hook executable...')
run_command('chmod', '+x',
join_paths(meson.source_root(), '.git', 'hooks', 'pre-commit')
)
#!/bin/sh
export CARGO_HOME=@CARGO_HOME@
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
......@@ -45,6 +45,7 @@ podir = join_paths (meson.source_root (), 'po')
subdir('po')
subdir('data')
subdir('hooks')
cargo = find_program('cargo', required: false)
gresource = find_program('glib-compile-resources', required: false)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment