Skip to content

Introducing sort-by option #1254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __tests__/constants/default-processor-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
removeIssueStaleWhenUpdated: undefined,
removePrStaleWhenUpdated: undefined,
ascending: false,
sortIssuesBy: 'created',
deleteBranch: false,
startDate: '',
exemptMilestones: '',
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ inputs:
description: 'The order to get issues or pull requests. Defaults to false, which is descending.'
default: 'false'
required: false
sort-issues-by:
description: 'What to sort results by'
default: 'created'
required: false
delete-branch:
description: 'Delete the git branch after closing a stale pull request.'
default: 'false'
Expand Down
7 changes: 7 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,11 @@ class IssuesProcessor {
state: 'open',
per_page: 100,
direction: this.options.ascending ? 'asc' : 'desc',
sort: this.options.sortIssuesBy === 'updated'
? 'updated'
: this.options.sortIssuesBy === 'comments'
? 'comments'
: 'created',
page
});
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsCount(issueResult.data.length);
Expand Down Expand Up @@ -2199,6 +2204,7 @@ var Option;
Option["RemovePrStaleWhenUpdated"] = "remove-pr-stale-when-updated";
Option["DebugOnly"] = "debug-only";
Option["Ascending"] = "ascending";
Option["SortIssuesBy"] = "sort-issues-by";
Option["DeleteBranch"] = "delete-branch";
Option["StartDate"] = "start-date";
Option["ExemptMilestones"] = "exempt-milestones";
Expand Down Expand Up @@ -2542,6 +2548,7 @@ function _getAndValidateArgs() {
removePrStaleWhenUpdated: _toOptionalBoolean('remove-pr-stale-when-updated'),
debugOnly: core.getInput('debug-only') === 'true',
ascending: core.getInput('ascending') === 'true',
sortIssuesBy: core.getInput('sort-issues-by'),
deleteBranch: core.getInput('delete-branch') === 'true',
startDate: core.getInput('start-date') !== ''
? core.getInput('start-date')
Expand Down
1 change: 1 addition & 0 deletions src/classes/issue.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Issue', (): void => {
beforeEach((): void => {
optionsInterface = {
ascending: false,
sortIssuesBy:'created',
closeIssueLabel: '',
closeIssueMessage: '',
closePrLabel: '',
Expand Down
6 changes: 6 additions & 0 deletions src/classes/issues-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,12 @@ export class IssuesProcessor {
state: 'open',
per_page: 100,
direction: this.options.ascending ? 'asc' : 'desc',
sort:
this.options.sortIssuesBy === 'updated'
? 'updated'
: this.options.sortIssuesBy === 'comments'
? 'comments'
: 'created',
page
});
this.statistics?.incrementFetchedItemsCount(issueResult.data.length);
Expand Down
1 change: 1 addition & 0 deletions src/enums/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum Option {
RemovePrStaleWhenUpdated = 'remove-pr-stale-when-updated',
DebugOnly = 'debug-only',
Ascending = 'ascending',
SortIssuesBy = 'sort-issues-by',
DeleteBranch = 'delete-branch',
StartDate = 'start-date',
ExemptMilestones = 'exempt-milestones',
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/issues-processor-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface IIssuesProcessorOptions {
removePrStaleWhenUpdated: boolean | undefined;
debugOnly: boolean;
ascending: boolean;
sortIssuesBy: string;
deleteBranch: boolean;
startDate: IsoOrRfcDateString | undefined; // Should be ISO 8601 or RFC 2822
exemptMilestones: string;
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function _getAndValidateArgs(): IIssuesProcessorOptions {
),
debugOnly: core.getInput('debug-only') === 'true',
ascending: core.getInput('ascending') === 'true',
sortIssuesBy: core.getInput('sort-issues-by'),
deleteBranch: core.getInput('delete-branch') === 'true',
startDate:
core.getInput('start-date') !== ''
Expand Down
Loading