MCPcopy
hub / github.com/iterative/cml / prCreate

Method prCreate

src/cml.js:535–663  ·  view source on GitHub ↗
(opts = {})

Source from the content-addressed store, hash-verified

533 }
534
535 async prCreate(opts = {}) {
536 const driver = this.getDriver();
537 const {
538 remote = GIT_REMOTE,
539 globs = [],
540 md,
541 skipCi,
542 branch,
543 targetBranch,
544 message,
545 title,
546 body,
547 merge,
548 rebase,
549 squash
550 } = opts;
551
552 await this.ci(opts);
553
554 const renderPr = (url) => {
555 if (md)
556 return `[CML's ${
557 this.driver === GITLAB ? 'Merge' : 'Pull'
558 } Request](${url})`;
559 return url;
560 };
561
562 const { files } = await git.status();
563
564 if (!files.length && globs.length) {
565 logger.warn('No changed files matched by glob path. Nothing to do.');
566 return;
567 }
568
569 const prefix = await new Promise((resolve, reject) =>
570 git.revparse(['--show-prefix'], (err, data) =>
571 err !== null ? reject(err) : resolve(data)
572 )
573 );
574
575 const paths = (await globby(globs, { dot: true })).filter((path) =>
576 files.map((file) => file.path).includes(prefix + path)
577 );
578
579 if (!paths.length && globs.length) {
580 logger.warn('Input files are not affected. Nothing to do.');
581 return;
582 }
583
584 const sha = await this.triggerSha();
585 const shaShort = sha.substr(0, 8);
586
587 let target = await this.branch();
588
589 if (targetBranch) {
590 try {
591 await exec(
592 'git',

Callers 1

create.jsFile · 0.45

Calls 7

getDriverMethod · 0.95
ciMethod · 0.95
triggerShaMethod · 0.95
branchMethod · 0.95
execFunction · 0.85
warnMethod · 0.45
prsMethod · 0.45

Tested by

no test coverage detected