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

Handle Gitlab closing comma separated actions #37

Open
angelkenneth opened this issue Oct 11, 2019 · 4 comments
Open

Handle Gitlab closing comma separated actions #37

angelkenneth opened this issue Oct 11, 2019 · 4 comments
Labels

Comments

@angelkenneth
Copy link

angelkenneth commented Oct 11, 2019

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": []
}
@pvdlg
Copy link
Member

pvdlg commented Oct 11, 2019

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?

@angelkenneth
Copy link
Author

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

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.

@pvdlg
Copy link
Member

pvdlg commented Oct 14, 2019

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 pvdlg added the bug label Oct 14, 2019
@machinshin
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants