diff --git a/server/lib/formatters/push.ts b/server/lib/formatters/push.ts index 57a8863..8615ca2 100644 --- a/server/lib/formatters/push.ts +++ b/server/lib/formatters/push.ts @@ -58,14 +58,6 @@ export function formatPush( descriptionParts.push(em("🆕") + t("events.push.branch_created")); } - descriptionParts.push( - t("events.push.commits_pushed", { - count, - s: count !== 1 ? "s" : "", - ref: isTagPush ? tagLink(baseUrl, rawRef, ref) : branchLink(baseUrl, rawRef, ref), - }), - ); - if (compareUrl) { descriptionParts.push(t("events.push.view_comparison", { url: compareUrl })); } @@ -119,6 +111,7 @@ export function formatPush( count, s: count !== 1 ? "s" : "", repo: repo ?? t("common.repository"), + ref: isTagPush ? tagLink(baseUrl, rawRef, ref) : branchLink(baseUrl, rawRef, ref), }), url: compareUrl, color: GITHUB_COLORS.push, diff --git a/server/lib/formatters/workflow.ts b/server/lib/formatters/workflow.ts index d8fea43..64ec077 100644 --- a/server/lib/formatters/workflow.ts +++ b/server/lib/formatters/workflow.ts @@ -175,13 +175,16 @@ export function formatWorkflowRun( }); } + const runLabel = workflow.html_url + ? `[${workflow.name ?? "Workflow"} — ${status}](${workflow.html_url})` + : `${workflow.name ?? "Workflow"} — ${status}`; + return buildMessage( { author, title: t("events.workflow_run.title", { repo: repo ?? t("common.repository"), - name: workflow.name ?? "Workflow", - conclusion: status, + run: runLabel, }), url: workflow.html_url, color: GITHUB_COLORS[colorKey], diff --git a/server/lib/lib/locales/en.ts b/server/lib/lib/locales/en.ts index ba04883..ccf968f 100644 --- a/server/lib/lib/locales/en.ts +++ b/server/lib/lib/locales/en.ts @@ -88,12 +88,11 @@ export const en = { push: { force_push: "**Force push**", branch_created: "Branch created", - commits_pushed: "**{count}** commit{s} pushed to {ref}", view_comparison: "[View comparison]({url})", added: "+{count} added", removed: "-{count} removed", modified: "~{count} modified", - title: "{repo}: Pushed {count} commit{s}", + title: "{repo}: Pushed {count} commit{s} to {ref}", }, pr: { action_pr: "{emoji}**{action}** pull request", @@ -108,7 +107,7 @@ export const en = { action_comment: "{emoji}**{action}** comment", }, workflow_run: { - title: "{repo}: {name} — {conclusion}", + title: "{repo}: {run}", }, workflow_job: { title: "{repo}: Job {name} — {conclusion}", diff --git a/server/lib/lib/locales/zh.ts b/server/lib/lib/locales/zh.ts index 521e8ba..3130be0 100644 --- a/server/lib/lib/locales/zh.ts +++ b/server/lib/lib/locales/zh.ts @@ -108,7 +108,7 @@ export const zh = { action_comment: "{emoji}**{action}** 评论", }, workflow_run: { - title: "{repo}: {name} — {conclusion}", + title: "{repo}: {run}", }, workflow_job: { title: "{repo}: 作业 {name} — {conclusion}", diff --git a/tests/formatter.test.ts b/tests/formatter.test.ts index a402dca..87c353d 100644 --- a/tests/formatter.test.ts +++ b/tests/formatter.test.ts @@ -31,7 +31,10 @@ describe("message title spec", () => { sender, }), ); - expect(msg.title).toBe("acme/widget: Pushed 1 commit"); + expect(msg.title).toBe( + "acme/widget: Pushed 1 commit to [`main`](https://github.com/acme/widget/tree/main)", + ); + expect(msg.description).toBe("[View comparison](https://github.com/acme/widget/compare/abc...def)"); }); it("pull_request title is repo#number: title", () => { @@ -98,7 +101,7 @@ describe("message title spec", () => { sender, }), ); - expect(msg.title).toBe("acme/widget: CI — success"); + expect(msg.title).toBe("acme/widget: [CI — success](https://github.com/acme/widget/actions/runs/42)"); expect(msg.fields![1].value).toBe("✅ build"); }); @@ -119,7 +122,7 @@ describe("message title spec", () => { sender, }), ); - expect(queued.title).toBe("acme/widget: CI — queued"); + expect(queued.title).toBe("acme/widget: [CI — queued](https://github.com/acme/widget/actions/runs/42)"); expect(queued.fields![0].value).toBe("⏳ queued"); const running = formatEvent( @@ -131,7 +134,7 @@ describe("message title spec", () => { sender, }), ); - expect(running.title).toBe("acme/widget: CI — running"); + expect(running.title).toBe("acme/widget: [CI — running](https://github.com/acme/widget/actions/runs/42)"); expect(running.fields![0].value).toBe("🔄 running"); });