Skip to content
Merged
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
30 changes: 28 additions & 2 deletions spec/operations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,15 +473,17 @@ describe('runner', () => {
describe('updateManualBackport()', { timeout: 30_000 }, () => {
const octokit = {
pulls: {
get: vi.fn().mockResolvedValue({}),
get: vi.fn().mockResolvedValue({
data: { user: { login: 'original-author' } },
}),
},
issues: {
createComment: vi.fn().mockResolvedValue({}),
listComments: vi.fn().mockResolvedValue({ data: [] }),
},
};

it('tags reviewers on manual backport creation', async () => {
it('tags reviewers and requests review from the original author on manual backport creation', async () => {
const context = {
...backportPROpenedEvent,
octokit,
Expand All @@ -492,6 +494,30 @@ describe('runner', () => {
expect(tagBackportReviewers).toHaveBeenCalledWith({
context,
targetPrNumber: 7,
user: 'original-author',
});
});

it('does not request review from the original author if they opened the manual backport', async () => {
const context = {
...backportPROpenedEvent,
octokit: {
...octokit,
pulls: {
// The author of the manual backport PR in the fixture.
get: vi.fn().mockResolvedValue({
data: { user: { login: 'codebytere' } },
}),
},
},
repo: vi.fn(),
};
await updateManualBackport(context, PRChange.OPEN, 1234);
expect(tagBackportReviewers).toHaveBeenCalled();
expect(tagBackportReviewers).toHaveBeenCalledWith({
context,
targetPrNumber: 7,
user: undefined,
});
});

Expand Down
9 changes: 8 additions & 1 deletion src/operations/update-manual-backport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,17 @@ please check out #${pr.number}`;
);
}

// Tag default reviewers to manual backport
// Tag default reviewers to manual backport, as well as the original
// PR author if they have write access. GitHub doesn't allow requesting
// a review from the PR author, so skip that if they backported it
// themselves.
await tagBackportReviewers({
context,
targetPrNumber: pr.number,
user:
originalPR.user?.login === pr.user.login
? undefined
: originalPR.user?.login,
});
} else if (type === PRChange.MERGE) {
log(
Expand Down