piceaTech / node-gitlab-2-github

Migrate Issues, milestones etc from gitlab to github
MIT License
547 stars 133 forks source link

Filter gitlab objects with functions #178

Open iamrgroot opened 1 year ago

iamrgroot commented 1 year ago

I think it would be really nice to remove the settings for skipping item states and replace them with filter functions.

Now:

  skipMergeRequestStates: string[];
  skipMatchingComments: string[];

Suggested:

  skipIssue: (issue: GitLabIssue) => boolean;
  skipMergeRequest: (mr: GitLabMergeRequest) => boolean;
  skipNotes: (note: GitLabNote) => boolean;
  skipMilestone: (note: GitLabMilestone) => boolean;

An example config could be:

  skipMergeRequest: (mr: GitLabMergeRequest) => ['merged', 'closed'].includes(mr.state),
  skipIssue: (issue: GitLabIssue) => {
    if (!issue.closed_at) {
      return false;
    }

    return (new Date(issue.closed_at)).getFullYear() < 2023;
  },