UNPKG

@elsikora/commitizen-plugin-commitlint-ai

Version:
70 lines (68 loc) 1.84 kB
/** * Entity representing a complete commit message */ class CommitMessage { BODY; HEADER; constructor(header, body) { this.HEADER = header; this.BODY = body; } /** * Get the commit body * @returns {CommitBody} The commit body */ getBody() { return this.BODY; } /** * Get breaking change text if present * @returns {string | undefined} The breaking change text or undefined */ getBreakingChange() { return this.BODY.getBreakingChange(); } /** * Get the commit header * @returns {CommitHeader} The commit header */ getHeader() { return this.HEADER; } /** * Check if this is a breaking change * @returns {boolean} True if breaking change */ isBreakingChange() { return this.BODY.hasBreakingChange(); } /** * Format the complete commit message * @returns {string} The formatted commit message */ toString() { const parts = [this.HEADER.toString()]; if (!this.BODY.isEmpty()) { parts.push(this.BODY.toString()); } return parts.join("\n\n"); } /** * Create a new CommitMessage with a different body * @param {CommitBody} body - The new body * @returns {CommitMessage} A new CommitMessage instance with the updated body */ withBody(body) { return new CommitMessage(this.HEADER, body); } /** * Create a new CommitMessage with a different header * @param {CommitHeader} header - The new header * @returns {CommitMessage} A new CommitMessage instance with the updated header */ withHeader(header) { return new CommitMessage(header, this.BODY); } } export { CommitMessage }; //# sourceMappingURL=commit-message.entity.js.map