buildMessageFromChanges routes to the appropriate message builder based on which change categories are present. Single-category changes use dedicated formats for backward compatibility; mixed changes use the combined format.
(changes TaskChanges, commitType string, includeBody, short bool)
| 105 | // which change categories are present. Single-category changes use dedicated |
| 106 | // formats for backward compatibility; mixed changes use the combined format. |
| 107 | func buildMessageFromChanges(changes TaskChanges, commitType string, includeBody, short bool) string { |
| 108 | onlyCompleted := len(changes.Completed) > 0 && len(changes.Added) == 0 && |
| 109 | len(changes.Started) == 0 && len(changes.Blocked) == 0 && len(changes.Cancelled) == 0 |
| 110 | if onlyCompleted { |
| 111 | return buildCommitMessage(changes.Completed, commitType, includeBody, short) |
| 112 | } |
| 113 | |
| 114 | onlyAdded := len(changes.Added) > 0 && len(changes.Completed) == 0 && |
| 115 | len(changes.Started) == 0 && len(changes.Blocked) == 0 && len(changes.Cancelled) == 0 |
| 116 | if onlyAdded { |
| 117 | return buildAddedTaskMessage(changes.Added, commitType) |
| 118 | } |
| 119 | |
| 120 | return buildMixedCommitMessage(changes, commitType, includeBody, short) |
| 121 | } |
| 122 | |
| 123 | func buildCommitMessage(tasks []*model.Task, commitType string, includeBody, short bool) string { |
| 124 | if len(tasks) == 1 { |
no test coverage detected