This is a personal experiment, and still in progress.
I'm wanting a GitHub bot that can:
black, and only format the affected changed files.
How to blacken an entire repo initially, for a project that did not use
before? I guess someone needs to check out the repo, run
black, then commit
the changes and create a pull request. They need to be on a computer to do this!
What if I have more than one projects to blacken? Seems like a lot of manual boring work and potentially a lot of repetition.
So I want a bot to do those boring things.
What I had in mind:
My bot will listen to one of the following commands as cue to start blacken the repo:
turn off the sun
take down the moon
switch off the stars
paint the sky black
black out the sun
All stolen from Darren Hayes of course.
Once I've blacken an entire repo, perhaps it's a good idea to ensure incoming changes are blackened too, and maybe it should be part of some CI.
I'm not aware if there's such CI yet. Seems like the recommended way is to
install pre-commit, setup the configuration
file, and then run it. Just sounds like a lot of work to me. (I'm very lazy!)
What if anyone can write their code the way they usually do, but when they
propose the pull request, a bot can run
black against the changed code,
and push the reformatted code back to the pull request?
I don't know if this is a good idea or not, but it could be fun experiment. 😄
Another thought is, instead of blacken incoming pull requests, I'll just schedule the entire repo to be blackened once a week.
I've made it such that the bot will black out a PR when the label
black out is
In Heroku, set the environment variables:
GH_USERNAME: The GitHub username for the bot user. The bot user must have write access to the repo being blackened.
GH_EMAIL: The email address for the bot user. The bot user must have write access to the repo being blackened.
GH_FULL_NAME: The full name of the bot user. The bot user must have write access to the repo being blackened.
GH_AUTH: The oauth token for the bot user.
GH_SECRET: The GitHub webhook secret.
Add the Heroku Redis add-on, and turn it on.
Enable the webhook events on:
The bot needs write access to the repo to be blackened.
With the current design, I'll need to deploy an instance of
black_out for every
GitHub repo I want to blacken. ☹️ It's still not what I want out of this project.
I think I'll need to make it into a GitHub App
, but I don't yet know how to do that. 🙃