Show Crosslinked/related issues in merge requests via the API

Proposal

BLUF: Include crosslinked issues when querying merge requests via the API

Context

The following MR: nmcd/pub!1 (closed)

  • Mentions issue 2 in the title
  • A commit message to the MR contains issue 3
  • A comment in the MR mentions issue 1
    • This discussion was then created into a new issue 4, resolving the discussion

Currently, we can see what issues close when this MR is merged:

curl -s -H  "PRIVATE-TOKEN: $TOKEN" "https://gitlab.com/api/v4/projects/57858823/merge_requests/1/closes_issues" \
| jq '.[].iid'

Returns:

2
3

Two new issues were made:

  • 4 - Created from a discussion in the MR
  • 5 - Newly created issue, which commented the MR link

Ideally, there should be an option in the API to return "related issues" for merge requests. This currently exists the other way around, whereby an issue will have "related merge requests" if an MR was mentioned in it.

PoC

curl -s -H  "PRIVATE-TOKEN: $TOKEN" "https://gitlab.com/api/v4/projects/57858823/merge_requests/1/related_issues" \
| jq '.[].iid'

Should return:

1 # this issue was commented in the MR
2 # this issue is mentioned in the MR's title
3 # a commit to the MR mentions this issue in the message
4 # this issue was created from the issue1 discussion (from the MR)
5 # this issue has a comment which links to the MR
461536 # this current issue (because the MR was added to the description of this issue)
Edited by Neil McDonald