Skip to content

Commit cb4a410

Browse files
committed
git-node: simplify PR wait time to 48 hours
Refs: nodejs/node#23082
1 parent 0610ab0 commit cb4a410

File tree

2 files changed

+5
-47
lines changed

2 files changed

+5
-47
lines changed

lib/pr_checker.js

+3-13
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ const SECOND = 1000;
44
const MINUTE = SECOND * 60;
55
const HOUR = MINUTE * 60;
66

7-
const SUNDAY = 0;
8-
const SATURDAY = 6;
9-
10-
const WEEKDAY_WAIT = 48;
11-
const WEEKEND_WAIT = 72;
7+
const WAIT_TIME = 48;
128

139
const {
1410
REVIEW_SOURCES: { FROM_COMMENT, FROM_REVIEW_COMMENT }
@@ -136,16 +132,11 @@ class PRChecker {
136132
*/
137133
getWait(now) {
138134
const createTime = new Date(this.pr.createdAt);
139-
const utcDay = createTime.getUTCDay();
140-
// TODO: do we need to lose this a bit considering timezones?
141-
const isWeekend = (utcDay === SUNDAY || utcDay === SATURDAY);
142-
const waitTime = isWeekend ? WEEKEND_WAIT : WEEKDAY_WAIT;
143-
const timeLeft = waitTime - Math.ceil(
135+
const timeLeft = WAIT_TIME - Math.ceil(
144136
(now.getTime() - createTime.getTime()) / HOUR
145137
);
146138

147139
return {
148-
isWeekend,
149140
timeLeft
150141
};
151142
}
@@ -183,8 +174,7 @@ class PRChecker {
183174
const wait = this.getWait(now);
184175
if (wait.timeLeft > 0) {
185176
const dateStr = new Date(pr.createdAt).toDateString();
186-
const type = wait.isWeekend ? 'weekend' : 'weekday';
187-
cli.info(`This PR was created on ${dateStr} (${type} in UTC)`);
177+
cli.info(`This PR was created on ${dateStr}`);
188178
cli.warn(`Wait at least ${wait.timeLeft} more hours before landing`);
189179
return false;
190180
}

test/unit/pr_checker.test.js

+2-34
Original file line numberDiff line numberDiff line change
@@ -165,44 +165,12 @@ describe('PRChecker', () => {
165165
});
166166

167167
describe('checkPRWait', () => {
168-
it('should warn about PR younger than 72h on weekends', () => {
169-
const cli = new TestCLI();
170-
171-
const expectedLogs = {
172-
warn: [['Wait at least 49 more hours before landing']],
173-
info: [['This PR was created on Sat Oct 28 2017 (weekend in UTC)']]
174-
};
175-
176-
const now = new Date('2017-10-29T13:00:41.682Z');
177-
const youngPR = Object.assign({}, firstTimerPR, {
178-
createdAt: '2017-10-28T14:25:41.682Z'
179-
});
180-
181-
const data = {
182-
pr: youngPR,
183-
reviewers: allGreenReviewers,
184-
comments: commentsWithLGTM,
185-
reviews: approvingReviews,
186-
commits: simpleCommits,
187-
collaborators,
188-
authorIsNew: () => true,
189-
getThread() {
190-
return PRData.prototype.getThread.call(this);
191-
}
192-
};
193-
const checker = new PRChecker(cli, data, argv);
194-
195-
const status = checker.checkPRWait(now);
196-
assert(!status);
197-
cli.assertCalledWith(expectedLogs);
198-
});
199-
200-
it('should warn about PR younger than 48h on weekdays', () => {
168+
it('should warn about PR younger than 48h', () => {
201169
const cli = new TestCLI();
202170

203171
const expectedLogs = {
204172
warn: [['Wait at least 22 more hours before landing']],
205-
info: [['This PR was created on Tue Oct 31 2017 (weekday in UTC)']]
173+
info: [['This PR was created on Tue Oct 31 2017']]
206174
};
207175

208176
const now = new Date('2017-11-01T14:25:41.682Z');

0 commit comments

Comments
 (0)