mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
fix(azure): Separate API call for the reopening PR state (#7050)
Co-authored-by: Jamie Magee <JamieMagee@users.noreply.github.com>
This commit is contained in:
parent
d22ae1e4bd
commit
786ff757b2
3 changed files with 48 additions and 6 deletions
|
@ -188,6 +188,26 @@ Array [
|
|||
]
|
||||
`;
|
||||
|
||||
exports[`platform/azure updatePr(prNo, title, body) should reopen the PR 1`] = `
|
||||
Array [
|
||||
Array [
|
||||
Object {
|
||||
"status": 1,
|
||||
},
|
||||
"1",
|
||||
1234,
|
||||
],
|
||||
Array [
|
||||
Object {
|
||||
"description": undefined,
|
||||
"title": "The New Title",
|
||||
},
|
||||
"1",
|
||||
1234,
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`platform/azure updatePr(prNo, title, body) should update the PR 1`] = `
|
||||
Array [
|
||||
Array [
|
||||
|
|
|
@ -631,6 +631,24 @@ describe('platform/azure', () => {
|
|||
});
|
||||
expect(updatePullRequest.mock.calls).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should reopen the PR', async () => {
|
||||
await initRepo({ repository: 'some/repo' });
|
||||
const updatePullRequest = jest.fn();
|
||||
azureApi.gitApi.mockImplementationOnce(
|
||||
() =>
|
||||
({
|
||||
updatePullRequest,
|
||||
} as any)
|
||||
);
|
||||
await azure.updatePr({
|
||||
number: 1234,
|
||||
prTitle: 'The New Title',
|
||||
prBody: 'Hello world again',
|
||||
state: PrState.Open,
|
||||
});
|
||||
expect(updatePullRequest.mock.calls).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ensureComment', () => {
|
||||
|
|
|
@ -373,21 +373,25 @@ export async function updatePr({
|
|||
}: UpdatePrConfig): Promise<void> {
|
||||
logger.debug(`updatePr(${prNo}, ${title}, body)`);
|
||||
|
||||
const status = {
|
||||
[PrState.Open]: PullRequestStatus.Active,
|
||||
[PrState.Closed]: PullRequestStatus.Abandoned,
|
||||
}[state];
|
||||
|
||||
const azureApiGit = await azureApi.gitApi();
|
||||
const objToUpdate: GitPullRequest = {
|
||||
title,
|
||||
...(status && { status }),
|
||||
};
|
||||
|
||||
if (body) {
|
||||
objToUpdate.description = azureHelper.max4000Chars(sanitize(body));
|
||||
}
|
||||
|
||||
if (state === PrState.Open) {
|
||||
await azureApiGit.updatePullRequest(
|
||||
{ status: PullRequestStatus.Active },
|
||||
config.repoId,
|
||||
prNo
|
||||
);
|
||||
} else if (state === PrState.Closed) {
|
||||
objToUpdate.status = PullRequestStatus.Abandoned;
|
||||
}
|
||||
|
||||
await azureApiGit.updatePullRequest(objToUpdate, config.repoId, prNo);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue