Skip to content

Commit

Permalink
Update comment with quick feedback
Browse files Browse the repository at this point in the history
Closes #30
  • Loading branch information
philip-gai committed Sep 8, 2021
1 parent 931ff24 commit 355bc95
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const issueCommentHandler = async (octokit: Octokit, chatOpService: ChatO
const issueCommentPayload = context.payload as IssueCommentEvent;
if (issueCommentPayload.action === 'created') {
const comment = issueCommentPayload.comment.body;
let updatedComment = comment;
core.debug(`Comment: ${comment}`);
const chatOpCommand = getChatOpCommand(chatOpService, comment);

Expand All @@ -19,6 +20,14 @@ export const issueCommentHandler = async (octokit: Octokit, chatOpService: ChatO
process.exit(core.ExitCode.Success);
}

updatedComment += '\n1. Creating the branch in ADO...';

await octokit.rest.issues.updateComment({
...context.issue,
comment_id: issueCommentPayload.comment.id,
body: updatedComment
});

const params = getParameters(chatOpService, chatOpCommand, comment);

resultMessage = await azureDevOpsService.createBranch({
Expand All @@ -29,10 +38,12 @@ export const issueCommentHandler = async (octokit: Octokit, chatOpService: ChatO
branchType: params['-type']
});

await octokit.rest.issues.createComment({
updatedComment += `\n1. ${resultMessage}`;

await octokit.rest.issues.updateComment({
...context.issue,
issue_number: context.issue.number,
body: resultMessage || 'There was nothing to do!'
comment_id: issueCommentPayload.comment.id,
body: updatedComment
});
}
return resultMessage;
Expand Down

0 comments on commit 355bc95

Please sign in to comment.