Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a largish refactoring which was necessary in order to support
--isort
together with the new--diff
option.The patch ditches the original approach in which
git diff
was used to get the changes between HEAD and the worktree for all requested files in one go, and the output was parsed into a list of changed line numbers for each file.Instead, the HEAD, worktree and (optionally) isorted versions of the file are read/generated in Python and compared against each other.
This required quite a bit of changes, and as I did them I also structured the code a bit better into descriptive modules, and did some clean-up.
This should be merged only after #4.
If this turns out too massive for review, I can try to split it up into smaller PRs – it's just that those interim steps will look a bit silly without knowing the ultimate motivation.
The main changes are:
--isort
and--diff
now work togethergit diff
outputisort
for edited filesisort
modifications together withblack
modifications, and skip writing if there are errors