refactor(push): move commits to description, comparison to changes field

This commit is contained in:
RhenCloud 2026-08-16 22:27:43 +08:00
parent 47d7c9105b
commit df0edbb581
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
6 changed files with 44 additions and 48 deletions

View file

@ -8,17 +8,17 @@ exports[`formatter snapshots push 1`] = `
"url": "https://github.com/octocat",
},
"color": 3056719,
"description": "[View comparison](https://github.com/acme/widget/compare/aaa...bbb)",
"description": "[\`bbbbbbb\`](https://github.com/acme/widget/commit/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) Fix login bug",
"fields": [
{
"inline": false,
"name": "",
"value": "[\`bbbbbbb\`](https://github.com/acme/widget/commit/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) Fix login bug",
"name": "Changes",
"value": "[View comparison](https://github.com/acme/widget/compare/aaa...bbb):",
},
],
"footer": "acme/widget",
"timestamp": "TIMESTAMP",
"title": "acme/widget: Pushed 1 commit to [\`main\`](https://github.com/acme/widget/tree/main)",
"title": "acme/widget: Pushed 1 commit to main",
"url": "https://github.com/acme/widget/compare/aaa...bbb",
}
`;

View file

@ -33,11 +33,14 @@ describe("message title spec", () => {
}),
);
expect(msg.title).toBe(
"acme/widget: Pushed 1 commit to [`main`](https://github.com/acme/widget/tree/main)",
"acme/widget: Pushed 1 commit to main",
);
expect(msg.description).toBe(
"[View comparison](https://github.com/acme/widget/compare/abc...def)",
"[`abcd123`](https://github.com/acme/widget/commit/abcd1234ef) fix stuff",
);
expect(msg.fields).toEqual([
{ name: "Changes", value: "[View comparison](https://github.com/acme/widget/compare/abc...def):", inline: false },
]);
});
it("pull_request title is repo#number: title", () => {
@ -346,8 +349,7 @@ describe("group emoji toggle", () => {
sender,
}),
);
expect(msg.fields![0].name).toBe("\u200b");
expect(msg.fields![0].value).toBe(
expect(msg.description).toBe(
"[`abcd123`](https://github.com/acme/widget/commit/abcd1234ef) fix stuff",
);
});
@ -450,7 +452,7 @@ describe("limits and localization", () => {
sender,
}),
);
expect(msg.fields![0].value).toBe(`${link} ${"x".repeat(MAX_COMMIT_SUBJECT)}`);
expect(msg.description).toBe(`${link} ${"x".repeat(MAX_COMMIT_SUBJECT)}`);
});
it("tag push created mentions the tag", () => {

View file

@ -148,7 +148,7 @@ describe("gitea event parsing", () => {
};
const msg = formatEvent(route, event!);
expect(msg.title).toContain("org/repo");
expect(msg.fields![0].value).toBe(
expect(msg.description).toContain(
"[`abcd123`](https://git.example.com/org/repo/commit/abcd1234ef) fix stuff",
);
});