berkshelf-bzr 0.4.0 → 1.0.0

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: 99abd99af539c2d1aab45f98ce47cde5aea182c0
4
- data.tar.gz: 8a947c8bf7ed24a0406375c95488e70e26282372
3
+ metadata.gz: 8df4ee900cfdfca48b8846ab67bb0f4276fd8217
4
+ data.tar.gz: 77e4f1ab05c61d938403d4eadf2edd95f5623c73
5
5
  SHA512:
6
- metadata.gz: ca57bab4b4595ee215f61a7f8a5047abc15f9bce72c285b528c398769c7cc19e4175e872d6c12e3b3e899860ac7f9e81a7c7c59963e1546cadda9ad5b1d6c454
7
- data.tar.gz: 12e7cd2b79b2ca5ce7df8bc530396b3b4c9e0e5f4fb99949cf0583b7fe06dc633b715ba4a5ede5876f6d91df9e2b070b0eb5370ca19c96a79ea2ff802f0cd680
6
+ metadata.gz: 5fd1115f955ff0d8541d611fdc6d8db9026e947785e4c6d0e1b694180d3d870ca5db7944aa4a15ac006505f56fb97dab5da4fd75c2c41e5331305f87e49f57d8
7
+ data.tar.gz: b5481a28137f178a78b52ca1dce8e64c158db0afc919df55a739123755396abcebee7fadd4534b5b1f8133fb1bee2db99f6f75942f810b72a73a2c634b64d113
@@ -1,12 +1,19 @@
1
+ sudo: true
2
+ language: ruby
3
+ cache: bundler
4
+
1
5
  before_install:
2
6
  - sudo apt-get update -qq
3
7
  - sudo apt-get install bzr
4
8
  - bzr whoami 'Test <test@test.net>'
5
9
 
6
- rvm:
7
- - 1.9.3
8
- - 2.0.0
9
- - 2.1.0
10
+ matrix:
11
+ include:
12
+ - rvm: 2.2.5
13
+ - rvm: 2.3.1
14
+ - rvm: ruby-head
15
+ allow_failures:
16
+ - rvm: ruby-head
10
17
 
11
18
  bundler_args: --jobs 7
12
19
 
data/README.md CHANGED
@@ -1,31 +1,35 @@
1
- Berkshelf Bzr
2
- ============
3
- [![Gem Version](https://badge.fury.io/rb/berkshelf-bzr.png)](http://badge.fury.io/rb/berkshelf-bzr)
4
- [![Build Status](https://travis-ci.org/berkshelf/berkshelf-bzr.png?branch=master)](https://travis-ci.org/berkshelf/berkshelf-bzr)
5
- [![Code Climate](https://codeclimate.com/github/berkshelf/berkshelf-bzr.png)](https://codeclimate.com/github/berkshelf/berkshelf-bzr)
1
+ # Berkshelf Bzr
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/berkshelf-bzr.svg)](http://badge.fury.io/rb/berkshelf-bzr) [![Build Status](https://travis-ci.org/berkshelf/berkshelf-bzr.svg?branch=master)](https://travis-ci.org/berkshelf/berkshelf-bzr) [![Code Climate](https://codeclimate.com/github/berkshelf/berkshelf-bzr.svg)](https://codeclimate.com/github/berkshelf/berkshelf-bzr)
6
4
 
7
5
  Berkshelf Bzr is a Berkshelf extension that adds support for downloading cookbooks from Bazaar locations.
8
6
 
9
- Installation
10
- ------------
7
+ ## Installation
8
+
11
9
  Add this line to your application's Gemfile:
12
10
 
13
- gem 'berkshelf-bzr'
11
+ ```
12
+ gem 'berkshelf-bzr'
13
+ ```
14
14
 
15
15
  And then execute:
16
16
 
17
- $ bundle
17
+ ```
18
+ $ bundle
19
+ ```
18
20
 
19
21
  Or install it yourself as:
20
22
 
21
- $ gem install berkshelf-bzr
23
+ ```
24
+ $ gem install berkshelf-bzr
25
+ ```
26
+
27
+ ## Usage
22
28
 
23
- Usage
24
- -----
25
29
  Activate the extension in your `Berksfile`:
26
30
 
27
31
  ```ruby
28
- source 'https://api.berkshelf.com'
32
+ source 'https://supermarket.chef.io'
29
33
  extension 'bzr'
30
34
  ```
31
35
 
@@ -41,10 +45,9 @@ You may also specify a `ref` (see output of bzr help revisionspec):
41
45
  cookbook 'mycookbook', bzr: 'lp:mycookbook', ref: 'revno:7'
42
46
  ```
43
47
 
44
- License & Authors
45
- -----------------
46
- The code is an adaptation of Mercurial berkshelf's extension
47
- (https://github.com/berkshelf/berkshelf-hg)
48
+ ## License & Authors
49
+
50
+ The code is an adaptation of Mercurial berkshelf's extension (<https://github.com/berkshelf/berkshelf-hg>)
48
51
 
49
52
  - Author: David Chauviere (d_chauviere@yahoo.fr)
50
53
 
@@ -19,13 +19,14 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ['lib']
21
21
 
22
+ spec.required_ruby_version = '>= 2.2.0'
22
23
  # Runtime dependencies
23
- spec.add_dependency 'berkshelf', '~> 3.1'
24
+ spec.add_dependency 'berkshelf', '~> 4.0'
24
25
 
25
26
  # Development dependencies
26
27
  spec.add_development_dependency 'aruba', '~> 0.5'
27
- spec.add_development_dependency 'rspec', '~> 2.14'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
29
 
29
30
  spec.add_development_dependency 'bundler', '~> 1.5'
30
- spec.add_development_dependency 'rake', '~> 0.9'
31
+ spec.add_development_dependency 'rake'
31
32
  end
@@ -1,5 +1,5 @@
1
1
  module Berkshelf
2
2
  module Bzr
3
- VERSION = '0.4.0'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
@@ -53,7 +53,7 @@ module Berkshelf
53
53
  #
54
54
  # @see BaseLocation#install
55
55
  def install
56
- if cached?
56
+ if cached? && valid?
57
57
  Dir.chdir(cache_path) do
58
58
  bzr %|pull|
59
59
  end
@@ -146,6 +146,37 @@ module Berkshelf
146
146
  end
147
147
  end
148
148
 
149
+ # Retrieve repository branch name or parent branch from a info output
150
+ #
151
+ # @return [string]
152
+ def retrieve_branch(output)
153
+ result = output.match(/repository branch: (.*)/)
154
+ return result.captures if result != nil
155
+ result = output.match(/parent branch: (.*)/)
156
+ return result.captures if result != nil
157
+ ''
158
+ end
159
+
160
+ # Determine if a bazaar cached location is valid
161
+ # Needed when we use alias in Berksfile
162
+ #
163
+ # @return [Boolean]
164
+ def valid?
165
+ # Get information
166
+ stdout_cached=''
167
+ Dir.chdir(cache_path) do
168
+ stdout_cached = retrieve_branch(bzr %|info|)
169
+ end
170
+ stdout_new = retrieve_branch(bzr %|info #{uri}|)
171
+ # Check if alias has been moved to a new release
172
+ if stdout_cached != stdout_new then
173
+ FileUtils.rm_rf cache_path
174
+ false
175
+ else
176
+ true
177
+ end
178
+ end
179
+
149
180
  # Determine if this bazaar repo has already been downloaded.
150
181
  #
151
182
  # @return [Boolean]
@@ -1,7 +1,6 @@
1
1
  require 'berkshelf/bzr'
2
2
 
3
3
  RSpec.configure do |config|
4
- config.treat_symbols_as_metadata_keys_with_true_values = true
5
4
  config.run_all_when_everything_filtered = true
6
5
  config.filter_run :focus
7
6
 
@@ -5,7 +5,7 @@ module Berkshelf
5
5
  let(:dependency) { double(name: 'bacon') }
6
6
 
7
7
  subject do
8
- described_class.new(dependency, bzr: 'https://repo.com',
8
+ described_class.new(dependency, bzr: 'https://repo.com',
9
9
  ref: 'revno:2', revision: 'revid:test@test.net-20140320213448-r0103d8bgjlu5jyz')
10
10
  end
11
11
 
@@ -31,36 +31,37 @@ module Berkshelf
31
31
 
32
32
  describe '#installed?' do
33
33
  it 'returns false when there is no revision' do
34
- subject.stub(:revision).and_return(nil)
35
- expect(subject.installed?).to be_false
34
+ allow(subject).to receive(:revision).and_return(nil)
35
+ expect(subject.installed?).to be_falsey
36
36
  end
37
37
  it 'returns false when the install_path does not exist' do
38
- subject.stub(:revision).and_return('abcd1234')
39
- subject.stub(:install_path).and_return(double(exist?: false))
40
- expect(subject.installed?).to be_false
38
+ allow(subject).to receive(:revision).and_return('abcd1234')
39
+ allow(subject).to receive(:install_path).and_return(double(exist?: false))
40
+ expect(subject.installed?).to be false
41
41
  end
42
42
 
43
43
  it 'returns true when the location is installed' do
44
- subject.stub(:revision).and_return('abcd1234')
45
- subject.stub(:install_path).and_return(double(exist?: true))
46
- expect(subject.installed?).to be_true
44
+ allow(subject).to receive(:revision).and_return('abcd1234')
45
+ allow(subject).to receive(:install_path).and_return(double(exist?: true))
46
+ expect(subject.installed?).to be true
47
47
  end
48
48
  end
49
49
 
50
50
  describe '#install' do
51
51
  before do
52
- CachedCookbook.stub(:from_store_path)
53
- FileUtils.stub(:cp_r)
54
- File.stub(:chmod)
55
- subject.stub(:validate_cached!)
56
- subject.stub(:validate_cookbook!)
57
- subject.stub(:bzr)
52
+ allow(CachedCookbook).to receive(:from_store_path)
53
+ allow(FileUtils).to receive(:cp_r)
54
+ allow(File).to receive(:chmod)
55
+ allow(subject).to receive(:validate_cached!)
56
+ allow(subject).to receive(:validate_cookbook!)
57
+ allow(subject).to receive(:bzr)
58
58
  end
59
59
 
60
60
  context 'when the repository is cached' do
61
61
  it 'pulls a new version' do
62
- Dir.stub(:chdir).and_yield
63
- subject.stub(:cached?).and_return(true)
62
+ allow(Dir).to receive(:chdir).and_yield
63
+ allow(subject).to receive(:cached?).and_return(true)
64
+ allow(subject).to receive(:valid?).and_return(true)
64
65
  expect(subject).to receive(:bzr).with('pull')
65
66
  subject.install
66
67
  end
@@ -68,9 +69,9 @@ module Berkshelf
68
69
 
69
70
  context 'when the revision is not cached' do
70
71
  it 'clones the repository' do
71
- Dir.stub(:chdir).and_yield
72
- subject.stub(:cached?).and_return(false)
73
- FileUtils.stub(:mkdir_p)
72
+ allow(Dir).to receive(:chdir).and_yield
73
+ allow(subject).to receive(:cached?).and_return(false)
74
+ allow(FileUtils).to receive(:mkdir_p)
74
75
  expect(subject).to receive(:bzr).with(/branch https:\/\/repo.com .*/)
75
76
  subject.install
76
77
  end
@@ -79,13 +80,13 @@ module Berkshelf
79
80
 
80
81
  describe '#cached_cookbook' do
81
82
  it 'returns nil if the cookbook is not installed' do
82
- subject.stub(:installed?).and_return(false)
83
+ allow(subject).to receive(:installed?).and_return(false)
83
84
  expect(subject.cached_cookbook).to be_nil
84
85
  end
85
86
 
86
87
  it 'returns the cookbook at the install_path' do
87
- subject.stub(:installed?).and_return(true)
88
- CachedCookbook.stub(:from_path)
88
+ allow(subject).to receive(:installed?).and_return(true)
89
+ allow(CachedCookbook).to receive(:from_path)
89
90
 
90
91
  expect(CachedCookbook).to receive(:from_path).once
91
92
  subject.cached_cookbook
@@ -100,17 +101,17 @@ module Berkshelf
100
101
  end
101
102
 
102
103
  it 'returns false when the other location is not an BzrLocation' do
103
- other.stub(:is_a?).and_return(false)
104
+ allow(other).to receive(:is_a?).and_return(false)
104
105
  expect(subject).to_not eq(other)
105
106
  end
106
107
 
107
108
  it 'returns false when the uri is different' do
108
- other.stub(:uri).and_return('different')
109
+ allow(other).to receive(:uri).and_return('different')
109
110
  expect(subject).to_not eq(other)
110
111
  end
111
112
 
112
113
  it 'returns false when the ref is different' do
113
- other.stub(:ref).and_return('different')
114
+ allow(other).to receive(:ref).and_return('different')
114
115
  expect(subject).to_not eq(other)
115
116
  end
116
117
  end
@@ -135,14 +136,14 @@ module Berkshelf
135
136
  before { described_class.send(:public, :bzr) }
136
137
 
137
138
  it 'raises an error if Bazaar is not installed' do
138
- Berkshelf.stub(:which).and_return(false)
139
+ allow(Berkshelf).to receive(:which).and_return(false)
139
140
  expect { subject.bzr('foo') }.to raise_error(BzrLocation::BzrNotInstalled)
140
141
  end
141
142
 
142
143
  it 'raises an error if the command fails' do
143
-
144
+ allow(Berkshelf).to receive(:which).and_return(true)
144
145
  shell_out = double('shell_out', success?: false, stdout: 'bzr: ERROR: Not a branch: "foo".', stderr: nil)
145
- Buff::ShellOut.stub(:shell_out).and_return(shell_out)
146
+ allow(Buff::ShellOut).to receive(:shell_out).and_return(shell_out)
146
147
  expect { subject.bzr('foo') }.to raise_error(BzrLocation::BzrCommandError)
147
148
  end
148
149
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkshelf-bzr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chauviere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-06 00:00:00.000000000 Z
11
+ date: 2016-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: berkshelf
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: aruba
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.14'
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.14'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '0.9'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '0.9'
82
+ version: '0'
83
83
  description: A Berkshelf plugin that adds support for downloading Chef cookbooks from
84
84
  Bazaar locations.
85
85
  email:
@@ -115,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ">="
117
117
  - !ruby/object:Gem::Version
118
- version: '0'
118
+ version: 2.2.0
119
119
  required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ">="
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.2.2
126
+ rubygems_version: 2.6.6
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Bazaar support for Berkshelf