Skip to content

Conversation

@emilio
Copy link
Contributor

@emilio emilio commented Jul 29, 2017

This patch introduces a super-simple format-diff tool, that allows you to do:

git diff | rustfmt-format-diff -p 1

To format your current changes.

For now it doesn't accept too much customisation, and it basically calls rustfmt
with the default configuration, but more customisation can be added in the
future if needed.

@emilio
Copy link
Contributor Author

emilio commented Jul 29, 2017

Also, note that this is pretty much useless without #1836 and #1841, but hopefully those land soon enough :)

Copy link
Member

@nrc nrc left a comment

Choose a reason for hiding this comment

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

Awesome, thank you! This looks great. Only comment about the code is about using logging. Could you file a tracking issue for things you think are missing for making this a 'complete' feature please?

verbose: bool,
) -> Result<(), FormatDiffError> {
if files.is_empty() || ranges.is_empty() {
if verbose {
Copy link
Member

Choose a reason for hiding this comment

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

Could you use logging (debug! or info!) rather than if verbose here and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I was following the format cargo-fmt was using, but will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

emilio added 2 commits July 31, 2017 09:15
This patch introduces a super-simple format-diff tool, that allows you to do:

```
git diff | rustfmt-format-diff -p 1
```

To format your current changes.

For now it doesn't accept too much customisation, and it basically calls rustfmt
with the default configuration, but more customisation can be added in the
future if needed.
@emilio emilio force-pushed the rustfmt-format-diff branch from 4238baa to 068bcad Compare July 31, 2017 08:39
@nrc nrc merged commit 0e84699 into rust-lang:master Aug 1, 2017
@nrc
Copy link
Member

nrc commented Aug 1, 2017

Awesome, thank you!

@emilio emilio deleted the rustfmt-format-diff branch September 1, 2017 20:19
@kamalmarhubi
Copy link
Contributor

This is really really late @emilio but I wanted to say thanks for building the thing I wanted to build from way back in #434 and #1007. :-)

@ArniDagur
Copy link

Is there a reason why this is a seperate binary, rather than a rustfmt command line argument, e.g. rustfmt --git-diff?

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.

4 participants