Imgbot
Imgbot copied to clipboard
Allow to customize commit message
Hi, It will be great if it's allowed to customize the commit message of imgbot, so that we can use conventional commit format without failing commitlint check.
Hi @Liu233w
Love this idea! Are you thinking just to be able to customize the title of the commit message or the whole body as well? Do you see this being configured in the .imgbotconfig
file?
Hi @dabutvin In my point of view, a customizable title is ok, because commitlint only check the title.
@dabutvin @Liu233w I could take a stab at this, at the ability to configure the title.
@daveabrock awesome! Let me know if you need any help getting started here or anything
also, check out #232 when you get in there for more background on the requests in this area
Hey @dabutvin - I have a PR almost ready, with it checking for a value from .imgbotconfig
and populating the title in the commit message and the pull requests (with tests, of course). Any interest in commit formatting logic, like what is referenced in #232, or should we push out what we have and build off it as needed?
We don't need to solve everything all at once, if you got something we can ship then let's do it!
Last thing is just the OpenPr
updates, and then I'll be done with it.
Any advice on accessing the .imgbotconfig
file from OpenPr.cs
to check for the commit title (or just passing down the title)? In CompressImages.cs
, you grab the file like this before deserializing:
var repoConfigJson = File.ReadAllText(parameters.LocalPath + Path.DirectorySeparatorChar + ".imgbotconfig");
From what I understand, the LocalPath
property's parameters
object has come from a cloned temporary directory, but in the PR level, we don't have access to that. All my ideas are suuuuuper-hacky, any advice?
In OpenAsync
in the PullRequest
class, I take in a RepoConfiguration
object but not sure how to pass it down from the top function level, if that makes sense.
sure!
Check out Stats.cs The commit message will have the commit title at this point and we can parse the PR title from the first line in the message.
Will probably have to return a different type so we can hold the title and all the stats
Ah! Got it now! Thanks.
I should probably run the function before submitting the PR and not relying on unit tests alone. :)
So do I need to generate these secrets in my own repo to test? The APP_PRIVATE_KEY
, PGP_PRIVATE_KEY
, PGP_PASSWORD
, TMP
?
Yep. I use a GitHub app just for local testing a lot. You can create one in the GitHub settings to get the app private key.
The pgp is just for commit signing and you can turn that off if you want.
Tmp is where the repo will get cloned
Let me know if you run into issues
Sorry @dabutvin, for all the newb questions but I've never registered a GitHub app before - any thoughts on how to "link" this to my repo? I see callback and hook URLs - how do you have it set up?
go to your apps landing page and configure it to be in a repo for example, here is one i use with localhost a lot https://github.com/apps/imgbot-local
It's considered an "installation" and gives you access to the repo All the callbacks and hooks are for triggers, but you can just trigger the function yourself once you have the permissions
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Up
Yes! I hope to return to this one next week or two - it got away from me. Just need to work on testing it locally and whatnot, I think the code is good.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Up :)
In my point of view, a customizable title is ok, because commitlint only check the title.
Sheesh, it's been 7 months hasn't it? I have a lot of time off this month and hope to code this soon. :)
Not 100% sure if it's a good idea, but having a custom body would allow auto DCO signing (and other git footer stuff)
Some hints to help you with this: the commit message is created here: https://github.com/imgbot/Imgbot/blob/master/CompressImagesFunction/CompressImages.cs#L184 you can add one more parameter to the Create
function and send the commit title which will be used here: https://github.com/imgbot/Imgbot/blob/d84e59634bab397fc02f7eb9e17d828b0bc99e71/CompressImagesFunction/CommitMessage.cs#L12 .It should be pretty easy to implement and with some tests here: https://github.com/imgbot/Imgbot/blob/master/Test/CommitMessageTests.cs it will be ready.