knife-changelog 1.2.2 → 1.2.3
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 +4 -4
- data/knife-changelog.gemspec +1 -1
- data/lib/knife/changelog/policyfile.rb +14 -35
- data/spec/unit/policyfile_spec.rb +11 -27
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8a6814c2c33a531b39095d40b5a29eac42e0d1d9f9771594eab6acf5585a2c1
|
4
|
+
data.tar.gz: 7e0be550e063acdb2b24fd8053815ddf5c19b9599c05147761227c28d2a946be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aa98d7ed974e17573f0ee28898f0475dc7629d1cd1f547e96152fafbe6e0c62ba5f1e6ab14228864e909bd1de7bc9be72e516dc2260cf431e4a90567f7a91c7
|
7
|
+
data.tar.gz: 6e40a18276224d6de4cff58176e18f3a7b2467949b6328504c0704514fc518519cdb49fa2eab7bbc5b735205e284e37f69fae6889176b5f9d73faf18b362f9e5
|
data/knife-changelog.gemspec
CHANGED
@@ -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.
|
8
|
+
spec.version = '1.2.3'
|
9
9
|
spec.authors = ['Gregoire Seux']
|
10
10
|
spec.email = ['kamaradclimber@gmail.com']
|
11
11
|
spec.summary = 'Facilitate access to cookbooks changelog'
|
@@ -104,52 +104,31 @@ class PolicyChangelog
|
|
104
104
|
def git_changelog(source_url, current, target)
|
105
105
|
dir = Dir.mktmpdir(TMP_PREFIX)
|
106
106
|
repo = Git.clone(source_url, dir)
|
107
|
-
|
108
|
-
c_tag, t_tag = correct_tags("v#{current}", "v#{target}", repo)
|
109
|
-
repo.log.between(c_tag, t_tag)
|
110
|
-
else
|
111
|
-
c_tag, t_tag = correct_tags(current, target, repo)
|
112
|
-
repo.log.between(c_tag, t_tag)
|
113
|
-
end.map do |commit|
|
107
|
+
repo.log.between(git_ref(current, repo), git_ref(target, repo)).map do |commit|
|
114
108
|
"#{commit.sha[0, 7]} #{commit.message.lines.first.strip}"
|
115
109
|
end.join("\n")
|
116
110
|
end
|
117
111
|
|
118
|
-
#
|
119
|
-
#
|
120
|
-
# @param current [String] current cookbook version tag
|
121
|
-
# @param target [String] target cookbook version tag
|
122
|
-
# @param repo [Git::Base] Git repository object
|
123
|
-
# @return [true, false]
|
124
|
-
def correct_tags(current, target, repo)
|
125
|
-
[git_tag(current, repo), git_tag(target, repo)]
|
126
|
-
end
|
127
|
-
|
128
|
-
# Tries to convert a supermarket tag to a git tag
|
112
|
+
# Tries to convert a supermarket tag to a git reference
|
129
113
|
# if there is a difference in formatting between the two.
|
130
114
|
# This is issue is present for the 'java' cookbook.
|
131
115
|
# https://github.com/agileorbit-cookbooks/java/issues/450
|
132
116
|
#
|
133
|
-
# @param
|
117
|
+
# @param ref [String] version reference
|
134
118
|
# @param repo [Git::Base] Git repository object
|
135
119
|
# @return [String]
|
136
|
-
def
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
120
|
+
def git_ref(myref, repo)
|
121
|
+
possible_refs = ['v' + myref, myref]
|
122
|
+
possible_refs += possible_refs.map { |ref| ref.chomp('.0') } if myref[/\.0$/]
|
123
|
+
existing_ref = possible_refs.find do |ref|
|
124
|
+
begin
|
125
|
+
repo.checkout(ref)
|
126
|
+
rescue ::Git::GitExecuteError
|
127
|
+
false
|
128
|
+
end
|
144
129
|
end
|
145
|
-
|
146
|
-
|
147
|
-
# Detects the format of a Git tag - v1.0.0 or 1.0.0
|
148
|
-
#
|
149
|
-
# @param repo [Git::Base] Git repository object
|
150
|
-
# @return [String] Git tag versioning type
|
151
|
-
def tag_format(repo)
|
152
|
-
sort_by_version(repo.tags).last.name[/^v/] ? 'v' : ''
|
130
|
+
raise "Impossible to find existing references to #{possible_refs} in #{repo.remote.url}" unless existing_ref
|
131
|
+
existing_ref
|
153
132
|
end
|
154
133
|
|
155
134
|
# Sort tags by version and filter out invalid version tags
|
@@ -179,10 +179,10 @@ RSpec.describe PolicyChangelog do
|
|
179
179
|
|
180
180
|
context 'when given two tags' do
|
181
181
|
it 'generates a changelog between two tags' do
|
182
|
-
allow(changelog).to receive(:tag_format).and_return('v')
|
183
182
|
allow(git).to receive(:clone).and_return(git_repo)
|
183
|
+
allow(changelog).to receive(:git_ref).with('1.0.0', any_args).and_return('v1.0.0')
|
184
|
+
allow(changelog).to receive(:git_ref).with('1.0.1', any_args).and_return('v1.0.1')
|
184
185
|
allow(changelog).to receive(:correct_tags)
|
185
|
-
.and_return(['v1.0.0', 'v1.0.1'])
|
186
186
|
allow(git_repo).to receive_message_chain(:log, :between)
|
187
187
|
.with('v1.0.0', 'v1.0.1')
|
188
188
|
.and_return([git_commit])
|
@@ -193,51 +193,35 @@ RSpec.describe PolicyChangelog do
|
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
|
-
describe '#
|
196
|
+
describe '#git_ref' do
|
197
197
|
let(:repo) { double('repo') }
|
198
198
|
|
199
199
|
context 'when tag valid' do
|
200
200
|
it 'returns correct git tag' do
|
201
|
+
allow(repo).to receive(:checkout).with('v1.0.0').and_raise(::Git::GitExecuteError)
|
201
202
|
allow(repo).to receive(:checkout).with('1.0.0').and_return(true)
|
202
203
|
|
203
|
-
expect(changelog.
|
204
|
+
expect(changelog.git_ref('1.0.0', repo)).to eq('1.0.0')
|
204
205
|
end
|
205
206
|
end
|
206
207
|
|
207
208
|
context 'when tag invalid and able to correct' do
|
208
209
|
it 'returns correct git tag' do
|
210
|
+
allow(repo).to receive(:checkout).with(/v1.0/).and_raise(::Git::GitExecuteError)
|
209
211
|
allow(repo).to receive(:checkout).with('1.0.0').and_raise(::Git::GitExecuteError)
|
210
212
|
allow(repo).to receive(:checkout).with('1.0').and_return(true)
|
211
213
|
|
212
|
-
expect(changelog.
|
214
|
+
expect(changelog.git_ref('1.0.0', repo)).to eq('1.0')
|
213
215
|
end
|
214
216
|
end
|
215
217
|
|
216
218
|
context 'when tags invalid and unable to correct' do
|
217
219
|
it 'raises exception' do
|
218
|
-
allow(repo).to receive(:
|
219
|
-
allow(repo).to receive(:checkout).with(
|
220
|
-
|
221
|
-
expect { changelog.git_tag('1.0.0', repo) }
|
222
|
-
.to raise_error(RuntimeError, 'Difference between Git and Supermarket tags')
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
describe '#tag_format' do
|
228
|
-
context 'when it receives a tag' do
|
229
|
-
let(:repo) { Git::Base }
|
230
|
-
|
231
|
-
it 'detects type for regular tag' do
|
232
|
-
allow(repo).to receive_message_chain(:tags, :last, :name).and_return('1.0.0')
|
233
|
-
allow(changelog).to receive(:sort_by_version).and_return(repo.tags)
|
234
|
-
expect(changelog.tag_format(repo)).to eq('')
|
235
|
-
end
|
220
|
+
allow(repo).to receive(:remote).and_return(double('remote', url: 'url.com'))
|
221
|
+
allow(repo).to receive(:checkout).with(any_args).and_raise(::Git::GitExecuteError)
|
236
222
|
|
237
|
-
|
238
|
-
|
239
|
-
allow(changelog).to receive(:sort_by_version).and_return(repo.tags)
|
240
|
-
expect(changelog.tag_format(repo)).to eq('v')
|
223
|
+
expect { changelog.git_ref('1.0.0', repo) }
|
224
|
+
.to raise_error(RuntimeError, /Impossible to find existing/)
|
241
225
|
end
|
242
226
|
end
|
243
227
|
end
|
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.
|
4
|
+
version: 1.2.3
|
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-
|
11
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|