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

Conversation

Projects
None yet
2 participants
@DJMcNab
Copy link
Contributor

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"#

This comment has been minimized.

@matklad

matklad Dec 9, 2018

Collaborator

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

This comment has been minimized.

Copy link
Collaborator

matklad commented Dec 9, 2018

bors r+

bors bot added a commit that referenced this pull request Dec 9, 2018

Merge #271
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

This comment has been minimized.

Copy link
Contributor

bors bot commented Dec 9, 2018

@bors bors bot merged commit cbce28a into rust-analyzer:master Dec 9, 2018

2 checks passed

bors Build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@DJMcNab DJMcNab deleted the DJMcNab:feat/format_hook branch Dec 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment