Skip to content

Commit

Permalink
Pre commit script to auto rustfmt (#1602)
Browse files Browse the repository at this point in the history
* test pre-commit

* remove pre-commit

* first step

* script to install precommit

* use bash
  • Loading branch information
ailisp authored and ilblackdragon committed Nov 3, 2019
1 parent 183fec3 commit 58d0ca2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- repo: https://github.com/doublify/pre-commit-rust
rev: master
hooks:
- id: fmt
19 changes: 19 additions & 0 deletions scripts/install_precommit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

echo "Copying rustfmt.toml into ~/.config/rustfmt/"
mkdir -p "${HOME}"/.config/rustfmt
cp $(dirname "${0}")/../rustfmt.toml "${HOME}"/.config/rustfmt/

if [[ ! -f "${HOME}/.local/bin/pre-commit" ]]; then
echo "installing pre-commit program"
if [[ ! -z "$(command -v pip3)" ]]; then
pip3 install pre-commit
elif [[ ! -z "$(command -v pip)" ]]; then
pip install pre-commit
else
echo "Please install pip3 or pip and rerun this script"
exit 1
fi
fi

"${HOME}"/.local/bin/pre-commit install
11 changes: 0 additions & 11 deletions scripts/pre-commit

This file was deleted.

0 comments on commit 58d0ca2

Please sign in to comment.