mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
fix(push): link commit hash and render message as plain text
This commit is contained in:
parent
e1b1daac98
commit
52d136c468
7 changed files with 1249 additions and 1175 deletions
1455
admin/bun.lock
1455
admin/bun.lock
File diff suppressed because it is too large
Load diff
|
|
@ -1,15 +1,16 @@
|
|||
{
|
||||
"name": "webhooker-admin",
|
||||
"dependencies": {
|
||||
"nuxt": "^3.21.10",
|
||||
"oxc-parser": "^0.144.0",
|
||||
"vue": "^3.5.13"
|
||||
},
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "nuxt dev",
|
||||
"build": "nuxt build",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"nuxt": "^3.21.10",
|
||||
"vue": "^3.5.13"
|
||||
}
|
||||
"type": "module"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,6 +279,25 @@ describe("group emoji toggle", () => {
|
|||
expect(msg.description).not.toContain("🔗");
|
||||
});
|
||||
|
||||
it("push commit renders linked short hash with plain-text message", () => {
|
||||
const msg = formatEvent(
|
||||
route,
|
||||
event("push", {
|
||||
ref: "refs/heads/main",
|
||||
compare: "https://github.com/acme/widget/compare/abc...def",
|
||||
created: false,
|
||||
forced: false,
|
||||
commits: [{ id: "abcd1234ef", message: "fix stuff", added: [], removed: [], modified: [] }],
|
||||
repository: repo,
|
||||
sender,
|
||||
}),
|
||||
);
|
||||
expect(msg.fields![0].name).toBe("\u200b");
|
||||
expect(msg.fields![0].value).toBe(
|
||||
"[`abcd123`](https://github.com/acme/widget/commit/abcd1234ef) fix stuff",
|
||||
);
|
||||
});
|
||||
|
||||
it("strips emoji from push description when disabled", () => {
|
||||
const msg = formatEvent(
|
||||
route,
|
||||
|
|
|
|||
|
|
@ -54,6 +54,16 @@ describe("telegram renderNeutralMessage", () => {
|
|||
expect(out).toContain("<b>Status</b>: <b>ok</b> and <code>done</code>");
|
||||
});
|
||||
|
||||
it("renders a code-formatted commit hash inside a link", () => {
|
||||
const out = renderNeutralMessage({
|
||||
title: "acme/widget: Pushed 1 commit",
|
||||
fields: [{ name: "\u200b", value: "[`abcd123`](https://github.com/acme/widget/commit/abcd1234ef) fix stuff" }],
|
||||
});
|
||||
expect(out).toContain(
|
||||
'<a href="https://github.com/acme/widget/commit/abcd1234ef"><code>abcd123</code></a> fix stuff',
|
||||
);
|
||||
});
|
||||
|
||||
it("formats ISO timestamps into a readable UTC string", () => {
|
||||
const out = renderNeutralMessage({
|
||||
title: "acme/widget: t",
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ export function formatPush(
|
|||
const shortId = c.id?.slice(0, 7) ?? "???????";
|
||||
const msg = c.message?.split("\n")[0].slice(0, 72) ?? t("common.no_message");
|
||||
const url = repo && c.id ? `https://github.com/${repo}/commit/${c.id}` : null;
|
||||
return { name: `\`${shortId}\``, value: url ? `[${msg}](${url})` : msg };
|
||||
const hash = url ? `[\`${shortId}\`](${url})` : `\`${shortId}\``;
|
||||
return { name: `\u200b`, value: `${hash} ${msg}` };
|
||||
};
|
||||
|
||||
if (count <= 5) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"compatibility_date": "2025-01-01",
|
||||
"compatibility_flags": [],
|
||||
"build": {
|
||||
"command": "cd admin && bun install --frozen-lockfile && bun run generate"
|
||||
"command": "cd admin && bun install --frozen-lockfile && node node_modules/nuxt/bin/nuxt.mjs generate"
|
||||
},
|
||||
"assets": {
|
||||
"directory": "./admin/.output/public",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue