fix(formatter): strip only leading ref prefixes

A short branch or tag may itself contain refs/heads or refs/tags.
Strip one leading full-ref prefix at the caller and keep short names
unchanged when generating labels and links.
This commit is contained in:
翅膀 committed 2026-10-23 23:21:50 +08:00
1 parent e44fc60c55
commit aca870374f
3 files changed
+32 -12

No files matched your search

+5 -1
View File
@@ -8,6 +8,7 @@ import {
type T,
buildMessage,
repoBaseUrl,
shortRef,
} from "./helpers";
/** Shared "branch/tag + commit" fields for deployment events. */
@@ -21,7 +22,10 @@ function addDeploymentRefFields(
const isTag = deployment.ref.startsWith("refs/tags/");
fields.push({
name: t("fields.branch_tag"),
value: isTag ? tagLink(baseUrl, deployment.ref) : branchLink(baseUrl, deployment.ref),
// A deployment's ref may be a full ref: its one leading prefix goes.
value: isTag
? tagLink(baseUrl, shortRef(deployment.ref))
: branchLink(baseUrl, shortRef(deployment.ref)),
inline: true,
});
}