sem_ver_components 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ad5f6f5e4ed0306f70bc8967049da98b057cbef64efcbb45708bcc97c05921d
4
- data.tar.gz: a5c86d63ed59ecb62ab18e9a6043bb53f3cafd04058b5c935ae9851765475904
3
+ metadata.gz: c9da50f9edee211f731452cdfb03e376d2b895f75d04a5ebdbfe2d30c87dfb90
4
+ data.tar.gz: 1ad69a75e32306303ae841aa9aecf633a7c90db25cd529d9c8c791837e154e04
5
5
  SHA512:
6
- metadata.gz: b7d91845e1d2c9488c91fc55fc7f33b83097c6a2f2487c5001ba4379e8123df2e412058b2dbdf69e18c1288efd7645e3b0588987017c0bd00086f16e5fdd65de
7
- data.tar.gz: df0a4368d25cceeef753bf31dc66a27442327e39bcd6686e49213144aafadb6f723864761c6700d5b1d9e1d45564efef59357f47b7b66f91cd7e895be70e2a77
6
+ metadata.gz: d4b54b6a41a4060da5171f2f809ca57aac59d75a72194da62b84d6e1a598f40e0ea29682221fdb0fda163db6dc494dcaf7dcd74b52fdbea6b20b167af3cc75b7
7
+ data.tar.gz: 2111a729b803e12870b3df2d1e4efc2411d34deeff6882218b2313b17686748d8350f47f56a89a39f12b5c0d997b3caef7ec4134e7c57462dc05f0704605694b
@@ -41,20 +41,44 @@ module SemVerComponents
41
41
  end
42
42
  git_url = @local_git.git.remote('origin').url
43
43
  git_url = git_url[0..-5] if git_url.end_with?('.git')
44
+ # Reference merge commits: merged commits will not be part of the changelog, but their bump level will be taken into account when reporting the merge commit.
45
+ # List of merged commits' shas, per merge commit sha.
46
+ # Hash< String, Array< String > >
47
+ merge_commits = {}
48
+ commits_info.each do |commit_info|
49
+ git_commit = commit_info[:commit]
50
+ git_commit_parents = git_commit.parents
51
+ # In the case of a merge commit, reference all commits that are part of this merge commit, directly from the graph
52
+ if git_commit_parents.size > 1
53
+ git_commit_sha = git_commit.sha
54
+ merge_commits[git_commit_sha] = @local_git.git_log.between(@local_git.git.merge_base(*git_commit_parents.map(&:sha)).first.sha, git_commit_sha)[1..-1].map(&:sha)
55
+ end
56
+ end
57
+ commits_to_ignore = merge_commits.values.flatten(1).sort.uniq
44
58
  # Group commits per bump level, per component
45
59
  # Hash< String or nil, Hash< Integer, Array<Git::Object::Commit> >
46
60
  commits_per_component = {}
47
- # Also reference commits to be ignored: commits that are part of a merge commit
48
- merged_commits = []
49
61
  commits_info.each do |commit_info|
50
62
  git_commit = commit_info[:commit]
51
- commit_info[:components_bump_levels].each do |component, bump_level|
63
+ git_commit_sha = git_commit.sha
64
+ # Don't put merged commits as we consider the changelog should contain the merge commit comment.
65
+ next if commits_to_ignore.include?(git_commit_sha)
66
+ components_bump_levels = commit_info[:components_bump_levels]
67
+ # If we are dealing with a merge commit, consider the components' bump levels of the merged commits
68
+ if merge_commits.key?(git_commit_sha)
69
+ merge_commits[git_commit_sha].each do |merged_commit_sha|
70
+ components_bump_levels = components_bump_levels.merge(
71
+ commits_info.find { |search_commit_info| search_commit_info[:commit].sha == merged_commit_sha }[:components_bump_levels]
72
+ ) do |component, bump_level_1, bump_level_2|
73
+ [bump_level_1, bump_level_2].max
74
+ end
75
+ end
76
+ end
77
+ components_bump_levels.each do |component, bump_level|
52
78
  commits_per_component[component] = {} unless commits_per_component.key?(component)
53
79
  commits_per_component[component][bump_level] = [] unless commits_per_component[component].key?(bump_level)
54
80
  commits_per_component[component][bump_level] << git_commit
55
81
  end
56
- # In the case of a merge commit, reference all commits that are part of this merge commit, directly from the graph
57
- merged_commits.concat(@local_git.git_log.between(@local_git.git.merge_base(*git_commit.parents.map(&:sha)).first.sha, git_commit.sha)[1..-1].map(&:sha)) if git_commit.parents.size > 1
58
82
  end
59
83
  puts "# [v#{new_version}](#{git_url}/compare/#{@local_git.git_from}...v#{new_version}) (#{Time.now.utc.strftime('%F %T')})"
60
84
  puts
@@ -78,8 +102,6 @@ module SemVerComponents
78
102
  # Hash< String, String >
79
103
  commit_lines = {}
80
104
  commits.each do |commit|
81
- # Don't put merged commits as we consider the changelog should contain the merge commit comment.
82
- next if merged_commits.include?(commit.sha)
83
105
  message_lines = commit.message.split("\n")
84
106
  commit_line = message_lines.first
85
107
  if commit_line =~ /^Merge pull request .+$/
@@ -1,5 +1,5 @@
1
1
  module SemVerComponents
2
2
 
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sem_ver_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan