Merge commit message template #5955
Replies: 21 comments 10 replies
-
Great idea! One caveat to think about: |
Beta Was this translation helpful? Give feedback.
-
optionally, the template could include variables like "creator", "reviewers" or "labels" |
Beta Was this translation helpful? Give feedback.
-
This would work great for automated changelog management plus it'd be a killer feature for companies using convenvional commits. Pretty please 🙏🏽 |
Beta Was this translation helpful? Give feedback.
-
This would be a great addition for us as well. We use rebase-squash-merge flow, and merge commit message in This means that a bullet-list of commit messages that is by default used as merge commit message is largely useless for us, while PR description is not added to git history, and the only way to see it is to manually pick out the PR number and search for it, which is far from ideal. This proposal would preserve current default behaviour, but would also allow us to customise it to better fit our workflow. |
Beta Was this translation helpful? Give feedback.
-
We would love to see this feature implemented. We are using a gerrit-like workflow where each PR is squashed into 1 commit. However, we also would like to add some extra information like PR id, reviewer list, related issues etc. in the commit message just like Gerrit does. This feature would be beneficial to everyone since it is hard to please everyone by offering some workflows to choose from. It is nice to offer some things, but some people would still prefer customizing their own workflow. We have noticed that GitLab has this feature. A similar template system would be great! |
Beta Was this translation helpful? Give feedback.
-
Using Conventional Changelog and would like to enforce commit message syntax to align with that :) |
Beta Was this translation helpful? Give feedback.
-
Is this still not currently possible? I am aware that we can set a commit template, but changing eg. this: Does not seem possible at all, at least not with Github actions (which is what I am trying to do). Does anyone have any ideas? |
Beta Was this translation helpful? Give feedback.
-
We make a lot of automatic merge requests which need to be approved manually so having a template for these merge request comments that can be checked and filled in by a human would be highly useful. |
Beta Was this translation helpful? Give feedback.
-
Need this to enforce good conventions in our team for automating good changelogs. A template is nice but I'd like to see something further that also prevents malformed commit bodies according to some specific pattern. Thus I would like the template to specify not just content and content slots but also a way to encode what patterns will be accepted or not. At the most basic I think a regex could do the job in some cases, though writing complex regexes that cover patterns spanning multiple lines easily gets complex fast. Still, I'd be so happy for it to be possible at this point, not caring so much about easy–so long as can make the day to day easy with some one-time hard regex authorship :) |
Beta Was this translation helpful? Give feedback.
-
I'd like this too so we can include the PR's branch name (which contains the ticket name) in the message |
Beta Was this translation helpful? Give feedback.
-
Having the PR description go into commit messages is extremely valuable for searchability and portability. I can't grep the log from GitHub and I enjoy being able to read the most complete log I can from wherever my repository is: be it GitHub, local git or GitLab. I use a strictly merge commits workflow on some projects, strictly squash commit on others. I think this would be important for both merge strategies. What some of us do to work without this feature today:
I think we should stick to the basics first, a simple template system just like GitLab. Validations like @jasonkuhrt mentioned would also be nice (GitLab has this too), although I'd be happy with simple templating. *like commenting "merge" on a PR, listening somewhere and doing the merge with the message you want to enforce |
Beta Was this translation helpful? Give feedback.
-
Not really a solution, but I want to
So taking advantage of gh-cli, I added this alias to my mpr = !" \
function merge_github_pr() { \
set -e; \
local RED='\\033[0;31m'; \
local NC='\\033[0m'; \
if [[ \"$(ps -o comm= $PPID)\" =~ ^n?vim$ ]] || [[ \"$(tput colors)\" != \"256\" ]]; then \
RED='~'; NC='~'; \
fi; \
local pr_stats; \
pr_stats=\"$(gh pr status --json number,baseRefName,headRefName,headRepositoryOwner --jq .currentBranch)\"; \
if [[ -z \"$pr_stats\" ]]; then \
printf 'Failed to find PR for current branch!\n'; \
exit 1; \
fi; \
local pr_number; \
local pr_base_ref; \
local pr_head_ref; \
local pr_head_owner; \
local pr_merge_subject; \
pr_number=\"$(jq -r .number <<<\"$pr_stats\")\"; \
pr_base_ref=\"$(jq -r .baseRefName <<<\"$pr_stats\")\"; \
pr_head_ref=\"$(jq -r .headRefName <<<\"$pr_stats\")\"; \
pr_head_owner=\"$(jq -r .headRepositoryOwner.login <<<\"$pr_stats\")\"; \
pr_merge_subject=\"$(printf 'Merge pull request #%d from %s/%s into %s' \"$pr_number\" \"$pr_head_owner\" \"$pr_head_ref\" \"$pr_base_ref\")\"; \
printf 'Gonna merge current branch with subject %b%s%b, sure? [y/n] ' \"$RED\" \"$pr_merge_subject\" \"$NC\"; \
read -n 1 -r; printf '\\n'; \
if [[ \"$REPLY\" != 'y' ]]; then \
exit 0; \
fi; \
git checkout \"$pr_base_ref\"; \
git merge --no-ff --log -m \"$pr_merge_subject\" \"$pr_head_ref\"; \
}; \
merge_github_pr \
" (I know this looks horrible. Don't judge me lol) |
Beta Was this translation helpful? Give feedback.
-
Adding my 2 cents and copying my post in the squash and merge thread in the community forum to here. Like @dp185133 I also want to be able to configure my PR merge commit message for regular merge commits.
|
Beta Was this translation helpful? Give feedback.
-
casually bumping thread that'd be awesome addition to github's templates
would be so great |
Beta Was this translation helpful? Give feedback.
-
In the Unikraft OSS Project we make use of a convention which is not yet possible using GitHub's PR merge system. The result is that merged PRs are marked as "closed" instead of "merged" and we use a custom label Similar to the approach made by the Linux kernel, merging a PR in our project involves an exhaustive review proccess which includes both a "reviewer" and an "approver". These two roles, mapped to GitHub's "reviewer" and "assignee" roles, respectively, guide the PR into a mergable state. The role of the reviewer is to comb through the PR and ensure it works, is an elegant solution, and check it is meets our standards before a merge. The role of the approver (who is a project maintaiinerr) is to double check this and "LGTM" the review and the PR. We ensure that every commit makes sense and leaves the repository in a working state through a single linear history -- it is not simply a case of providing new functionality as it is also about idempotency. Since one of the pilar's of Unikraft as a kernel is security, our philosophy is that every commit and its change reflects a well-defined intention to ensure integrity. As a result and to accommodate for the fact that there can be many people involved in the merging of a PR, we include their name in each commit of the PR. Here is an example commit message:
This means we have had to build a custom mechanism for adopting this philosophy. We use Concourse to achieve this (amongst other benefits it offers as a CI system). The trigger for us is that once the GitHub "assignee" (who has the permission) leaves an There are a number of caveats to the current system, and I speak through the lens of GitHub's API:
One solution is to look at this process even more abstract, and offer the ability to mark the PR as merged as opposed to closed if we can program systematic merging. For example, we use the "special" GitHub Git Trailer to close the commit: |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
This would be a very nice feature PR_ID: PR_TITLE |
Beta Was this translation helpful? Give feedback.
-
+1 for me as well |
Beta Was this translation helpful? Give feedback.
-
I would like to enforce particular message style for the merge commits. It would be very handy to have some
.github/MERGE_COMMIT_TEMPLATE
config file that would be parsed by Github and pre-filled the commit message accordingly when somebody clicks on "Merge pull request" button.In particular, I would like to achieve something like this:
instead of the regular:
Beta Was this translation helpful? Give feedback.
All reactions