Update missing target branch error message
Signed-off-by: mbruhin <47482924+mbruhin@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-bitbucket-server': patch
|
||||
---
|
||||
|
||||
Improve error message when provided target branch is missing
|
||||
+29
@@ -399,4 +399,33 @@ describe('publish:bitbucketServer:pull-request', () => {
|
||||
'https://hosted.bitbucket.com/projects/project/repos/repo/pull-requests/1',
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw an error when the target branch is not found', async () => {
|
||||
server.use(
|
||||
rest.get(
|
||||
'https://hosted.bitbucket.com/rest/api/1.0/projects/project/repos/repo/branches',
|
||||
(_, res, ctx) => {
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.set('Content-Type', 'application/json'),
|
||||
ctx.json(responseOfBranches),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
await expect(
|
||||
action.handler({
|
||||
...mockContext,
|
||||
input: {
|
||||
...mockContext.input,
|
||||
repoUrl: 'hosted.bitbucket.com?project=project&repo=repo',
|
||||
targetBranch: 'non-existent-branch',
|
||||
sourceBranch: 'develop',
|
||||
},
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
/Target branch 'non-existent-branch' not found in repository project\/repo/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
+6
@@ -380,6 +380,12 @@ export function createPublishBitbucketServerPullRequestAction(options: {
|
||||
apiBaseUrl,
|
||||
});
|
||||
|
||||
if (!toRef) {
|
||||
throw new InputError(
|
||||
`Target branch '${finalTargetBranch}' not found in repository ${project}/${repo}. Please ensure the branch exists before creating a pull request.`,
|
||||
);
|
||||
}
|
||||
|
||||
let fromRef = await findBranches({
|
||||
project,
|
||||
repo,
|
||||
|
||||
Reference in New Issue
Block a user