Create .pre-commit-config.yml

This commit is contained in:
Shunsuke Shibayama 2022-08-17 23:42:32 +09:00
parent fa6979fed2
commit fa33a2003b
5 changed files with 18 additions and 5 deletions

3
.gitignore vendored
View file

@ -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
result

9
.pre-commit-config.yaml Normal file
View file

@ -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

View file

@ -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;

View file

@ -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);

View file

@ -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;