Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append PR number to merge commit message #255

Open
hwhsu1231 opened this issue Feb 21, 2024 · 2 comments
Open

Append PR number to merge commit message #255

hwhsu1231 opened this issue Feb 21, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@hwhsu1231
Copy link

hwhsu1231 commented Feb 21, 2024

Feature Request

When merging a pull request on the GitHub web client, the suggested commit message (at least in the case of a squash commit, which we always use) will automatically include the number of the PR in parentheses, like so:

Update project files (#123)

However, when merging using this GitHub Action, the first line of the commit message will look like this:

Update project files

No matter what option of MERGE_COMMIT_MESSAGE I choose:

  • automatic
  • pull-request-title
  • pull-request-description
  • pull-request-title-and-description

Therefore, I hope that it can append (#NUM) to the first line of the commit message for all possible options.

Versions

Current latest release: v0.16.2

@hwhsu1231
Copy link
Author

Related to this part?

function getCommitMessage(mergeCommitMessage, pullRequest) {
if (mergeCommitMessage === "automatic") {
return undefined;
} else if (mergeCommitMessage === "pull-request-title") {
return pullRequest.title;
} else if (mergeCommitMessage === "pull-request-description") {
return pullRequest.body;
} else if (mergeCommitMessage === "pull-request-title-and-description") {
return (
pullRequest.title + (pullRequest.body ? "\n\n" + pullRequest.body : "")
);
} else {
return mergeCommitMessage.replace(PR_PROPERTY, (_, prProp) =>
resolvePath(pullRequest, prProp)
);
}
}

@hwhsu1231
Copy link
Author

Hello, @pascalgn

I think the current alternative to appending PR number is to customize the commit message ourselves. For example, if I want to append a PR number to "pull-request-title" option of MERGE_COMMIT_MESSAGE, I can write it like this:

{pullRequest.title} (#{pullRequest.number})

The full example may look like this:

- name: Automerge a PR with 'automerge' label
  id: automerge
  uses: "pascalgn/automerge-action@v0.16.2"
  env:
    GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
    MERGE_METHOD: 'squash'
    MERGE_COMMIT_MESSAGE: '{pullRequest.title} (#{pullRequest.number})'
    UPDATE_METHOD: 'rebase'

But I hope that this GitHub Action can append (#PR) to the title of message by default. Can you fix this issue by appending (#PR) for all the options of MERGE_COMMIT_MESSAGE?

@pascalgn pascalgn added the enhancement New feature or request label Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants