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)
- 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 HOT 1
- 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 3
- Really-43e2c HOT 2
- Renaming path and then renaming it back to the original name deletes path rather than renaming it (renaming to another path that exists has weird side effects) HOT 2
- Case-insenstive APFS volumes causing refs lock problem? HOT 1
- [Question] Repo size not shrinking after using --invert-paths HOT 6
- Clone rather than edit
- --paths-from-file only works with directories HOT 1
- `--dry-run` removes quotation marks from paths in `fast-export.filtered` HOT 5
- Unable to create 'myrepo.git/./packed-refs.lock': File exists. Confirmed that ubuntu volume is case sensitive HOT 10
- --tag-callback only executes on annotated tags, not lightweight tags HOT 3
- FIlter problem HOT 2
- [Question] Lost all folders HOT 1
- Repo not shrinking, number of commits doubles
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.