Skip to content

Commit

Permalink
Added autoformatting to .vscode/settings.json and updated the hooks/p…
Browse files Browse the repository at this point in the history
…re-commit message
  • Loading branch information
ryancwalsh committed Aug 19, 2022
1 parent 82ae876 commit 40405a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"editor.tabSize": 4
"editor.tabSize": 4,
"[rust]": {
"editor.formatOnType": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "rust-lang.rust-analyzer"
},
}
23 changes: 5 additions & 18 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,6 @@
#
# In the project directory, run `git config core.hooksPath hooks/` to install the hooks of this directory (without affecting how git hooks work for other projects).

# To avoid having this pre-commit hook block your commits, configure your VSCode like this:

# {
# "editor.formatOnPaste": true,
# "editor.formatOnSave": true,
# "editor.formatOnType": true,
# "editor.codeActionsOnSave": {
# "source.fixAll.eslint": true
# },
# "[rust]": {
# "editor.formatOnSave": true,
# "editor.defaultFormatter": "rust-lang.rust-analyzer"
# },
# //...
# }


# https://www.atlassian.com/git/tutorials/git-hooks#local-hooks
# https://near-foundation.atlassian.net/browse/ENG-149

Expand All @@ -29,7 +12,11 @@ RED='\033[0;31m'
RESET='\033[0m' # No Color

if [[ ${result} -ne 0 ]] ; then
printf "${RED}Formatting / style errors.${RESET}\n\n Please read the comments at hooks/pre-commit to see how to configure VSC to avoid this problem.\n\n Alternatively, you can always run \`cargo fmt\` before committing code. Here is the current result of \`cargo fmt -- --check\`:\n\n"
printf "${RED}Formatting / style errors.${RESET}\n\n"
printf " To avoid having \`hooks/pre-commit\` block your commits, ensure that your IDE is configured to autoformat Rust code via \`cargo fmt\`.\n"
printf " If you use VSCode, the \`.vscode/settings.json\` file in this repo will autoformat code appropriately.\n"
printf " Alternatively, you can always run \`cargo fmt\` before committing code.\n"
printf " Here is the current result of \`cargo fmt -- --check\`:\n\n"
echo "$diff"
exit 1
fi
Expand Down

0 comments on commit 40405a0

Please sign in to comment.