Skip to content

Commit

Permalink
Fix send comment pr error without PR (#791)
Browse files Browse the repository at this point in the history
* Fix send comment pr error without PR

* revert #790

* add info messages

Co-authored-by: Casper da Costa-Luis <[email protected]>
  • Loading branch information
DavidGOrtega and casperdcl authored Oct 29, 2021
1 parent 569e548 commit a2b21eb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/cml.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,9 @@ class CML {
this.driver = driver || inferDriver({ repo: this.repo });
}

async headSha() {
return exec(`git rev-parse HEAD`);
}

async triggerSha() {
const { sha } = getDriver(this);
return sha || (await this.headSha());
return sha || (await exec(`git rev-parse HEAD`));
}

async branch() {
Expand All @@ -99,7 +95,7 @@ class CML {
async commentCreate(opts = {}) {
const {
report: userReport,
commitSha = await this.headSha(),
commitSha = await this.triggerSha(),
rmWatermark,
update,
pr
Expand All @@ -125,8 +121,15 @@ class CML {
if (pr || this.driver === 'bitbucket') {
let commentUrl;

if (
(await exec(`git rev-parse ${commitSha}`)) !==
(await exec('git rev-parse HEAD'))
)
winston.info(
`Looking for PR associated with --commit-sha="${commitSha}".\nSee https://cml.dev/doc/ref/send-comment.`
);
const longReport = `${commitSha.substr(0, 7)}\n\n${report}`;
const [commitPr] = await drv.commitPrs({ commitSha });
const [commitPr = {}] = await drv.commitPrs({ commitSha });
const { url } = commitPr;

if (!url) throw new Error(`PR for commit sha "${commitSha}" not found`);
Expand Down

1 comment on commit a2b21eb

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Comment

CML watermark

Please sign in to comment.