Skip to content

Commit

Permalink
Merge pull request #22 from instantish/mm/fix-future-milestone-closing
Browse files Browse the repository at this point in the history
Fix for future milestone closing
  • Loading branch information
marissamarym authored Apr 22, 2021
2 parents f8b71a7 + 71a1346 commit 15d06f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 3 additions & 8 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import * as core from '@actions/core';
import * as github from '@actions/github';
import {Octokit} from '@octokit/rest';
import moment from 'moment';

import {
MilestoneProcessor,
MilestoneProcessorOptions
Expand Down Expand Up @@ -106,7 +101,7 @@ test('should not create a <2 day sprint', async () => {
expect(milestonesToAdd[6].title).toEqual('🍊 Orange');
});

test('single milestone list results in 7 created', async () => {
test('single milestone list with future due date results in 7 created', async () => {
// June 1 2020
const now = DUCK && DUCK.firstDueDate.clone().subtract(3, 'days');

Expand All @@ -133,7 +128,7 @@ test('single milestone list results in 7 created', async () => {
// Process the list
const {milestonesToAdd} = await processor.processMilestones(1);

expect(processor.closedMilestones.length).toEqual(1);
expect(processor.closedMilestones.length).toEqual(0);
expect(milestonesToAdd.length).toEqual(7);
expect(milestonesToAdd[0].title).toEqual('🥚 Egg');
expect(milestonesToAdd[1].title).toEqual('🥏 Frisbee');
Expand Down Expand Up @@ -177,7 +172,7 @@ test('single milestone list in future cycle results in 6 created', async () => {
1
);

expect(processor.closedMilestones.length).toEqual(1);
expect(processor.closedMilestones.length).toEqual(0);
expect(milestonesToAdd.length).toEqual(6);
expect(milestonesToAdd[0].title).toEqual('🦞 Lobster');
expect(milestonesToAdd[1].title).toEqual('🗺 Map');
Expand Down
5 changes: 5 additions & 0 deletions src/MilestoneProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ export class MilestoneProcessor {
core.info(`Skipping closing ${title} because it has open issues/prs`);
return;
}
const dueOn = milestone.due_on && moment(milestone.due_on);
if (dueOn && dueOn.isAfter(this.now)) {
core.info(`Skipping closing ${title} because it is in the future`);
return;
}
// Close instantly because there isn't a good way to tag milestones
// and do another pass.
return await this.closeMilestone(milestone);
Expand Down

0 comments on commit 15d06f1

Please sign in to comment.