knife-changelog 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 705a36f063f6249e387aa5d52cd1784cb38f1ac9
4
- data.tar.gz: 521f2a3658ca50040b0f119437fb38d37111fefa
3
+ metadata.gz: 15f2df34a124b7b5ff0adcda1708cd7aab61b803
4
+ data.tar.gz: 457fa10cc15ae920422d08ecb584e8e98889f010
5
5
  SHA512:
6
- metadata.gz: 6f32a1750c57c95b8dc9144c4783d95d0d6281bcd76bd2e0e77def896d0b6eaca27d88b4b0f2a5e1eb4dd4aa7ddd856f90f06a2a303b95944cb5c090f6c30898
7
- data.tar.gz: 87ad561196aa635e2508eb0871f235d216fd66e5141bb12a10d334c4b72e807e349a68c88e48c24bdff0c519e4fa3d86d579792901b5ecf8c271aa2c53471056
6
+ metadata.gz: 51f86b089762e86f31a45587915b36ae8c94abd3c11b5b8a29dc23bf99f540368033933f0a6289132caa20c8bf159349d51e528443cfb206d0da56256fe4cb53
7
+ data.tar.gz: 38eb6d3b2fa6a6edf9ac17ffc809008e5685b90a89f44beefcb5a0c013548bd1024a9522e7ad09c3945a874e7b4a88ab29a0c365d5e18e93c8f25d821589e9e4
@@ -15,16 +15,6 @@ class Chef
15
15
  require "berkshelf"
16
16
  end
17
17
 
18
- def initialize(options)
19
- super
20
- @changelog = if File.exists?(config[:policyfile])
21
- KnifeChangelog::Changelog::Policyfile.new(config[:policyfile], config)
22
- else
23
- berksfile = Berkshelf::Berksfile.from_options({})
24
- KnifeChangelog::Changelog::Berksfile.new(berksfile.lockfile.locks, config, berksfile.sources)
25
- end
26
- end
27
-
28
18
  option :linkify,
29
19
  :short => '-l',
30
20
  :long => '--linkify',
@@ -57,11 +47,20 @@ class Chef
57
47
  :description => 'Link to policyfile, defaults to Policyfile.rb',
58
48
  :default => 'Policyfile.rb'
59
49
 
50
+ option :update,
51
+ :long => '--update',
52
+ :description => 'Update Berksfile'
60
53
 
61
54
  def run
62
55
  Log.info config
63
- changelog = @changelog.run(@name_args)
64
- puts changelog
56
+ @changelog = if config[:policyfile] && File.exists?(config[:policyfile])
57
+ KnifeChangelog::Changelog::Policyfile.new(config[:policyfile], config)
58
+ else
59
+ berksfile = Berkshelf::Berksfile.from_options({})
60
+ KnifeChangelog::Changelog::Berksfile.new(berksfile, config)
61
+ end
62
+ changelog_text = @changelog.run(@name_args)
63
+ puts changelog_text
65
64
  end
66
65
  end
67
66
 
@@ -5,10 +5,11 @@ require_relative 'changelog'
5
5
  class KnifeChangelog
6
6
  class Changelog
7
7
  class Berksfile < Changelog
8
- def initialize(locked_versions, config, sources)
8
+ def initialize(berksfile, config)
9
9
  require 'berkshelf'
10
- @locked_versions = locked_versions
11
- @sources = sources
10
+ @locked_versions = berksfile.lockfile.locks
11
+ @sources = berksfile.sources
12
+ @berksfile = berksfile
12
13
  super(config)
13
14
  end
14
15
 
@@ -53,6 +54,10 @@ class KnifeChangelog
53
54
  @locked_versions[name].locked_version.to_s
54
55
  end
55
56
 
57
+ def update(cookbooks)
58
+ @berksfile.update(*cookbooks)
59
+ end
60
+
56
61
  private
57
62
 
58
63
  def ck_dep(name)
@@ -85,6 +85,7 @@ class KnifeChangelog
85
85
  Chef::Log.debug "Checking changelog for #{submodule} (submodule)"
86
86
  execute(submodule, true)
87
87
  end
88
+ update(cks) if @config[:update]
88
89
  ensure
89
90
  clean
90
91
  end
@@ -55,6 +55,10 @@ class KnifeChangelog
55
55
  Location.new(spec[:git], spec[:revision], spec[:branch])
56
56
  end
57
57
 
58
+ def update(cookbooks)
59
+ raise NotImplementedError
60
+ end
61
+
58
62
  # return a list of supermarket uri for a given cookbook
59
63
  # example: [ 'https://supermarket.chef.io' ]
60
64
  def supermarkets_for(name)
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module Changelog
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
@@ -9,6 +9,16 @@ WebMock.disable_net_connect!
9
9
  RSpec.shared_examples 'changelog generation' do
10
10
  # this supposes that "changelog" is an instance of KnifeChangelog::Changelog
11
11
  it 'detects basic changelog' do
12
+ mock_git('second_out_of_date', <<-EOH)
13
+ aaaaaa commit in second_out_of_date
14
+ bbbbbb bugfix in second_out_of_date
15
+ EOH
16
+ mock_git('outdated1', <<-EOH)
17
+ aaaaaa commit in outdated1
18
+ bbbbbb bugfix in outdated1
19
+ EOH
20
+ mock_git('uptodate', '')
21
+
12
22
  changelog_txt = changelog.run(%w[new_cookbook uptodate outdated1 second_out_of_date])
13
23
  expect(changelog_txt).to match(/commit in outdated1/)
14
24
  expect(changelog_txt).to match(/commit in second_out_of_date/)
@@ -29,16 +39,6 @@ describe KnifeChangelog::Changelog do
29
39
 
30
40
  mock_universe('https://mysupermarket2.io', uptodate: %w[1.0.0], outdated1: %w[1.0.0 1.1.0], second_out_of_date: %w[1.0.0 1.2.0])
31
41
  mock_universe('https://mysupermarket.io', {})
32
-
33
- mock_git('second_out_of_date', <<-EOH)
34
- aaaaaa commit in second_out_of_date
35
- bbbbbb bugfix in second_out_of_date
36
- EOH
37
- mock_git('outdated1', <<-EOH)
38
- aaaaaa commit in outdated1
39
- bbbbbb bugfix in outdated1
40
- EOH
41
- mock_git('uptodate', '')
42
42
  end
43
43
 
44
44
  def mock_git(name, changelog)
@@ -93,18 +93,40 @@ describe KnifeChangelog::Changelog do
93
93
  )
94
94
  end
95
95
 
96
+ let(:options) do
97
+ {}
98
+ end
99
+
96
100
  let(:changelog) do
97
- KnifeChangelog::Changelog::Berksfile.new(berksfile.lockfile.locks, {}, berksfile.sources)
101
+ KnifeChangelog::Changelog::Berksfile.new(berksfile, options)
98
102
  end
99
103
 
100
104
  include_examples 'changelog generation'
105
+
106
+ context 'with --update' do
107
+ let(:options) do
108
+ { update: true }
109
+ end
110
+ it 'updates Berksfile' do
111
+ mock_git('outdated1', <<-EOH)
112
+ aaaaaa commit in outdated1
113
+ bbbbbb bugfix in outdated1
114
+ EOH
115
+ expect(berksfile).to receive(:update).with('outdated1')
116
+ changelog.run(%w[outdated1])
117
+ end
118
+ end
101
119
  end
102
120
 
103
121
  context 'in policyfile mode' do
104
122
  let(:policyfile_path) { File.join(File.dirname(__FILE__), '../data/Policyfile.rb') }
105
123
 
124
+ let(:options) do
125
+ {}
126
+ end
127
+
106
128
  let(:changelog) do
107
- KnifeChangelog::Changelog::Policyfile.new(policyfile_path, {})
129
+ KnifeChangelog::Changelog::Policyfile.new(policyfile_path, options)
108
130
  end
109
131
 
110
132
  before(:each) do
@@ -112,6 +134,19 @@ describe KnifeChangelog::Changelog do
112
134
  end
113
135
 
114
136
  include_examples 'changelog generation'
137
+
138
+ context 'with --update' do
139
+ let(:options) do
140
+ { update: true }
141
+ end
142
+ it 'fails with not implemented error' do
143
+ mock_git('outdated1', <<-EOH)
144
+ aaaaaa commit in outdated1
145
+ bbbbbb bugfix in outdated1
146
+ EOH
147
+ expect { changelog.run(%w[outdated1]) }.to raise_error(NotImplementedError)
148
+ end
149
+ end
115
150
  end
116
151
  end
117
152
 
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.0.1
4
+ version: 1.0.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: 2017-10-05 00:00:00.000000000 Z
11
+ date: 2017-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  requirements: []
215
215
  rubyforge_project:
216
- rubygems_version: 2.6.13
216
+ rubygems_version: 2.6.14
217
217
  signing_key:
218
218
  specification_version: 4
219
219
  summary: Facilitate access to cookbooks changelog