Skip to content

Commit

Permalink
Revert "Merge branch 'main' into feat/update-baseBranch"
Browse files Browse the repository at this point in the history
This reverts commit 256c1c8, reversing
changes made to 9c6dc13.
  • Loading branch information
RahulGautamSingh committed May 20, 2023
1 parent 256c1c8 commit 08ce058
Show file tree
Hide file tree
Showing 24 changed files with 24 additions and 179 deletions.
5 changes: 0 additions & 5 deletions lib/modules/platform/azure/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOption
{
"description": "Hello world again",
"status": 2,
"targetRefName": "refs/heads/target_branch",
"title": "The New Title",
},
"1",
Expand All @@ -296,15 +295,13 @@ exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOption
[
{
"status": 1,
"targetRefName": "refs/heads/target_branch",
},
"1",
1234,
],
[
{
"description": "Hello world again",
"targetRefName": "refs/heads/target_branch",
"title": "The New Title",
},
"1",
Expand All @@ -318,7 +315,6 @@ exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOption
[
{
"description": "Hello world again",
"targetRefName": "refs/heads/target_branch",
"title": "The New Title",
},
"1",
Expand All @@ -331,7 +327,6 @@ exports[`modules/platform/azure/index updatePr(prNo, title, body, platformOption
[
[
{
"targetRefName": "refs/heads/target_branch",
"title": "The New Title - autoclose",
},
"1",
Expand Down
4 changes: 0 additions & 4 deletions lib/modules/platform/azure/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,6 @@ describe('modules/platform/azure/index', () => {
number: 1234,
prTitle: 'The New Title',
prBody: 'Hello world again',
targetBranch: 'target_branch',
});
expect(updatePullRequest.mock.calls).toMatchSnapshot();
});
Expand All @@ -843,7 +842,6 @@ describe('modules/platform/azure/index', () => {
await azure.updatePr({
number: 1234,
prTitle: 'The New Title - autoclose',
targetBranch: 'target_branch',
});
expect(updatePullRequest.mock.calls).toMatchSnapshot();
});
Expand All @@ -862,7 +860,6 @@ describe('modules/platform/azure/index', () => {
prTitle: 'The New Title',
prBody: 'Hello world again',
state: 'closed',
targetBranch: 'target_branch',
});
expect(updatePullRequest.mock.calls).toMatchSnapshot();
});
Expand All @@ -881,7 +878,6 @@ describe('modules/platform/azure/index', () => {
prTitle: 'The New Title',
prBody: 'Hello world again',
state: 'open',
targetBranch: 'target_branch',
});
expect(updatePullRequest.mock.calls).toMatchSnapshot();
});
Expand Down
5 changes: 1 addition & 4 deletions lib/modules/platform/azure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,16 +508,13 @@ export async function updatePr({
prTitle: title,
prBody: body,
state,
targetBranch,
platformOptions,
}: UpdatePrConfig): Promise<void> {
logger.debug(`updatePr(${prNo}, ${title}, body)`);

const azureApiGit = await azureApi.gitApi();
const targetRefName = getNewBranchName(targetBranch);
const objToUpdate: GitPullRequest = {
title,
targetRefName,
};

if (body) {
Expand All @@ -526,7 +523,7 @@ export async function updatePr({

if (state === 'open') {
await azureApiGit.updatePullRequest(
{ status: PullRequestStatus.Active, targetRefName },
{ status: PullRequestStatus.Active },
config.repoId,
prNo
);
Expand Down
33 changes: 4 additions & 29 deletions lib/modules/platform/bitbucket-server/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,6 @@ describe('modules/platform/bitbucket-server/index', () => {
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
).toResolve();
});
Expand All @@ -1444,7 +1443,6 @@ describe('modules/platform/bitbucket-server/index', () => {
prTitle: 'title',
prBody: 'body',
state: 'closed',
targetBranch: 'target_branch',
})
).toResolve();
});
Expand All @@ -1471,7 +1469,6 @@ describe('modules/platform/bitbucket-server/index', () => {
prTitle: 'title',
prBody: 'body',
state: 'open',
targetBranch: 'target_branch',
})
).toResolve();
});
Expand All @@ -1483,7 +1480,6 @@ describe('modules/platform/bitbucket-server/index', () => {
number: null as any,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
).rejects.toThrow(REPOSITORY_NOT_FOUND);
});
Expand All @@ -1496,12 +1492,7 @@ describe('modules/platform/bitbucket-server/index', () => {
)
.reply(404);
await expect(
bitbucket.updatePr({
number: 4,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 4, prTitle: 'title', prBody: 'body' })
).rejects.toThrow(REPOSITORY_NOT_FOUND);
});

Expand All @@ -1518,12 +1509,7 @@ describe('modules/platform/bitbucket-server/index', () => {
.reply(404);

await expect(
bitbucket.updatePr({
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' })
).rejects.toThrow(REPOSITORY_NOT_FOUND);
});

Expand Down Expand Up @@ -1572,7 +1558,6 @@ describe('modules/platform/bitbucket-server/index', () => {
prTitle: 'title',
prBody: 'body',
state: 'open',
targetBranch: 'target_branch',
})
).toResolve();
});
Expand All @@ -1590,12 +1575,7 @@ describe('modules/platform/bitbucket-server/index', () => {
.reply(409);

await expect(
bitbucket.updatePr({
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' })
).rejects.toThrow(REPOSITORY_CHANGED);
});

Expand All @@ -1612,12 +1592,7 @@ describe('modules/platform/bitbucket-server/index', () => {
.reply(405);

await expect(
bitbucket.updatePr({
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' })
).rejects.toThrowErrorMatchingSnapshot();
});
});
Expand Down
5 changes: 0 additions & 5 deletions lib/modules/platform/bitbucket-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,6 @@ export async function updatePr({
prBody: rawDescription,
state,
bitbucketInvalidReviewers,
targetBranch,
}: UpdatePrConfig & {
bitbucketInvalidReviewers: string[] | undefined;
}): Promise<void> {
Expand Down Expand Up @@ -879,9 +878,6 @@ export async function updatePr({
(name: string) => !bitbucketInvalidReviewers?.includes(name)
)
.map((name: string) => ({ user: { name } })),
toRef: {
id: `refs/heads/${targetBranch}`,
},
},
}
);
Expand Down Expand Up @@ -923,7 +919,6 @@ export async function updatePr({
prBody: rawDescription,
state,
bitbucketInvalidReviewers: invalidReviewers,
targetBranch,
});
} else {
throw new Error(REPOSITORY_CHANGED);
Expand Down
50 changes: 7 additions & 43 deletions lib/modules/platform/bitbucket/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1175,12 +1175,7 @@ describe('modules/platform/bitbucket/index', () => {
.put('/2.0/repositories/some/repo/pullrequests/5')
.reply(200);
await expect(
bitbucket.updatePr({
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' })
).toResolve();
});

Expand Down Expand Up @@ -1243,12 +1238,7 @@ describe('modules/platform/bitbucket/index', () => {
.put('/2.0/repositories/some/repo/pullrequests/5')
.reply(200);
await expect(
bitbucket.updatePr({
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' })
).toResolve();
});

Expand Down Expand Up @@ -1292,12 +1282,7 @@ describe('modules/platform/bitbucket/index', () => {
.reply(200);

await expect(
bitbucket.updatePr({
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' })
).toResolve();
});

Expand Down Expand Up @@ -1329,12 +1314,7 @@ describe('modules/platform/bitbucket/index', () => {
)
.reply(401);
await expect(() =>
bitbucket.updatePr({
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' })
).rejects.toThrow(new Error('Response code 401 (Unauthorized)'));
});

Expand All @@ -1359,12 +1339,7 @@ describe('modules/platform/bitbucket/index', () => {
},
});
await expect(() =>
bitbucket.updatePr({
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' })
).rejects.toThrowErrorMatchingSnapshot();
});

Expand All @@ -1389,12 +1364,7 @@ describe('modules/platform/bitbucket/index', () => {
},
});
await expect(() =>
bitbucket.updatePr({
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' })
).rejects.toThrow(new Error('Response code 400 (Bad Request)'));
});

Expand All @@ -1404,12 +1374,7 @@ describe('modules/platform/bitbucket/index', () => {
.get('/2.0/repositories/some/repo/pullrequests/5')
.reply(500, undefined);
await expect(() =>
bitbucket.updatePr({
number: 5,
prTitle: 'title',
prBody: 'body',
targetBranch: 'target_branch',
})
bitbucket.updatePr({ number: 5, prTitle: 'title', prBody: 'body' })
).rejects.toThrowErrorMatchingSnapshot();
});

Expand All @@ -1428,7 +1393,6 @@ describe('modules/platform/bitbucket/index', () => {
number: pr.id,
prTitle: pr.title,
state: 'closed',
targetBranch: 'target_branch',
})
).toBeUndefined();
});
Expand Down
11 changes: 0 additions & 11 deletions lib/modules/platform/bitbucket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,6 @@ export async function updatePr({
prTitle: title,
prBody: description,
state,
targetBranch,
}: UpdatePrConfig): Promise<void> {
logger.debug(`updatePr(${prNo}, ${title}, body)`);
// Updating a PR in Bitbucket will clear the reviewers if reviewers is not present
Expand All @@ -897,11 +896,6 @@ export async function updatePr({
title,
description: sanitize(description),
reviewers: pr.reviewers,
destination: {
branch: {
name: targetBranch,
},
},
},
}
);
Expand All @@ -919,11 +913,6 @@ export async function updatePr({
title,
description: sanitize(description),
reviewers: sanitizedReviewers,
destination: {
branch: {
name: targetBranch,
},
},
},
}
);
Expand Down
5 changes: 0 additions & 5 deletions lib/modules/platform/codecommit/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,6 @@ describe('modules/platform/codecommit/index', () => {
prTitle: 'title',
prBody: 'body',
state: 'open',
targetBranch: 'target_branch',
})
).toResolve();
});
Expand Down Expand Up @@ -726,7 +725,6 @@ describe('modules/platform/codecommit/index', () => {
prTitle: 'title',
prBody: 'new description',
state: 'open',
targetBranch: 'target_branch',
})
).toResolve();
});
Expand All @@ -753,7 +751,6 @@ describe('modules/platform/codecommit/index', () => {
prTitle: 'title',
prBody: 'new description',
state: 'open',
targetBranch: 'target_branch',
})
).toResolve();
});
Expand All @@ -770,7 +767,6 @@ describe('modules/platform/codecommit/index', () => {
prTitle: 'title',
prBody: 'body',
state: 'open',
targetBranch: 'target_branch',
})
).toResolve();
});
Expand All @@ -785,7 +781,6 @@ describe('modules/platform/codecommit/index', () => {
prTitle: 'title',
prBody: 'body',
state: 'closed',
targetBranch: 'target_branch',
})
).toResolve();
});
Expand Down
Loading

0 comments on commit 08ce058

Please sign in to comment.