-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
271: Implement format hook r=matklad a=DJMcNab Tentatively: fixes #155. However, this does add all changes in staged files, which might not be desirable. However, I think we can't solve that without explicit support in rustfmt for it, so it should be fine. Co-authored-by: DJMcNab <36049421+djmcnab@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
75 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
[alias] | ||
# Automatically generates the ast and syntax kinds files | ||
gen-syntax = "run --package tools -- gen-syntax" | ||
gen-tests = "run --package tools -- gen-tests" | ||
install-code = "run --package tools -- install-code" | ||
format = "run --package tools -- format" | ||
gen-syntax = "run --package tools --bin tools -- gen-syntax" | ||
gen-tests = "run --package tools --bin tools -- gen-tests" | ||
install-code = "run --package tools --bin tools -- install-code" | ||
format = "run --package tools --bin tools -- format" | ||
format-hook = "run --package tools --bin tools -- format-hook" | ||
|
||
render-test = "run --package ra_cli -- render-test" | ||
parse = "run --package ra_cli -- parse" | ||
render-test = "run --package ra_cli -- render-test" | ||
parse = "run --package ra_cli -- parse" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use std::{ | ||
process::{Command}, | ||
}; | ||
|
||
use tools::{Result, run_rustfmt, run, project_root}; | ||
use failure::bail; | ||
|
||
fn main() -> tools::Result<()> { | ||
run_rustfmt(tools::Overwrite)?; | ||
update_staged() | ||
} | ||
|
||
fn update_staged() -> Result<()> { | ||
let root = project_root(); | ||
let output = Command::new("git") | ||
.arg("diff") | ||
.arg("--name-only") | ||
.arg("--cached") | ||
.current_dir(&root) | ||
.output()?; | ||
if !output.status.success() { | ||
bail!( | ||
"`git diff --name-only --cached` exited with {}", | ||
output.status | ||
); | ||
} | ||
for line in String::from_utf8(output.stdout)?.lines() { | ||
run( | ||
&format!( | ||
"git update-index --add {}", | ||
root.join(line).to_string_lossy() | ||
), | ||
".", | ||
)?; | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters