Skip to content

Commit

Permalink
feat(reviewer): add config to assign reviewer when creating PR (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunjae Lee authored and shipjs committed Aug 7, 2019
1 parent 64e9626 commit 4b7b74f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/shipjs-lib/src/lib/config/defaultConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default {
];
return lines.join('\n');
},
pullRequestReviewer: undefined,
mergeStrategy: {
toSameBranch: ['master'],
// toReleaseBranch: {
Expand Down
23 changes: 17 additions & 6 deletions packages/shipjs/src/flow/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ function createPullRequest({
dryRun,
}) {
printStep('Creating a pull-request');
const { mergeStrategy, formatPullRequestMessage, remote } = config;
const {
mergeStrategy,
formatPullRequestMessage,
pullRequestReviewer,
remote,
} = config;
const destinationBranch = getDestinationBranchName({
baseBranch,
mergeStrategy,
Expand All @@ -351,11 +356,17 @@ function createPullRequest({
});
const filePath = tempWrite.sync(message);
run(`git remote prune ${remote}`, dir, dryRun);
run(
`hub pull-request --base ${destinationBranch} --browse --push --file ${filePath}`,
dir,
dryRun
);
const createPullRequestCommand = [
'hub pull-request',
`--base ${destinationBranch}`,
'--browse',
'--push',
pullRequestReviewer ? `--reviewer ${pullRequestReviewer}` : undefined,
`--file ${filePath}`,
]
.filter(Boolean)
.join(' ');
run(createPullRequestCommand, dir, dryRun);
run(`cat ${filePath}`, dir);
print('');
}
Expand Down

0 comments on commit 4b7b74f

Please sign in to comment.