in src/services/cherryPickService.ts [221:266]
export async function ValidateTargetBranchesAsync(
repository: GitRepository,
targetTopicBranchName: string,
targetBranchName: string
): Promise<IRestClientResult<boolean>> {
let targetBranch = targetBranchName;
// Check to ensure targetBranch exists in repo
if (!targetBranch.startsWith("heads/")) {
targetBranch = `heads/${targetBranch}`;
}
const targetRef = await client.getRefs(
repository.id,
repository.project.id,
targetBranch
);
if (!targetRef.find(x => x.name === `refs/${targetBranch}`)) {
return {
error: "Target branch does not exist",
result: false
};
}
let topicBranch = targetTopicBranchName;
// Check to ensure targetTopicBranch does not exists in repo
if (!topicBranch.startsWith("heads/")) {
topicBranch = `heads/${topicBranch}`;
}
const targetTopicRefs = await client.getRefs(
repository.id,
repository.project.id,
topicBranch
);
if (targetTopicRefs.find(x => x.name === `refs/${topicBranch}`)) {
return {
error: `Target topic branch already exists`,
result: false
};
}
return {
result: true
};
}