Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Commit

Permalink
fix: concat strings and include verification status (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound authored Aug 8, 2023
1 parent 04a9a19 commit 497928f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
15 changes: 8 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32850,21 +32850,22 @@ function runPushAlert(args) {
const commit = process.env.GITHUB_SHA;
const reviewed = yield verifyCommitReview(client, commit);
if (reviewed === false) {
const commitDetails = yield client.git.getCommit({
const commitDetails = yield client.repos.getCommit({
repo: github.context.repo.repo,
owner: github.context.repo.owner,
commit_sha: commit,
ref: commit,
});
//notify channel
var github_commit_url = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/commit/${commit}`;
const message = `:red-c: @channel Unreviewed Commit in \`${github.context.repo.owner}/${github.context.repo.repo}\`\n` +
const message = `:red-c: <!channel> Unreviewed Commit in \`${github.context.repo.owner}/${github.context.repo.repo}\`\n` +
'\n' +
`*Commit:* <${github_commit_url}|${commit.slice(0, 6)}>\n` +
`*Author:* <https://github.com/${encodeURIComponent(commitDetails.data.author.name)}|${safeSlackString(commitDetails.data.author.name)}>\n` +
`*Committer:* <https://github.com/${encodeURIComponent(commitDetails.data.committer.name)}|${safeSlackString(commitDetails.data.committer.name)}>\n` +
`*Author:* <https://github.com/${encodeURIComponent(commitDetails.data.author.login)}|${safeSlackString(commitDetails.data.commit.author.name)}>\n` +
`*Committer:* <https://github.com/${encodeURIComponent(commitDetails.data.committer.login)}|${safeSlackString(commitDetails.data.commit.committer.name)}>\n` +
`*Verified Commit:* ${commitDetails.data.commit.verification.verified ? ':check:' : ':red-bang:'} _${safeSlackString(commitDetails.data.commit.verification.reason)}_\n` +
'*Message:*\n' +
'```\n';
safeSlackString(commitDetails.data.message) +
'```\n' +
safeSlackString(commitDetails.data.commit.message) +
'\n```';
const req = request.post(args.slackEndpoint, {
json: {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "push-alert",
"version": "1.1.2",
"version": "1.1.3",
"private": true,
"description": "Push alert for monitoring unreviewed commits",
"main": "dist/index.js",
Expand Down
15 changes: 8 additions & 7 deletions src/push-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ export async function runPushAlert(args) {
const commit = process.env.GITHUB_SHA;
const reviewed = await verifyCommitReview(client, commit);
if (reviewed === false){
const commitDetails = await client.git.getCommit({
const commitDetails = await client.repos.getCommit({
repo: github.context.repo.repo,
owner: github.context.repo.owner,
commit_sha: commit,
ref: commit,
});

//notify channel
var github_commit_url = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/commit/${commit}`;
const message = `:red-c: @channel Unreviewed Commit in \`${github.context.repo.owner}/${github.context.repo.repo}\`\n` +
const message = `:red-c: <!channel> Unreviewed Commit in \`${github.context.repo.owner}/${github.context.repo.repo}\`\n` +
'\n' +
`*Commit:* <${github_commit_url}|${commit.slice(0, 6)}>\n` +
`*Author:* <https://github.com/${encodeURIComponent(commitDetails.data.author.name)}|${safeSlackString(commitDetails.data.author.name)}>\n` +
`*Committer:* <https://github.com/${encodeURIComponent(commitDetails.data.committer.name)}|${safeSlackString(commitDetails.data.committer.name)}>\n` +
`*Author:* <https://github.com/${encodeURIComponent(commitDetails.data.author.login)}|${safeSlackString(commitDetails.data.commit.author.name)}>\n` +
`*Committer:* <https://github.com/${encodeURIComponent(commitDetails.data.committer.login)}|${safeSlackString(commitDetails.data.commit.committer.name)}>\n` +
`*Verified Commit:* ${commitDetails.data.commit.verification.verified ? ':check:' : ':red-bang:'} _${safeSlackString(commitDetails.data.commit.verification.reason)}_\n` +
'*Message:*\n' +
'```\n'
safeSlackString(commitDetails.data.message) +
'```\n' +
safeSlackString(commitDetails.data.commit.message) +
'\n```';
const req = request.post(args.slackEndpoint,{
json:{
Expand Down

0 comments on commit 497928f

Please sign in to comment.