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 } from "./colors";
|
||||
import { emojiPrefix, type T, buildMessage, repoBaseUrl } from "./helpers";
|
||||
import { branchLink, emojiPrefix, tagLink, type T, buildMessage, repoBaseUrl } from "./helpers";
|
||||
|
||||
export function formatPush(
|
||||
payload: Record<string, unknown>,
|
||||
|
|
@ -9,7 +9,9 @@ export function formatPush(
|
|||
t: T,
|
||||
showEmoji: boolean,
|
||||
): NeutralMessage {
|
||||
const ref = (payload.ref as string)?.replace("refs/heads/", "").replace("refs/tags/", "tag: ");
|
||||
const rawRef = (payload.ref as string) ?? "";
|
||||
const isTagPush = rawRef.startsWith("refs/tags/");
|
||||
const ref = rawRef.replace("refs/heads/", "").replace("refs/tags/", "tag: ");
|
||||
const commits = (payload.commits ?? []) as Array<{
|
||||
id?: string;
|
||||
message?: string;
|
||||
|
|
@ -35,7 +37,11 @@ export function formatPush(
|
|||
}
|
||||
|
||||
descriptionParts.push(
|
||||
t("events.push.commits_pushed", { count, s: count !== 1 ? "s" : "", ref: ref ?? "" }),
|
||||
t("events.push.commits_pushed", {
|
||||
count,
|
||||
s: count !== 1 ? "s" : "",
|
||||
ref: isTagPush ? tagLink(baseUrl, rawRef, ref) : branchLink(baseUrl, rawRef, ref),
|
||||
}),
|
||||
);
|
||||
|
||||
if (compareUrl) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue