Skip to content

Commit

Permalink
feat(style): group scopes only when one of the scope have multiple co…
Browse files Browse the repository at this point in the history
…mmits
  • Loading branch information
antfu committed Jul 1, 2022
1 parent 24ad1a1 commit 312f796
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,17 @@ function formatSection(commits: Commit[], sectionName: string, options: Resolved
]

const scopes = groupBy(commits, 'scope')
let useScopeGroup = options.group

// group scopes only when one of the scope have multiple commits
if (!Object.entries(scopes).some(([k, v]) => k && v.length > 1))
useScopeGroup = false

Object.keys(scopes).sort().forEach((scope) => {
let padding = ''
let prefix = ''
const scopeText = `**${options.scopeMap[scope] || scope}**`
if (scope && options.group) {
if (scope && useScopeGroup) {
lines.push(`- ${scopeText}:`)
padding = ' '
}
Expand Down

0 comments on commit 312f796

Please sign in to comment.