Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically closing issue from pull request in GitHub

How do I close an issue using a pull request on GitHub? I know about closing multiple issues with a commit message, but it's a different case.

I would like to close the issues not from a commit, but from the description of the pull request. More like

Pull request:

Name: bla bla
Description ... , _fixes_ #123

And when merging the pull request, the #123 to automatically close. Is this possible?

like image 651
Andrei-Niculae Petre Avatar asked Sep 02 '12 11:09

Andrei-Niculae Petre


People also ask

How do I auto close an issue in GitHub?

It is on that commit message you can add a " close #xx " in order to trigger the closing of an issue. However, as mentioned in "Closing multiple issues in Github with a commit message", in GitHub blog post "Closing Issues via Commit Messages" (January 2013), and in the current GitHub docs.

How do you close a pull request problem?

You can also use closing keywords in a commit message. The issue will be closed when you merge the commit into the default branch, but the pull request that contains the commit will not be listed as a linked pull request.

How do I close a pull request on GitHub?

Under your repository name, click Pull requests. In the "Pull Requests" list, click the pull request you'd like to close. At the bottom of the pull request, below the comment box, click Close pull request. Optionally, delete the branch.


2 Answers

As you mention in the comments, the merge from the pull request will result in a commit.
It is on that commit message you can add a "close #xx" in order to trigger the closing of an issue.

However, as mentioned in "Closing multiple issues in Github with a commit message", in GitHub blog post "Closing Issues via Commit Messages" (January 2013), and in the current GitHub docs.

Now when you enter "Fixes #33" in a commit message, issue 33 will only be closed once the commit is merged into your default branch (usually master).

This is super useful because it means the issue's open / closed status will map to your default branch.
If the bug isn't fixed in your default branch, the issue will remain open.
Once the commit with the fix is merged into your default branch the issue will be automatically closed.

When you do make a commit in a non-default branch with the "Fixes #33" syntax, the issue will be referenced with a tooltip:

Closing Issue

You can use any of these keywords to close an issue via commit message:

close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved

As mentioned below by cosmolev (upvoted), the blog post from May 14th 2013 "Closing Issues via Pull Requests" adds pull requests as a way to close an issue:

some issues take more work than a single commit to close.
That's why you can now close an issue from a Pull Request.
All you have to do is include the special keyword syntax (eg. "fixes #5") in the body of your Pull Request.

comment on pull request

the referenced issue will automatically be closed when the PR is merged into the default branch.
It even works across repositories.

As John Eikenberry points out in the comments, the help page "Closing issues using keywords" does mention:

To close multiple issues, preface each issue reference with one of the above keywords.
You must use the keyword before each issue you reference for the keyword to work.

For example, This closes #34, closes #23, and closes example_user/example_repo#42 would close issues #34 and #23 in the same repository, and issue #42 in the "example_user/example_repo" repository.

like image 149
VonC Avatar answered Sep 23 '22 19:09

VonC


It's finally possible: https://github.com/blog/1506-closing-issues-via-pull-requests

Just add resolve #18 to pull request message

where 18 is an issue number

like image 27
Leo Avatar answered Sep 21 '22 19:09

Leo