fix(push): render created tags/branches as create events instead of 0 commits

This commit is contained in:
RhenCloud 2026-08-29 16:45:17 +08:00
parent 5c31b573d3
commit cc8bb4182f
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
4 changed files with 36 additions and 2 deletions

View file

@ -57,6 +57,28 @@ export function formatPush(
);
}
// A newly-created branch/tag pushed via `git push` arrives as a push event
// with `created: true` and no commits — render it like the `create` event
// instead of a confusing "0 commits pushed".
if (created && count === 0) {
const refType = isTagPush ? "tag" : "branch";
const cleanRef = rawRef.replace("refs/heads/", "").replace("refs/tags/", "");
return buildMessage(
{
author,
title: t("events.create.title", {
repo: repo ?? t("common.repository"),
emoji: em(isTagPush ? "🏷️" : "🌿"),
type: refType,
ref: isTagPush ? tagLink(baseUrl, cleanRef) : branchLink(baseUrl, cleanRef),
}),
color: GITHUB_COLORS.create,
},
t,
repo,
);
}
const descLines: string[] = [];
if (forced) {