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

fix(vote): improve UX when posting comment fails #814

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lib/voting_session.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class VotingSession extends Session {
const body = 'I would like to close this vote, and for this effect, I\'m revealing my ' +
`key part:\n\n${'```'}\n${keyPart}\n${'```'}\n`;
if (this.postComment) {
const { html_url } = await this.req.json(`https://api.github.com/repos/${this.owner}/${this.repo}/issues/${this.prid}/comments`, {
const { message, html_url } = await this.req.json(`https://api.github.com/repos/${this.owner}/${this.repo}/issues/${this.prid}/comments`, {
agent: this.req.proxyAgent,
method: 'POST',
headers: {
Expand All @@ -124,13 +124,23 @@ export default class VotingSession extends Session {
},
body: JSON.stringify({ body })
});
this.cli.log('Comment posted at:', html_url);
} else if (isGhAvailable()) {
if (html_url) {
this.cli.log(`Comment posted at: ${html_url}`);
return;
} else {
this.cli.error('Failed to post comment');
this.cli.info(message);
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
}
}
if (isGhAvailable()) {
this.cli.log('\nRun the following command to post the comment:\n');
this.cli.log(
`gh pr comment ${this.prid} --repo ${this.owner}/${this.repo} ` +
`--body-file - <<'EOF'\n${body}\nEOF`
);
} else {
this.cli.log('\nPost the following comment on the PR thread:\n');
this.cli.log(body);
}
}
}
Loading