Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $ npm install
Build the typescript and package it for distribution.

```bash
$ npm run build && npm run pack
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was no pack script locally

$ npm run build
```

Run the tests :heavy_check_mark:
Expand Down
40 changes: 39 additions & 1 deletion __tests__/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,44 @@ test('stale label should be removed if a comment was added to a stale issue', as
expect(processor.removedLabelIssues).toHaveLength(1);
});

test('stale label should not be removed if a bot comment was added to a stale issue', async () => {
const opts = {...DefaultProcessorOptions, removeStaleWhenUpdated: true};
const TestIssueList: Issue[] = [
generateIssue(
opts,
1,
'An issue that should un-stale',
Copy link

Copilot AI Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test description 'An issue that should un-stale' contradicts the test's purpose, which is to verify that bot comments do NOT cause issues to un-stale. Consider renaming to 'An issue that should remain stale'.

Suggested change
'An issue that should un-stale',
'An issue that should remain stale',

Copilot uses AI. Check for mistakes.
'2020-01-01T17:00:00Z',
'2020-01-01T17:00:00Z',
false,
false,
['Stale']
)
];
const processor = new IssuesProcessorMock(
opts,
alwaysFalseStateMock,
async p => (p === 1 ? TestIssueList : []),
async () => [
{
user: {
login: 'notme',
type: 'Bot'
},
body: 'Body'
}
], // return a fake comment to indicate there was an update
async () => new Date().toDateString()
);

// process our fake issue list
await processor.processIssues(1);

expect(processor.closedIssues).toHaveLength(1);
expect(processor.staleIssues).toHaveLength(0);
expect(processor.removedLabelIssues).toHaveLength(0);
});

test('when the option "labelsToAddWhenUnstale" is set, the labels should be added when unstale', async () => {
expect.assertions(4);
const opts = {
Expand Down Expand Up @@ -1360,7 +1398,7 @@ test('stale label should not be removed if a comment was added by the bot (and t
{
user: {
login: 'abot',
type: 'User'
type: 'Bot'
},
body: 'This issue is stale'
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ class IssuesProcessor {
const comments = yield this.listIssueComments(issue, sinceDate);
const filteredComments = comments.filter(comment => {
var _a, _b;
return ((_a = comment.user) === null || _a === void 0 ? void 0 : _a.type) === 'User' &&
return ((_a = comment.user) === null || _a === void 0 ? void 0 : _a.type) !== 'Bot' &&
((_b = comment.body) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== staleMessage.toLowerCase();
});
issueLogger.info(`Comments that are not the stale comment or another bot: ${logger_service_1.LoggerService.cyan(filteredComments.length)}`);
Expand Down
2 changes: 1 addition & 1 deletion src/classes/issues-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ export class IssuesProcessor {

const filteredComments = comments.filter(
comment =>
comment.user?.type === 'User' &&
comment.user?.type !== 'Bot' &&
comment.body?.toLowerCase() !== staleMessage.toLowerCase()
);

Expand Down