UNPKG

@elsikora/commitizen-plugin-commitlint-ai

Version:
67 lines (64 loc) 1.81 kB
'use strict'; /** * Value object representing a commit message body */ class CommitBody { BREAKING_CHANGE; CONTENT; constructor(content, breakingChange) { this.CONTENT = content?.trim() ?? undefined; this.BREAKING_CHANGE = breakingChange?.trim() ?? undefined; } /** * Check if two bodies are equal * @param {CommitBody} other - The other commit body to compare with * @returns {boolean} True if the bodies are equal */ equals(other) { return this.CONTENT === other.CONTENT && this.BREAKING_CHANGE === other.BREAKING_CHANGE; } /** * Get the breaking change description * @returns {string | undefined} The breaking change description or undefined */ getBreakingChange() { return this.BREAKING_CHANGE; } /** * Get the body content * @returns {string | undefined} The body content or undefined */ getContent() { return this.CONTENT; } /** * Check if there is a breaking change * @returns {boolean} True if there is a breaking change */ hasBreakingChange() { return !!this.BREAKING_CHANGE; } /** * Check if the body is empty * @returns {boolean} True if the body is empty */ isEmpty() { return !this.CONTENT && !this.BREAKING_CHANGE; } /** * Format the body as a string * @returns {string} The formatted body text */ toString() { const parts = []; if (this.BREAKING_CHANGE) { parts.push(`BREAKING CHANGE: ${this.BREAKING_CHANGE}`); } if (this.CONTENT) { parts.push(this.CONTENT); } return parts.join("\n\n"); } } exports.CommitBody = CommitBody; //# sourceMappingURL=commit-body.value-object.js.map