Skip to content

Commit d1957ed

Browse files
committed
fix(scm): 🐛 avoid attribution leading blank line
1 parent 788a100 commit d1957ed

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/services/commit-message/__tests__/attribution.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ describe("commit message attribution", () => {
4040
)
4141
})
4242

43+
it("returns only trimmed attribution when message is empty", () => {
44+
expect(appendCommitMessageAttribution(" ", "\nAssisted-by: Zoo Code\n")).toBe("Assisted-by: Zoo Code")
45+
})
46+
4347
it("does not duplicate an existing attribution footer", () => {
4448
const message = "feat(scm): generate commits\n\nAssisted-by: Zoo Code"
4549

src/services/commit-message/attribution.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export function appendCommitMessageAttribution(message: string, attribution: str
6464
return cleanedMessage
6565
}
6666

67+
if (!cleanedMessage) {
68+
return cleanedAttribution
69+
}
70+
6771
if (cleanedMessage.endsWith(cleanedAttribution)) {
6872
return cleanedMessage
6973
}

0 commit comments

Comments
 (0)