Comments (7)
Thanks for this! If anybody finds this useful, I extended @JacobHayes 's code to also reformat Jupyter notebook cells: https://github.com/shenker/nbcleanse/blob/master/nbcleanse.py
from git-filter-repo.
Thanks @newren and people in this thread for the inspiration, here is another adaptation of the lint example.
This time it is meant to format Java
code using formatter-maven-plugin and custom style (for example) .
Files are processed in batches. Path to the style should be changed to the real one.
Here is gist: 🔗 .
from git-filter-repo.
Perfect, got it working. Thanks again!
from git-filter-repo.
filter-repo avoids checking out any of the files onto disk, which is part of its speedup. In that sense filter-repo's tree-filter is a bit easier to use here since your linting program probably expects the file on disk in normal format rather than trying to read it from git's history. However, contrib/filter-repo-demos/lint-history was specifically written to show how to lint files in history. You could just call it as
lint-history black
and have it lint every non-binary file in history for you, or you could tweak it to only call the linter for .py files (while keeping all other files as-is).
Also, the lint-history example actually includes three different implementations of how to do it: one in a comment showing how you could do it without writing a full-fledged python script that imports filter-repo, one which does it as a blob callback assuming that it doesn't matter to the lint program what the name of the file is (it just writes every file to .git/info/tmpfile
and then runs the linter on that), and a third one that does it as a commit callback which makes sure the basename of the file is the same. You'll only need to use one of the three, but all three are in the demo since it's just trying to demonstrate how things could be done.
from git-filter-repo.
Thanks @newren, I'll try that out! It was close to working with:
git filter-repo --force --blob-callback '
import black
blob.data = black.format_str(blob.data.decode(), mode=black.FileMode()).encode()
'
but I needed to only reformat the python files and couldn't figure out how to limit it. Should be able to put something together with the lint-history commit-callback version!
from git-filter-repo.
Thanks everyone for posting examples here; I put a comment pointing at this issue in the lint-history code so that others will be more likely to find all your examples.
from git-filter-repo.
Adapted your script into #464 that allows to add new or replace files produced from shell commands.
from git-filter-repo.
Related Issues (20)
- Update submodule hashes?
- Renaming paths into pre-existing path causes double-nested paths (sometimes)
- Keep last 3 months of package-lock.json diffs only HOT 1
- Question: prune lfs files
- remark: Pity that this tool can't run scripts/programs and it is not clearly stated HOT 1
- minor: Logic error with `_commits_referenced_but_removed` on a GitHub Gist web url in commit message 😂
- Crash when path contains emoji HOT 1
- Question: Recommended way to log the usage of git filter-repo and related changes? HOT 1
- Callback that gives both filename and blob
- Breaking change in git 2.43 or 2.44 HOT 2
- lint-history: --refs argument not working at all HOT 1
- Test suite succedes with Python 3.11 but has multiple failures with Python 3.12 HOT 7
- Turns out my assumption was wrong: `git lfs migrate export --everything --include="*"` does rewrite the whole history, across all branches, reinjecting all the large files' consecutive versions ([see here](https://github.com/git-lfs/git-lfs/issues/910#issuecomment-551566315)). Awesome! HOT 1
- Support for SHA256
- FR: Filter into new repo HOT 1
- clean-ignore of filter-repo-demos does not handle utf-8 characters HOT 1
- Trouble with Lock File HOT 1
- Really-43e2c HOT 2
- > main HOT 1
- Renaming path and then renaming it back to the original name deletes path rather than renaming it HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git-filter-repo.