DEV Community

Cover image for GitHub: Understand issue close keywords with experiments
Yuko
Yuko

Posted on • Edited on

GitHub: Understand issue close keywords with experiments

GitHub: Understand issue close keywords with experiments

This is my memo about GitHub issues. In this article I will focus on the close key word which allows you to close the linked issue automatically when your pull request is merged with the default branch. I would be happy if you could provide your own usage rules, since I am interested in real life usage.

Basic knowledge about close keywords
Experiments
Learn from an open source project

Basic knowledge about close keywords

These 9 words are close keywords which you can link to issues when you open a pull request.

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

The issue will be closed when your branch is merged into the default branch. In other words, when your pull request is not on the default branch, your pull request is linked to the issue, but the issue won’t be closed automatically after your pull request is closed.

Syntax

Pattern1: Issue in the same repository

//syntax
KEYWORD #ISSUE-NUMBER

// example1
close #10

// example2
I added something to fix #1
Enter fullscreen mode Exit fullscreen mode

Pattern2: Issue in a different repository

//syntax
KEYWORD OWNER/REPOSITORY#ISSUE-NUMBER

// example
resolve Lada496/github-practice#1
Enter fullscreen mode Exit fullscreen mode

Pattern3: Multiple issues

//syntax
list all linked issues with syntax above

// example
resolved #10, resolved #11, fixed resolve Lada496/github-practice#12

Enter fullscreen mode Exit fullscreen mode




Where to put this keywords

There are two options: 1) the comment on your pull request and 2) your commit message.

The differences between PR comment and commit message

The linked issue is automatically closed but the pull request that contains the commit will not be listed as a linked pull request when you use the commit message. On the other hand, the linked issue is automatically closed and the pull request will be listed as a linked pull request when you use PR comment. I will show you what exactly this means in the experiment part.
Linking a pull request to an issue - GitHub Docs

Experiments

There are two questions that I wanted to determine: 1) What happens if you merge a branch into the default branch after the branch is merged with another branch linked to an issue? and 2) What exactly differences between PR comments and commit messages.
Experiment1: On which should the issue linked pull request be?

condition: the default branch is main

expectation:
1) your pull request is on the develop branch -> No
2) your pull request is on the main branch -> Yes
3) your pull request is develop and the develop branch is merged to main -> Yes??

1 and 2) are obviously true, but I went through all the patterns during the process and determined whether 3) is true or not.

1) is true
Add close keywords in PR comment
Add close keywords in PR comment

The PR is linked but the issue status is still open
The PR is linked but the issue status is still open

3) is not true
Open PR after develop experiment1–1 was merged into develop
Open PR after develop experiment1–1 was merged into develop

The number is 19
The number is 19

The commit was not linked to this issue nor closed it
The commit was not linked to this issue nor closed it

2) is also true
PR to the default branch with close keywords
PR to the default branch with close keywords

The issue was automatically closed
The issue was automatically closed

Experiment2: Where to put closing key words

1)commit message

when you put a close keyword in the commit message
when you put a close keyword in the commit message

You will go to the commit history page when you click the link
You will go to the commit history page when you click the link

2)PR comment
when you put a close keyword in the PR comment
when you put a close keyword in the PR comment

You will go to the PR history when you click the link
You will go to the PR history when you click the link

Learn from an open source project

I visited an open source project (React bootstrap) to see how they use issues. I was especially interested in which is better to put close key words. As a result, they use both.

These are typical examples.
Missing export for ModalHeader · Issue #6226 · react-bootstrap/react-bootstrap
Tabs component has no Fade transition by default · Issue #6232 · react-bootstrap/react-bootstrap
When a tooltip is visible and you start scrolling, the tooltip appears above other elements. ·…

However, the sample size is too small to conclude that this is the best practice. Therefore please tell me if you have any opinion about it.

Thank you for reading :)

The original article is here

Top comments (0)