diff --git a/src/projectmanagement.cli.ts b/src/projectmanagement.cli.ts
index 3e326624..ea6addce 100644
--- a/src/projectmanagement.cli.ts
+++ b/src/projectmanagement.cli.ts
@@ -18,9 +18,9 @@ import * as commander from 'commander';
import {existsSync, readFileSync} from 'fs';
import {join} from 'path';
import {GITLAB_API_URL} from './configuration';
-import {move} from './tasks/move';
import {report} from './tasks/report';
import {tidy} from './tasks/tidy';
+import {unlabel} from './tasks/unlabel';
const logger = new Logger();
@@ -50,9 +50,9 @@ commander
});
commander
- .command('move')
+ .command('unlabel')
.action(async () => {
- await move(gitlabApi);
+ await unlabel(gitlabApi);
logger.ok('Done!');
});
diff --git a/src/tasks/move.ts b/src/tasks/move.ts
deleted file mode 100644
index a58aa11e..00000000
--- a/src/tasks/move.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2018 StApps
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see .
- */
-import {Api} from '@openstapps/gitlab-api';
-import {Milestone} from '@openstapps/gitlab-api/lib/types';
-import {asyncPool} from 'async-pool-native/dist/async-pool';
-import {prompt} from 'inquirer';
-import {flatten2dArray, logger} from '../common';
-import {GROUPS, NOTE_PREFIX} from '../configuration';
-
-/**
- * Move closed issues away from Meeting milestone
- *
- * @param api Instance of GitLabAPI to send requests with
- */
-export async function move(api: Api) {
- const issueResults = await asyncPool(3, GROUPS, (groupId) => {
- return api.getIssues({
- groupId: groupId,
- state: 'closed',
- });
- });
-
- const issues = flatten2dArray(issueResults);
-
- logger.log('Fetched ' + issues.length + ' closed issue(s).');
-
- const milestoneCache: { [s: number]: Milestone[] } = {};
-
- await asyncPool(1, issues, async (issue) => {
- const selectedMilestone = issue.milestone;
- let milestoneId: number | null = null;
-
- if (selectedMilestone !== null) {
- milestoneId = selectedMilestone.id;
- }
-
- if (typeof milestoneCache[issue.project_id] === 'undefined') {
- const milestones = await api.getMilestonesForProject(issue.project_id);
-
- milestones.sort((a, b) => {
- return a.title.localeCompare(b.title);
- });
-
- milestoneCache[issue.project_id] = milestones;
- }
-
- const selectableMilestones: Array<{ name: string, value: number | null }> = [
- {
- name: '>skip<',
- value: milestoneId,
- }, {
- name: '>none<',
- value: null,
- },
- ];
-
- milestoneCache[issue.project_id].forEach((milestone) => {
- selectableMilestones.push({value: milestone.id, name: milestone.title});
- });
-
- const answer: any = await prompt({
- choices: selectableMilestones,
- message: '(' + issue.web_url + '): ' + issue.title,
- name: 'Milestone',
- type: 'list',
- });
-
- const chosenMilestoneId = answer[Object.keys(answer)[0]];
-
- if (chosenMilestoneId === milestoneId) {
- logger.info('Milestone unchanged...');
- return;
- }
-
- await api.setMilestoneForIssue(issue, chosenMilestoneId);
-
- await api.createNote(
- issue.project_id,
- issue.iid,
- `${NOTE_PREFIX} Issue was moved automatically.`,
- );
-
- logger.log('Milestone has been updated...');
- });
-
- logger.ok('Closed issues have been moved.');
-}
diff --git a/src/tasks/unlabel.ts b/src/tasks/unlabel.ts
new file mode 100644
index 00000000..6dca6276
--- /dev/null
+++ b/src/tasks/unlabel.ts
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2018 StApps
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+import {Api} from '@openstapps/gitlab-api';
+import {asyncPool} from 'async-pool-native/dist/async-pool';
+import {flatten2dArray, logger} from '../common';
+import {GROUPS, NOTE_PREFIX} from '../configuration';
+
+/**
+ * Remove label `meeting` from closed issues
+ *
+ * @param api Instance of GitLabAPI to send requests with
+ */
+export async function unlabel(api: Api) {
+ const issueResults = await asyncPool(3, GROUPS, (groupId) => {
+ return api.getIssues({
+ groupId: groupId,
+ state: 'closed',
+ });
+ });
+
+ const issues = flatten2dArray(issueResults);
+
+ logger.log('Fetched ' + issues.length + ' closed issue(s).');
+
+ await asyncPool(1, issues, async (issue) => {
+ await api.createNote(
+ issue.project_id,
+ issue.iid,
+ `${NOTE_PREFIX} Removed label \`meeting\` automatically.
+/unlabel ~meeting`,
+ );
+ });
+
+ logger.ok('Label `meeting` has been removed from closed issues.');
+}