Api for merge commit message

Long story short, merge commit messages are our source of truth (they survive things like azure devops → gitlab migrations). And we have a sub-group of folks that love changelogs. And another group that love their gitlab objects (MRs, issues, etc). I’d like to get rid of all this manual propagation of the same text, but I need to be able to change the Merge Commit message. Ideally I can accomplish this by sending some API command to gitlab after the MR approve button is clicked.

Or can i modify a MR commit message after with just the hash?

You could force push an --amend commit on merge, but usually that’s a big nogo since this introduces a point in time where someone else who was pushing in between will loose his/her commit.

If I’m doing it as part of a webhook I think I can live with that risk, however, there doesn’t appear to be an API for that. As part of the webhook I’d have to git clone the repo and force commit using git. There is a great git library for go - but that seems like it will take a long time which makes me uneasy.

I’ve also been looking for a way to “hook into the merge (train?)” while it happens.

In my case, I’d like a merge to “main” to automatically update some submodule pointer within the merge.
We cannot do this in the feature branch as that will cause conflicts when main and one or more features move that pointer to different revisions. However, one of the submodule pointers always is an ancestor to the other, so it could be automatically resolved which pointer to choose.

we are contemplating revoking merge rights on MRs and creating a quick action that allows people to tell the bot to merge. Then we can do all sorts of things to the branch before merging it, set the squashed commit message (which is in the merge api in gitlab), and also do cool things to create downstream merges automatically on other projects if thats appropriate.