-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: move cargo fmt to pre-commit script #2163
Conversation
Kinda weird, the Cirrus CI still runs even though I explicitly |
It seems you have to include
https://cirrus-ci.org/guide/writing-tasks/#conditional-task-execution Still weird though as it worked in #2158. |
I don't know about you, but personally I would find it surprising if the pre-commit script actually changed my code, as opposed to merely checking it. Also, I don't think that the addition of a pre-commit script absolves us from running rustfmt in CI. Because what if some contributor doesn't run the pre-commit script? We have no way to force them to. |
Then it seems that we have to add rustfmt to our CI, because AFAIK, there is no way to make this check compulsory with a pre-commit script |
Yeah, it is indeed weird :< |
@@ -0,0 +1,36 @@ | |||
#!/bin/sh | |||
|
|||
function red() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function
is bash syntax, not sh.
function red() { | |
red() { |
|
||
echo -e "$(green INFO): Checking code format..." | ||
|
||
cargo fmt --all -q -- --check 2>/dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This command doesn't actually work. I just tested it by screwing up the format in src/sys/aio.rs, and this command didn't complain. I think it's caused by this bug: rust-lang/rustfmt#3253 . That's why we need to do cargo fmt --all -- --check **/*.rs
For the format check, are we gonna use a pre-commit script or do it in CI? #2166 has migrated it to GHA, so if we choose the latter, then we can simply close this PR |
Yeah, I think we can close this PR if we merge the other one too. The pre-commit.sh script could be useful too, but maybe not useful enough to justify its ongoing maintenance. |
Close this PR |
What does this PR do
cargo fmt
task to a pre-commit script, and add a doc for it inCONTRIBUTING.md
CONTRIBUTING.md
Checklist:
CONTRIBUTING.md
[skip ci]