issue-parser icon indicating copy to clipboard operation
issue-parser copied to clipboard

Handle Gitlab closing comma separated actions

Open angelkenneth opened this issue 6 years ago • 4 comments

Parser configuration

const issueParser = require('issue-parser');
const parse = issueParser('gitlab');

Text to parse

From: Managing Issues > Default closing pattern

Awesome commit message

Fix #20, Fixes #21 and Closes group/otherproject#22.
This commit is also related to #17 and fixes #18, #19
and https://gitlab.com/group/otherproject/issues/23.

Current Behavior

{
  "actions": {
    "close": [
      {
        "raw": "Fix #20",
        "action": "Fix",
        "prefix": "#",
        "issue": "20"
      },
      {
        "raw": "Fixes #21",
        "action": "Fixes",
        "prefix": "#",
        "issue": "21"
      },
      {
        "raw": "Closes group/otherproject#22",
        "action": "Closes",
        "slug": "group/otherproject",
        "prefix": "#",
        "issue": "22"
      },
      {
        "raw": "fixes #18",
        "action": "Fixes",
        "prefix": "#",
        "issue": "18"
      }
    ],
    "duplicate": []
  },
  "refs": [
    {
      "raw": "#17",
      "prefix": "#",
      "issue": "17"
    },
    {
      "raw": "#19",
      "prefix": "#",
      "issue": "19"
    },
    {
      "raw": "https://gitlab.com/group/otherproject/issues/23",
      "slug": "group/otherproject",
      "issue": "23"
    }
  ],
  "mentions": []
}

Expected behavior

Issue 19 and 23 should be interpreted as close.

If it helps, their parser code is at: closing_issue_extractor.rb

{
  "actions": {
    "close": [
      {
        "raw": "Fix #20",
        "action": "Fix",
        "prefix": "#",
        "issue": "20"
      },
      {
        "raw": "Fixes #21",
        "action": "Fixes",
        "prefix": "#",
        "issue": "21"
      },
      {
        "raw": "Closes group/otherproject#22",
        "action": "Closes",
        "slug": "group/otherproject",
        "prefix": "#",
        "issue": "22"
      },
      {
        "raw": "fixes #18",
        "action": "Fixes",
        "prefix": "#",
        "issue": "18"
      },
      {
        "raw": "#19",
        "prefix": "#",
        "issue": "19"
      },
      {
        "raw": "https://gitlab.com/group/otherproject/issues/23",
        "slug": "group/otherproject",
        "issue": "23"
      }
    ],
    "duplicate": []
  },
  "refs": [
    {
      "raw": "#17",
      "prefix": "#",
      "issue": "17"
    },
    {
      "raw": "#19",
      "prefix": "#",
      "issue": "19"
    },
    {
      "raw": "https://gitlab.com/group/otherproject/issues/23",
      "slug": "group/otherproject",
      "issue": "23"
    }
  ],
  "mentions": []
}

angelkenneth avatar Oct 11 '19 07:10 angelkenneth

The reason is that I mostly based the code on the GitHub behavior. In GitHub fixes #18, #19 applies the fixes keyword to #18 but not to #19.

Can you confirm that in GitLab when closing a PR with fixes #18, #19 both #18 and #19 will be closed?

pvdlg avatar Oct 11 '19 15:10 pvdlg

Hi @pvdlg , for context, i made some projects at GitLab:

  • https://gitlab.com/angelkenneth/issue-closing-sample
  • https://gitlab.com/angelkenneth/issue-closing-other-sample

Default Example

https://gitlab.com/angelkenneth/issue-closing-sample/merge_requests/1

Awesome commit message

Fix #20, Fixes #21 and Closes angelkenneth/issue-closing-other-sample#22.
This commit is also related to #17 and fixes #18, #19
and https://gitlab.com/angelkenneth/issue-closing-other-sample/issues/23.

This Merge Request closes the issues № 20, № 21, № 18, and № 19, but not № 23 for some reason.

Aside: I think № 23 not being closed is a bug, because i was able to do something similar at the 3rd example. I need to do more research if this issue has been raised or not at a future time.

2nd Example

https://gitlab.com/angelkenneth/issue-closing-sample/merge_requests/2

Marvelous commit message

Fixes https://gitlab.com/angelkenneth/issue-closing-sample/issues/11 and #15

This closes issues № 11 and № 15.

3rd Example

https://gitlab.com/angelkenneth/issue-closing-sample/merge_requests/4

Astonishing commit message

Fixes https://gitlab.com/angelkenneth/issue-closing-other-sample/issues/16 and https://gitlab.com/angelkenneth/issue-closing-other-sample/issues/12

This closes external issues № 16 and № 12.

angelkenneth avatar Oct 14 '19 03:10 angelkenneth

Thanks for those info! So it seems keywords have to be applied to each issue reference that are separated by , or and.

Doing that would be a big rewrite of all the regexp in this project so it might takes time...

pvdlg avatar Oct 14 '19 15:10 pvdlg

hi @pvdlg Any updates on this? i wasn't aware that by github doesn't work that way normally. I'm working on a custom action to handle, e.g.: "blocked by: #2001, #2004". I'm currently hacking around it, but it would definitely be awesome if i could get that behavior from issue-parser directly. Thanks for the work you've already put in :)

machinshin avatar Aug 23 '20 01:08 machinshin