Skip to content

clear-pr-merge-commit-message should preserve which issues a PR closes when it is not merged into the default branch #4531

Closed

Description

@AlCalzone

I'm looking for a good way to keep a linear commit history, and work on new release branches while being able to preserve GitHub's auto-close feature for issues when a PR gets merged into master. My plan is to merge PRs (I'm squash-merging) into a develop branch and when I deem it to be ready, locally rebase it on top of master, then fast-forward master. Unfortunately the rebase step (or if I were to squash-merge the branch), GitHub forgets which issues should be closed.

If the commit bodies would contain the information of which issues get closed, for example

fixes: #1234
fixes: #4567
...

the commits would still cause Github to close the referenced issues, no matter how the commits finally end up in master.

To summarize, I'm asking for a way to automatically put the linked issues of a PR in the final commit message when the PR is not merged into the default branch. Currently, clear-pr-merge-commit-message clears everything but Co-authored-by: <...>

Activity

  1. added
    small
    and removed on Aug 22, 2021
  2. cheap-glitch commented on Nov 21, 2021

    @cheap-glitch
    Contributor

    To summarize, I'm asking for a way to automatically put the linked issues of a PR in the final commit message when the PR is not merged into the default branch.

    So if I'm not mistaken, this is a not a bug, but a new feature request? Because afaik GitHub doesn't natively include references to the closed issues in the commit description.

  3. AlCalzone commented on Nov 21, 2021

    @AlCalzone
    Author

    I'd consider it a feature request, yes.

  4. added
    small
    and removed
    small
    on Nov 21, 2021
  5. added
    small
    and removed on Dec 3, 2021
  6. fregante commented on Dec 3, 2021

    @fregante
    Member

    This just needs a regex to detect and preserve these fixes/resolves/fix/etc keywords. I consider it a bug as it's breaking native GH behavior

  7. cheap-glitch commented on Dec 4, 2021

    @cheap-glitch
    Contributor

    I consider it a bug as it's breaking native GH behavior

    But afaict, GitHub doesn't automatically add this info to the "extended description" box in the first place.

  8. fregante commented on Dec 5, 2021

    @fregante
    Member

    I consider it a bug as it's breaking native GH behavior

    But afaict, GitHub doesn't automatically add this info to the "extended description" box in the first place.

    It's true that if you link the issue via UI or "fixes" keyword in a comment, they won't add it to the description.

    But they do when fixes #n appears in the commit description itself. This situation is relatively niche, but it's also a regex away. I suppose the regex would be kinda complex however, like:

    (fixe?s?|resolves?|closes?) (issueRegex|urlRegex)
    

    Maybe https://www.npmjs.com/package/regex-join could also help

  9. removed
    small
    on Mar 13, 2022
  10. yakov116 commented on Oct 30, 2022

    @yakov116
    Member

    Don't understand why we cant just do on the first post and extract the issue number

    	select.all('[aria-label="This pull request closes issue*"]')
  11. fregante commented on Oct 31, 2022

    @fregante
    Member

    It wouldn't preserve the same wording but that's totally fine for me. 💙

    We need to verify if this is still happening though, I'd kinda be surprised that GitHub doesn't close the issues regardless of the branch, especially with the new "linked issues" in the sidebar. Do they have the same behavior?

  12. yakov116 commented on Oct 31, 2022

    @yakov116
    Member

    The only way to check is by trying it out 😀

    If I remember correctly they only close if its the default branch by design.

  13. yakov116 commented on Oct 31, 2022

    @yakov116
    Member

    refined-github/sandbox#52

    It does not close it

  14. AlCalzone commented on Nov 13, 2022

    @AlCalzone
    Author

    Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions