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

gitlab issue gaps with size > 1 not handled correctly #54

Closed
maks-io opened this issue Aug 17, 2019 · 0 comments · Fixed by #55
Closed

gitlab issue gaps with size > 1 not handled correctly #54

maks-io opened this issue Aug 17, 2019 · 0 comments · Fixed by #55

Comments

@maks-io
Copy link
Contributor

maks-io commented Aug 17, 2019

If there are multiple gitlab issues missing in a row, the current code will not correctly create placeholder issues. I faked a dummy gitlab setup, only containing gitlab issues #15, #16 and #17 (with issues #1 to #14 being non-existent). The current code will turn the set of gitlab issues into
[ { iid: 1 }, { iid: 15 }, { iid: 3 }, { iid: 16 }, { iid: 5 }, { iid: 17 } ]

I tested it with the following code, where the for loop is exactly the same as on the master branch currently:

const gitlabIssues = [
  {iid: 15},
  {iid: 16},
  {iid: 17}
];

for (let i = 0; i < gitlabIssues.length; i++) {
  // GitLab issue internal Id (iid)
  let expectedIdx = i + 1;

  // is there a gap in the GitLab issues?
  // Create placeholder issues so that new GitHub issues will have the same
  // issue number as in GitLab. If a placeholder is used it is because there
  // was a gap in GitLab issues -- likely caused by a deleted GitLab issue.
  if (gitlabIssues[i].iid != expectedIdx) {
    gitlabIssues.splice(i, 0, {
      iid: expectedIdx
    });
    i++;
    console.log('Added placeholder issue for GitLab issue #' + expectedIdx);
    console.log("gitlabIssues now looks like this:", gitlabIssues)
  }
}

When you run this you get:

Added placeholder issue for GitLab issue #1
gitlabIssues now looks like this: [ { iid: 1 }, { iid: 15 }, { iid: 16 }, { iid: 17 } ]
Added placeholder issue for GitLab issue #3
gitlabIssues now looks like this: [ { iid: 1 }, { iid: 15 }, { iid: 3 }, { iid: 16 }, { iid: 17 } ]
Added placeholder issue for GitLab issue #5
gitlabIssues now looks like this: [ { iid: 1 },
  { iid: 15 },
  { iid: 3 },
  { iid: 16 },
  { iid: 5 },
  { iid: 17 } ]

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

Successfully merging a pull request may close this issue.

1 participant