From fa33a2003b9ed530178ff85d4a9cc2f564ceebcc Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Wed, 17 Aug 2022 23:42:32 +0900 Subject: [PATCH] Create .pre-commit-config.yml --- .gitignore | 3 ++- .pre-commit-config.yaml | 9 +++++++++ compiler/erg_common/config.rs | 2 +- compiler/erg_common/traits.rs | 7 +++++-- compiler/erg_parser/parse.rs | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.gitignore b/.gitignore index 1be558fe..b7f527d7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ # These are backup files generated by rustfmt **/*.rs.bk *.pyc +*.pyz /.vscode/ /.VSCodeCounter/ /.vs/ @@ -19,4 +20,4 @@ # Nix .direnv -result \ No newline at end of file +result diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..513977d7 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: + - repo: local + hooks: + - id: rustfmt + name: rustfmt + description: Check if all files follow the rustfmt style + entry: cargo fmt --all + language: system + pass_filenames: false \ No newline at end of file diff --git a/compiler/erg_common/config.rs b/compiler/erg_common/config.rs index cdd23adb..51c31041 100644 --- a/compiler/erg_common/config.rs +++ b/compiler/erg_common/config.rs @@ -4,7 +4,7 @@ use std::env; // use std::env::consts::{ARCH, OS}; use std::fs::File; -use std::io::{BufRead, BufReader, Read, stdin}; +use std::io::{stdin, BufRead, BufReader, Read}; use std::process; // use crate::lazy::Lazy; diff --git a/compiler/erg_common/traits.rs b/compiler/erg_common/traits.rs index b4d1c711..34315c9b 100644 --- a/compiler/erg_common/traits.rs +++ b/compiler/erg_common/traits.rs @@ -9,7 +9,7 @@ use std::slice::{Iter, IterMut}; use std::vec::IntoIter; use crate::color::{GREEN, RESET}; -use crate::config::{ErgConfig, Input, SEMVER, GIT_HASH_SHORT, BUILD_DATE}; +use crate::config::{ErgConfig, Input, BUILD_DATE, GIT_HASH_SHORT, SEMVER}; use crate::error::{ErrorDisplay, Location, MultiErrorDisplay}; use crate::ty::Type; use crate::Str; @@ -311,7 +311,10 @@ pub trait Runnable: Sized { fn new(cfg: ErgConfig) -> Self; fn input(&self) -> &Input; fn start_message(&self) -> String { - format!("{} {SEMVER} (tags/?:{GIT_HASH_SHORT}, {BUILD_DATE}) on {ARCH}/{OS}\n", Self::NAME) + format!( + "{} {SEMVER} (tags/?:{GIT_HASH_SHORT}, {BUILD_DATE}) on {ARCH}/{OS}\n", + Self::NAME + ) } fn finish(&mut self); // called when the :exit command is received. fn clear(&mut self); diff --git a/compiler/erg_parser/parse.rs b/compiler/erg_parser/parse.rs index 621e8207..557e3260 100644 --- a/compiler/erg_parser/parse.rs +++ b/compiler/erg_parser/parse.rs @@ -7,7 +7,7 @@ use std::mem; use erg_common::color::{GREEN, RED, RESET}; use erg_common::config::ErgConfig; -use erg_common::config::{Input}; +use erg_common::config::Input; use erg_common::error::Location; use erg_common::set::Set; use erg_common::traits::Runnable;