Skip to content

Commit 7e0502a

Browse files
committed
feat: case-insensitive scope grouping in changelog and filtering
Normalize scope names to lowercase when grouping commits in the changelog and when matching include_scopes/ignore_scopes filters. Scopes like Login, login, and LOGIN are now treated as the same scope. The display uses the casing from the first commit seen. Closes #52
1 parent 92b6463 commit 7e0502a

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

lib/fastlane/plugin/semantic_release/actions/conventional_changelog.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,16 @@ def self.note_builder(format, commits, version, commit_url, params)
8484

8585
def self.build_scope_lines(type_commits, format, commit_url, params)
8686
result = ""
87-
grouped = type_commits.group_by { |commit| commit[:scope] }
87+
grouped = type_commits.group_by { |commit| commit[:scope]&.downcase }
8888

8989
grouped.each do |scope, scope_commits|
9090
if scope.nil? || scope_commits.length == 1
9191
scope_commits.each do |commit|
9292
result += build_commit_line("-", commit, format, commit_url, params, include_scope: true)
9393
end
9494
else
95-
result += "- #{style_text("#{scope}:", format, 'bold')}\n"
95+
display_scope = scope_commits.first[:scope]
96+
result += "- #{style_text("#{display_scope}:", format, 'bold')}\n"
9697
scope_commits.each do |commit|
9798
result += build_commit_line(" -", commit, format, commit_url, params, include_scope: false)
9899
end

lib/fastlane/plugin/semantic_release/helper/semantic_release_helper.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def self.git_log(params)
2525
end
2626

2727
def self.should_exclude_commit(params)
28-
commit_scope = params[:commit_scope]
29-
scopes_to_include = params[:include_scopes]
30-
scopes_to_ignore = params[:ignore_scopes]
28+
commit_scope = params[:commit_scope]&.downcase
29+
scopes_to_include = params[:include_scopes].map(&:downcase)
30+
scopes_to_ignore = params[:ignore_scopes].map(&:downcase)
3131

3232
return !scopes_to_include.include?(commit_scope) unless scopes_to_include.empty?
3333
return scopes_to_ignore.include?(commit_scope) unless commit_scope.nil?

spec/conventional_changelog_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,33 @@ def execute_lane_test_no_links_slack
395395
end
396396
end
397397

398+
describe 'case-insensitive scope grouping' do
399+
commits = [
400+
"feat(Login): add biometric auth||long_hash|short_hash|Jiri Otahal|time",
401+
"fix(login): fix session timeout||long_hash|short_hash|Jiri Otahal|time",
402+
"feat(LOGIN): add SSO support||long_hash|short_hash|Jiri Otahal|time"
403+
]
404+
405+
it "should group scopes case-insensitively in markdown format" do
406+
allow(Fastlane::Actions::ConventionalChangelogAction).to receive(:get_commits_from_hash).and_return(commits)
407+
allow(Date).to receive(:today).and_return(Date.new(2019, 5, 25))
408+
409+
result = [
410+
"# 1.0.2 (2019-05-25)",
411+
"",
412+
"### Features",
413+
"- **Login:**",
414+
" - add biometric auth ([short_hash](/long_hash))",
415+
" - add SSO support ([short_hash](/long_hash))",
416+
"",
417+
"### Bug fixes",
418+
"- **login:** fix session timeout ([short_hash](/long_hash))"
419+
].join("\n")
420+
421+
expect(execute_lane_test).to eq(result)
422+
end
423+
end
424+
398425
describe 'revert commits in changelog' do
399426
it "should display reverted fix under Bug fixes section" do
400427
commits = [

0 commit comments

Comments
 (0)