mariatta / black_out Goto Github PK
View Code? Open in Web Editor NEW๐๐๐ค GitHub bot that formats code with `black`
License: Apache License 2.0
๐๐๐ค GitHub bot that formats code with `black`
License: Apache License 2.0
When submitting PR, check "allow edits from maintainers".
I don't think you need write permission.
For the requirement of "Blacken incoming pull request", I think there is a project that is similar to your requirement
https://github.com/dwoz/salt-pr-tools
Nice work on this project! I've been looking for something like it for some time.
I'm wondering if the bot could be configured to run pre-commit. That way, it could do more than just format with black.
pre-commit
+ a GitHub bot would ensure that unformatted code never gets merged, and would take the burden off maintainers and contributors.
In an ideal world, unformatted code never gets committed because pre-commit prevents it. In a realistic world, contributors may forget to install the pre-commit hooks. The black_out
bot would be the last resort, making the formatting commit for you.
(disclamer: rewriting history of merged commits is bad, I know, just exploring the idea for the sake of it)
In the one hand, rewriting history is bad. But in the other a huge big bang commit is equally bad for being able to use git blame
and understanding where a commit comes from.
So I would find it interesting to be able to retrospectively blacken all commits in git history one by one in a PR. Or if you're YOLO, for the whole repo.
For the whole repo, this can be done with git filter-branch --tree-filter "git ls-files |xargs black" -- --all
. (it a similar construct for a single PR with something instead of --all
, probably <target-branch>..<pr-branch>
but I haven't tried). But in real life you don't want to rewrite history of your whole repo, that would be bad.
This would mean the bot would rewrite commits but as far as I can tell, git filter-tree doesn't change the committer, so it wouldn't appear as co-author (we could add a Co-Authored-By` field, though). But, quite logically, this removes GPG signature from commits and tags. And rewriting the whole repo is madness, did I mention it ? Would be cool still. ๐
What I mean is that high-volume, actively developed repos it might be unable to afford reformatting of the entire code base at once.
Instead, it would be less painful and non-blocking if bot could do blackening file by file or even better - update chunks and send new PRs once previous have been merged. It could even do bigger chucks against rarely changed code at the beginning and slow down and be more picky about the code someone is currently editing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.