mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-23 00:21:28 +00:00
style(formatters): render branch/commit/tag refs as inline code with hyperlinks
Unify all branch, commit hash and tag references across formatters to the push commit style (inline code + link). Adds commitLink/branchLink/tagLink helpers in formatters/helpers.ts, links branches to /tree/, tags to /releases/tag/, and PR head branches to the fork repo. Drops the backticks from the en/zh locale templates around {ref}/{sha} since the formatters now inject pre-linked values.
This commit is contained in:
parent
3029b3468f
commit
bf76b9342f
12 changed files with 110 additions and 45 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import type { NeutralMessage, NeutralAuthor } from "../types";
|
||||
import { GITHUB_COLORS, WORKFLOW_CONCLUSION_EMOJI } from "./colors";
|
||||
import { emojiPrefix, type T, buildMessage } from "./helpers";
|
||||
import { emojiPrefix, type T, buildMessage, branchLink, commitLink, repoBaseUrl } from "./helpers";
|
||||
|
||||
export function formatWorkflowJob(
|
||||
payload: Record<string, unknown>,
|
||||
|
|
@ -28,6 +28,7 @@ export function formatWorkflowJob(
|
|||
: (job.conclusion ?? "pending");
|
||||
const emoji = WORKFLOW_CONCLUSION_EMOJI[status] ?? "⏳";
|
||||
const em = (e: string): string => emojiPrefix(e, showEmoji);
|
||||
const baseUrl = repoBaseUrl(payload, repo);
|
||||
const colorKey =
|
||||
status === "success"
|
||||
? "workflow_run_success"
|
||||
|
|
@ -62,7 +63,7 @@ export function formatWorkflowJob(
|
|||
if (job.head_branch) {
|
||||
fields.push({
|
||||
name: t("fields.branch"),
|
||||
value: `\`${job.head_branch}\``,
|
||||
value: branchLink(baseUrl, job.head_branch),
|
||||
inline: true,
|
||||
});
|
||||
}
|
||||
|
|
@ -70,7 +71,7 @@ export function formatWorkflowJob(
|
|||
if (job.head_sha) {
|
||||
fields.push({
|
||||
name: t("fields.commit"),
|
||||
value: `\`${job.head_sha.slice(0, 7)}\``,
|
||||
value: commitLink(baseUrl, job.head_sha),
|
||||
inline: true,
|
||||
});
|
||||
}
|
||||
|
|
@ -121,6 +122,7 @@ export function formatWorkflowRun(
|
|||
: (workflow.conclusion ?? "pending");
|
||||
const emoji = WORKFLOW_CONCLUSION_EMOJI[status] ?? "⏳";
|
||||
const em = (e: string): string => emojiPrefix(e, showEmoji);
|
||||
const baseUrl = repoBaseUrl(payload, repo);
|
||||
const colorKey =
|
||||
status === "success"
|
||||
? "workflow_run_success"
|
||||
|
|
@ -150,7 +152,7 @@ export function formatWorkflowRun(
|
|||
if (workflow.head_branch) {
|
||||
fields.push({
|
||||
name: t("fields.branch"),
|
||||
value: `\`${workflow.head_branch}\``,
|
||||
value: branchLink(baseUrl, workflow.head_branch),
|
||||
inline: true,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue