Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to define the target branch on pull requests #1326

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions bin/cml/pr/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ exports.options = kebabcaseKeys({
type: 'string',
description: 'Pull request branch name'
},
targetBranch: {
type: 'string',
description: 'Pull request target branch name'
},
title: {
type: 'string',
description: 'Pull request title'
Expand Down
21 changes: 20 additions & 1 deletion src/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ class CML {
md,
skipCi,
branch,
targetBranch,
message,
title,
body,
Expand Down Expand Up @@ -551,7 +552,25 @@ class CML {
const sha = await this.triggerSha();
const shaShort = sha.substr(0, 8);

const target = await this.branch();
let target = await this.branch();

if (targetBranch) {
try {
await exec(
'git',
dfinteligenz marked this conversation as resolved.
Show resolved Hide resolved
'ls-remote',
'--exit-code',
await exec('git', 'config', '--get', `remote.${remote}.url`),
targetBranch
);

target = targetBranch;
} catch (error) {
winston.error('The target branch does not exist.');
process.exit(1);
}
}

const source = branch || `${target}-cml-pr-${shaShort}`;

const branchExists = (
Expand Down