mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +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, repoBaseUrl } from "./helpers";
|
||||
import { branchLink, commitLink, emojiPrefix, type T, buildMessage, repoBaseUrl } from "./helpers";
|
||||
|
||||
export function formatCheckSuite(
|
||||
payload: Record<string, unknown>,
|
||||
|
|
@ -53,7 +53,7 @@ export function formatCheckSuite(
|
|||
if (suite.head_branch) {
|
||||
fields.push({
|
||||
name: t("fields.branch"),
|
||||
value: suite.head_branch,
|
||||
value: branchLink(baseUrl, suite.head_branch),
|
||||
inline: true,
|
||||
});
|
||||
}
|
||||
|
|
@ -61,10 +61,7 @@ export function formatCheckSuite(
|
|||
if (suite.head_sha) {
|
||||
fields.push({
|
||||
name: t("fields.commit"),
|
||||
value:
|
||||
baseUrl && suite.head_sha
|
||||
? `[${suite.head_sha.slice(0, 7)}](${baseUrl}/commit/${suite.head_sha})`
|
||||
: `\`${suite.head_sha.slice(0, 7)}\``,
|
||||
value: commitLink(baseUrl, suite.head_sha),
|
||||
inline: true,
|
||||
});
|
||||
}
|
||||
|
|
@ -99,6 +96,7 @@ export function formatStatus(
|
|||
const description = payload.description as string | undefined;
|
||||
const targetUrl = payload.target_url as string | undefined;
|
||||
const sha = payload.sha as string | undefined;
|
||||
const baseUrl = repoBaseUrl(payload, repo);
|
||||
|
||||
const emoji = state === "success" ? "✅" : state === "failure" || state === "error" ? "❌" : "⏳";
|
||||
const em = (e: string): string => emojiPrefix(e, showEmoji);
|
||||
|
|
@ -128,7 +126,7 @@ export function formatStatus(
|
|||
if (sha) {
|
||||
fields.push({
|
||||
name: t("fields.commit"),
|
||||
value: `\`${sha.slice(0, 7)}\``,
|
||||
value: commitLink(baseUrl, sha),
|
||||
inline: true,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue