knife-changelog 1.2.5 → 1.3.0

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: afbea7c14cdeabf23ea4f20db0af330eff3cad96f1239ded017e125182fb1ffb
4
- data.tar.gz: 7cb891e33b24d3d99c0822d509af3f2c50ae9fb40cb6dde74bf83c1b21fc5075
3
+ metadata.gz: 8fc579c229163b128ddd103ce2781f9b9ade76c5652d5cee2b35be4aa0300a9f
4
+ data.tar.gz: 542377730e977eb8d8cd4fb89cbb23e47db92380986e2679c03fa380b7792eb0
5
5
  SHA512:
6
- metadata.gz: 56b42d01d1246064e7d74812cbccb51be231aea9603a0364046a1dde153127d6ee0eb24bede748c6af660dc0131f4bd1b20858b3fc2b0057ac6e86206918c75f
7
- data.tar.gz: 1840e41083d1167cb803590b9151b543ed6df478d89e12a8ca81e921359eb6383ac340a847d87f99d91a91e17e2eefc5fd0bca338e970cd86a45cf6834045d1a
6
+ metadata.gz: 160785af9a8e1d0702fe055c10acbbb857a405ea6d4303cd592d57073d00f7ebb8bcc0fa08700dbae4277dcf415dbf4eed8b402e98c4f43edbf52e1e94846783
7
+ data.tar.gz: c74421eccbddb0cf7bdb55585e237c9d7f4fb3cf01a1e98cac7f73b58d7ac194e6a8a497115bea7b61ae93b529d50f81d4dc46dba23f874aefc8ab5d88f8b7c9
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'knife-changelog'
8
- spec.version = '1.2.5'
8
+ spec.version = '1.3.0'
9
9
  spec.authors = ['Gregoire Seux']
10
10
  spec.email = ['kamaradclimber@gmail.com']
11
11
  spec.summary = 'Facilitate access to cookbooks changelog'
@@ -239,10 +239,15 @@ class KnifeChangelog
239
239
  c
240
240
  end
241
241
 
242
+ GERRIT_REGEXP = %r{^(.*)/[^/]+/[^/]+(?:\.git)$}
242
243
  def linkify(url, changelog)
243
- changelog.map do |line|
244
- line.gsub(/^([a-f0-9]+) (.*)$/, '\2 (%s/commit/\1) ' % [url.chomp('.git')])
245
- end
244
+ format = case url
245
+ when /gitlab/, /github/
246
+ "\\2 (#{url.chomp('.git')}/commit/\\1)"
247
+ when GERRIT_REGEXP
248
+ "\\2 (#{::Regexp.last_match(1)}/#/q/\\1)"
249
+ end
250
+ format ? changelog.map { |line| line.sub(/^([a-f0-9]+) (.*)$/, format) } : changelog
246
251
  end
247
252
 
248
253
  def https_url(location)
@@ -92,6 +92,35 @@ RSpec.describe PolicyChangelog do
92
92
  end
93
93
  end
94
94
 
95
+ describe '#linkify' do
96
+ subject { KnifeChangelog::Changelog.new(config) }
97
+ let(:config) { double('config') }
98
+ let(:changelog) do
99
+ ['9363423 Leverage criteo-flavor 3.11 to benefit from labels']
100
+ end
101
+ context 'when url is gitlab style' do
102
+ let(:url) { 'https://gitlab.com/chef-cookbooks/criteo-rackguru.git' }
103
+
104
+ it 'creates a gitlab style link' do
105
+ expect(subject.linkify(url, changelog).first).to match(%r{https://gitlab.com/chef-cookbooks/criteo-rackguru/commit/9363423})
106
+ end
107
+ end
108
+
109
+ context 'when url is github style' do
110
+ let(:url) { 'https://github.com/chef-cookbooks/criteo-rackguru.git' }
111
+ it 'creates a github style link' do
112
+ expect(subject.linkify(url, changelog).first).to match(%r{https://github.com/chef-cookbooks/criteo-rackguru/commit/9363423})
113
+ end
114
+ end
115
+
116
+ context 'when url has no known style' do
117
+ let(:url) { 'https://review.mycompany.com/chef-cookbooks/criteo-rackguru.git' }
118
+ it 'creates a gerrit style link' do
119
+ expect(subject.linkify(url, changelog).first).to match(%r{https://review.mycompany.com/#/q/9363423})
120
+ end
121
+ end
122
+ end
123
+
95
124
  describe '#versions' do
96
125
  context 'when type is current' do
97
126
  it 'returns correct current versions' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-changelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregoire Seux
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-24 00:00:00.000000000 Z
11
+ date: 2018-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler