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

Commit 497928f

Browse files
fix: concat strings and include verification status (#304)
1 parent 04a9a19 commit 497928f

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

dist/index.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -32850,21 +32850,22 @@ function runPushAlert(args) {
3285032850
const commit = process.env.GITHUB_SHA;
3285132851
const reviewed = yield verifyCommitReview(client, commit);
3285232852
if (reviewed === false) {
32853-
const commitDetails = yield client.git.getCommit({
32853+
const commitDetails = yield client.repos.getCommit({
3285432854
repo: github.context.repo.repo,
3285532855
owner: github.context.repo.owner,
32856-
commit_sha: commit,
32856+
ref: commit,
3285732857
});
3285832858
//notify channel
3285932859
var github_commit_url = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/commit/${commit}`;
32860-
const message = `:red-c: @channel Unreviewed Commit in \`${github.context.repo.owner}/${github.context.repo.repo}\`\n` +
32860+
const message = `:red-c: <!channel> Unreviewed Commit in \`${github.context.repo.owner}/${github.context.repo.repo}\`\n` +
3286132861
'\n' +
3286232862
`*Commit:* <${github_commit_url}|${commit.slice(0, 6)}>\n` +
32863-
`*Author:* <https://github.com/${encodeURIComponent(commitDetails.data.author.name)}|${safeSlackString(commitDetails.data.author.name)}>\n` +
32864-
`*Committer:* <https://github.com/${encodeURIComponent(commitDetails.data.committer.name)}|${safeSlackString(commitDetails.data.committer.name)}>\n` +
32863+
`*Author:* <https://github.com/${encodeURIComponent(commitDetails.data.author.login)}|${safeSlackString(commitDetails.data.commit.author.name)}>\n` +
32864+
`*Committer:* <https://github.com/${encodeURIComponent(commitDetails.data.committer.login)}|${safeSlackString(commitDetails.data.commit.committer.name)}>\n` +
32865+
`*Verified Commit:* ${commitDetails.data.commit.verification.verified ? ':check:' : ':red-bang:'} _${safeSlackString(commitDetails.data.commit.verification.reason)}_\n` +
3286532866
'*Message:*\n' +
32866-
'```\n';
32867-
safeSlackString(commitDetails.data.message) +
32867+
'```\n' +
32868+
safeSlackString(commitDetails.data.commit.message) +
3286832869
'\n```';
3286932870
const req = request.post(args.slackEndpoint, {
3287032871
json: {

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "push-alert",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"private": true,
55
"description": "Push alert for monitoring unreviewed commits",
66
"main": "dist/index.js",

src/push-alert.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,23 @@ export async function runPushAlert(args) {
1515
const commit = process.env.GITHUB_SHA;
1616
const reviewed = await verifyCommitReview(client, commit);
1717
if (reviewed === false){
18-
const commitDetails = await client.git.getCommit({
18+
const commitDetails = await client.repos.getCommit({
1919
repo: github.context.repo.repo,
2020
owner: github.context.repo.owner,
21-
commit_sha: commit,
21+
ref: commit,
2222
});
2323

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

0 commit comments

Comments
 (0)