Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up[WIP] Add format command to tools crate #163
Conversation
matklad
reviewed
Oct 30, 2018
|
|
||
| fn run_rustfmt() -> Result<()> { | ||
| // Use beta toolchain for 2018 edition. | ||
| run("rustup install beta", ".")?; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
mominul
Oct 31, 2018
Author
Contributor
How about we have a const value like:
const TOOLCHAIN: &str = "beta-2018-10-30";and use it where we need?
This comment has been minimized.
This comment has been minimized.
matklad
reviewed
Oct 30, 2018
| @@ -163,3 +160,11 @@ fn run(cmdline: &'static str, dir: &str) -> Result<()> { | |||
| } | |||
| Ok(()) | |||
| } | |||
|
|
|||
| fn run_rustfmt() -> Result<()> { | |||
This comment has been minimized.
This comment has been minimized.
matklad
Oct 30, 2018
•
Collaborator
It would be cool to have an fn run_rustfmt_precommit, which formats all files changed in git. See this for the proper git command invocation and for how to make rustfmt format a single file: https://github.com/antiochp/grin/blob/121cce7e515f9eca8d8708a262a7cc262ee9b7e9/.hooks/pre-commit#L27
This comment has been minimized.
This comment has been minimized.
|
Oh, and one more stratch goal is to have a test which checks formatting. |
This comment has been minimized.
This comment has been minimized.
|
@matklad We now use a specific toolchain version and there is a test to check the code formatting. Can you check it please? I haven't yet added precommit hook though. |
This comment has been minimized.
This comment has been minimized.
Let's handle that in a separate PR then! Bascially, I think we need to have
which installs the hook (copies relevant files to and
which does the trick. |
This comment has been minimized.
This comment has been minimized.
|
I'll merge this PR manually and run a one-time formatting. |
This comment has been minimized.
This comment has been minimized.
|
BTW, this seems like a common problem, so publishing this as a reusable |
This comment has been minimized.
This comment has been minimized.
|
Ok! I'll create a |
This comment has been minimized.
This comment has been minimized.
|
I'd rather merge this as is! |
matklad
merged commit 857c165
into
rust-analyzer:master
Oct 31, 2018
This comment has been minimized.
This comment has been minimized.
I think it make sense to prototype the git-hook as a PR against this repo, and then extract everyting as a crate: we might find some things to improve after using this for a bit. For example, I've noticed that rustup is not exactly fast, and added some code to check if we already have rustfmt isntalled |
This comment has been minimized.
This comment has been minimized.
|
Ok, I'll start hacking with git pre-commit hook and have a PR here first! After we gain experience, we can bundle them into a crate as you have said. |
mominul commentedOct 26, 2018
I am quite unsure about the implementation of #155 , so I want to get reviews.
Thanks!
Thanks to @alanhdu @CAD97 for discussing the
rustupcommands!