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

bitbucket Driver: body can be undefined #962

Merged
merged 2 commits into from
Apr 14, 2022
Merged

bitbucket Driver: body can be undefined #962

merged 2 commits into from
Apr 14, 2022

Conversation

dacbd
Copy link
Contributor

@dacbd dacbd commented Apr 14, 2022

cml/src/cml.js

Lines 104 to 144 in 6fb4c10

async commentCreate(opts = {}) {
const triggerSha = await this.triggerSha();
const {
report: userReport,
commitSha: inCommitSha = triggerSha,
rmWatermark,
update,
pr
} = opts;
const commitSha =
(await this.revParse({ ref: inCommitSha })) || inCommitSha;
if (rmWatermark && update)
throw new Error('watermarks are mandatory for updateable comments');
const watermark = rmWatermark
? ''
: '![CML watermark](https://raw.githubusercontent.com/iterative/cml/master/assets/watermark.svg)';
const report = `${userReport}\n\n${watermark}`;
const drv = getDriver(this);
let comment;
const updatableComment = (comments) => {
return comments.reverse().find(({ body }) => {
return body.includes('watermark.svg');
});
};
const isBB = this.driver === BB;
if (pr || isBB) {
let commentUrl;
if (commitSha !== triggerSha)
winston.info(
`Looking for PR associated with --commit-sha="${inCommitSha}".\nSee https://cml.dev/doc/ref/send-comment.`
);
const longReport = `${commitSha.substr(0, 7)}\n\n${report}`;
const [commitPr = {}] = await drv.commitPrs({ commitSha });

async commitPrs(opts = {}) {
const { projectPath } = this;
const { commitSha, state = 'OPEN' } = opts;
const endpoint = `/repositories/${projectPath}/commit/${commitSha}/pullrequests?state=${state}`;
const prs = await this.paginatedRequest({ endpoint });

async paginatedRequest(opts = {}) {
const { method = 'GET', body } = opts;
const { next, values } = await this.request(opts);

async request(opts = {}) {
const { token, api } = this;
const { url, endpoint, method = 'GET', body } = opts;
if (!(url || endpoint))
throw new Error('Bitbucket Cloud API endpoint not found');
const headers = { Authorization: `Basic ${token}` };
if (body.constructor !== FormData)

@dacbd dacbd temporarily deployed to internal April 14, 2022 00:25 Inactive
@dacbd dacbd temporarily deployed to internal April 14, 2022 00:32 Inactive
@dacbd dacbd requested a review from DavidGOrtega April 14, 2022 00:34
@dacbd dacbd marked this pull request as ready for review April 14, 2022 00:34
@0x2b3bfa0 0x2b3bfa0 enabled auto-merge (squash) April 14, 2022 00:36
@0x2b3bfa0 0x2b3bfa0 added bug Something isn't working p1-important High priority ci-bitbucket labels Apr 14, 2022
@0x2b3bfa0 0x2b3bfa0 linked an issue Apr 14, 2022 that may be closed by this pull request
@0x2b3bfa0 0x2b3bfa0 merged commit 99c0f94 into master Apr 14, 2022
@0x2b3bfa0 0x2b3bfa0 deleted the bb-driver-patch branch April 14, 2022 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ci-bitbucket p1-important High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

send-comment error on example project using BitBucket
2 participants