Skip to content
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

Implement format hook #271

Merged
merged 4 commits into from
Dec 9, 2018
Merged

Implement format hook #271

merged 4 commits into from
Dec 9, 2018

Conversation

DJMcNab
Copy link
Contributor

@DJMcNab DJMcNab commented Dec 9, 2018

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.

cargo format
for path in $( git diff --name-only --cached ); do
git update-index --add $path
done"#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, let's make a hook itself a rust program, so that it doesn't depend on a particular shell and works on windows?

What I have in mind is to have a src/bin/pre-commit.rs program which basically runs this function.

Then the install-format-hook would run cargo build --release --package tools --bin pre-commit and copy the binary from target/release to ./git/hooks

@matklad
Copy link
Member

matklad commented Dec 9, 2018

bors r+

bors bot added a commit that referenced this pull request Dec 9, 2018
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>
@bors
Copy link
Contributor

bors bot commented Dec 9, 2018

Build succeeded

@bors bors bot merged commit cbce28a into rust-lang:master Dec 9, 2018
@DJMcNab DJMcNab deleted the feat/format_hook branch December 19, 2018 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hassle-free rustfmt setup
2 participants