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

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

Closed
AlCalzone opened this issue Jun 30, 2021 · 10 comments · Fixed by #6122

Comments

@AlCalzone
Copy link

AlCalzone commented Jun 30, 2021

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: <...>

@cheap-glitch
Copy link
Member

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.

@AlCalzone
Copy link
Author

I'd consider it a feature request, yes.

@cheap-glitch cheap-glitch added bug enhancement small Issues that new contributors can pick up and removed bug small Issues that new contributors can pick up labels Nov 21, 2021
@fregante fregante added bug small Issues that new contributors can pick up and removed enhancement labels Dec 3, 2021
@fregante
Copy link
Member

fregante commented Dec 3, 2021

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

@cheap-glitch
Copy link
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.

@fregante
Copy link
Member

fregante commented Dec 5, 2021

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

@fregante fregante removed the small Issues that new contributors can pick up label Mar 13, 2022
@yakov116
Copy link
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*"]')

@fregante
Copy link
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?

@yakov116
Copy link
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.

@yakov116
Copy link
Member

refined-github/sandbox#52

It does not close it

@AlCalzone
Copy link
Author

Great, thanks!

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