-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stale-and-close): add new options to change the days before close
to avoid a breaking change and simplify the configuration the old options 'daysBeforeStale' and 'daysBeforePrClose' are kept and new options are available to override them with 'daysBeforeIssueStale', 'daysBeforePrStale', 'daysBeforeIssueClose' and 'daysBeforePrClose'
- Loading branch information
Showing
9 changed files
with
507 additions
and
46 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// @todo fix this "false" report from ESLint | ||
// Or I just missed something IDK | ||
// eslint-disable-next-line no-shadow | ||
export enum IssueTypeEnum { | ||
ISSUE = 'issue', | ||
PULL_REQUEST = 'pr' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import {getIssueType} from './get-issue-type'; | ||
|
||
describe('getIssueType()', (): void => { | ||
let isPullRequest: boolean; | ||
|
||
describe('when the issue is a not pull request', (): void => { | ||
beforeEach((): void => { | ||
isPullRequest = false; | ||
}); | ||
|
||
it('should return that the issue is really an issue', (): void => { | ||
expect.assertions(1); | ||
|
||
const result = getIssueType(isPullRequest); | ||
|
||
expect(result).toStrictEqual('issue'); | ||
}); | ||
}); | ||
|
||
describe('when the issue is a pull request', (): void => { | ||
beforeEach((): void => { | ||
isPullRequest = true; | ||
}); | ||
|
||
it('should return that the issue is a pull request', (): void => { | ||
expect.assertions(1); | ||
|
||
const result = getIssueType(isPullRequest); | ||
|
||
expect(result).toStrictEqual('pr'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {IssueTypeEnum} from '../enums/issue-type.enum'; | ||
|
||
export function getIssueType(isPullRequest: Readonly<boolean>): IssueTypeEnum { | ||
return isPullRequest ? IssueTypeEnum.PULL_REQUEST : IssueTypeEnum.ISSUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import {Issue} from '../IssueProcessor'; | ||
import {isPullRequest} from './is-pull-request'; | ||
|
||
describe('isPullRequest()', (): void => { | ||
let issue: Issue; | ||
|
||
describe('when the given issue has an undefined pull request', (): void => { | ||
beforeEach((): void => { | ||
issue = { | ||
pull_request: undefined | ||
} as Issue; | ||
}); | ||
|
||
it('should return false', (): void => { | ||
expect.assertions(1); | ||
|
||
const result = isPullRequest(issue); | ||
|
||
expect(result).toStrictEqual(false); | ||
}); | ||
}); | ||
|
||
describe('when the given issue has a null pull request', (): void => { | ||
beforeEach((): void => { | ||
issue = { | ||
pull_request: null | ||
} as Issue; | ||
}); | ||
|
||
it('should return false', (): void => { | ||
expect.assertions(1); | ||
|
||
const result = isPullRequest(issue); | ||
|
||
expect(result).toStrictEqual(false); | ||
}); | ||
}); | ||
|
||
describe.each([{}, true])( | ||
'when the given issue has pull request', | ||
(value): void => { | ||
beforeEach((): void => { | ||
issue = { | ||
pull_request: value | ||
} as Issue; | ||
}); | ||
|
||
it('should return true', (): void => { | ||
expect.assertions(1); | ||
|
||
const result = isPullRequest(issue); | ||
|
||
expect(result).toStrictEqual(true); | ||
}); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {Issue} from '../IssueProcessor'; | ||
|
||
export function isPullRequest(issue: Readonly<Issue>): boolean { | ||
return !!issue.pull_request; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import {shouldMarkWhenStale} from './should-mark-when-stale'; | ||
|
||
describe('shouldMarkWhenStale()', (): void => { | ||
let daysBeforeStale: number; | ||
|
||
describe('when the given number of days indicate that it should be stalled', (): void => { | ||
beforeEach((): void => { | ||
daysBeforeStale = -1; | ||
}); | ||
|
||
it('should return false', (): void => { | ||
expect.assertions(1); | ||
|
||
const result = shouldMarkWhenStale(daysBeforeStale); | ||
|
||
expect(result).toStrictEqual(false); | ||
}); | ||
}); | ||
|
||
describe('when the given number of days indicate that it should be stalled today', (): void => { | ||
beforeEach((): void => { | ||
daysBeforeStale = 0; | ||
}); | ||
|
||
it('should return true', (): void => { | ||
expect.assertions(1); | ||
|
||
const result = shouldMarkWhenStale(daysBeforeStale); | ||
|
||
expect(result).toStrictEqual(true); | ||
}); | ||
}); | ||
|
||
describe('when the given number of days indicate that it should be stalled tomorrow', (): void => { | ||
beforeEach((): void => { | ||
daysBeforeStale = 1; | ||
}); | ||
|
||
it('should return true', (): void => { | ||
expect.assertions(1); | ||
|
||
const result = shouldMarkWhenStale(daysBeforeStale); | ||
|
||
expect(result).toStrictEqual(true); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function shouldMarkWhenStale( | ||
daysBeforeStale: Readonly<number> | ||
): boolean { | ||
return daysBeforeStale >= 0; | ||
} |