Imgbot icon indicating copy to clipboard operation
Imgbot copied to clipboard

Allow to customize commit message

Open Liu233w opened this issue 4 years ago • 23 comments

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.

Liu233w avatar Mar 27 '20 11:03 Liu233w

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?

dabutvin avatar Mar 27 '20 17:03 dabutvin

Hi @dabutvin In my point of view, a customizable title is ok, because commitlint only check the title.

Liu233w avatar Mar 28 '20 02:03 Liu233w

@dabutvin @Liu233w I could take a stab at this, at the ability to configure the title.

daveabrock avatar May 02 '20 23:05 daveabrock

@daveabrock awesome! Let me know if you need any help getting started here or anything

dabutvin avatar May 10 '20 16:05 dabutvin

also, check out #232 when you get in there for more background on the requests in this area

dabutvin avatar May 10 '20 16:05 dabutvin

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?

daveabrock avatar May 13 '20 00:05 daveabrock

We don't need to solve everything all at once, if you got something we can ship then let's do it!

dabutvin avatar May 13 '20 00:05 dabutvin

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.

daveabrock avatar May 13 '20 00:05 daveabrock

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

dabutvin avatar May 13 '20 01:05 dabutvin

Ah! Got it now! Thanks.

daveabrock avatar May 13 '20 01:05 daveabrock

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?

daveabrock avatar May 13 '20 01:05 daveabrock

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

dabutvin avatar May 13 '20 01:05 dabutvin

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?

daveabrock avatar May 13 '20 13:05 daveabrock

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

dabutvin avatar May 13 '20 17:05 dabutvin

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.

stale[bot] avatar Jul 12 '20 18:07 stale[bot]

Up

moul avatar Jul 13 '20 10:07 moul

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.

daveabrock avatar Jul 14 '20 15:07 daveabrock

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.

stale[bot] avatar Sep 12 '20 15:09 stale[bot]

Up :)

moul avatar Sep 12 '20 18:09 moul

In my point of view, a customizable title is ok, because commitlint only check the title.

Anmol368 avatar Dec 01 '20 16:12 Anmol368

Sheesh, it's been 7 months hasn't it? I have a lot of time off this month and hope to code this soon. :)

daveabrock avatar Dec 01 '20 18:12 daveabrock

Not 100% sure if it's a good idea, but having a custom body would allow auto DCO signing (and other git footer stuff)

moul avatar Dec 01 '20 19:12 moul

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.

GrigoreMihai avatar Oct 27 '21 14:10 GrigoreMihai