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 +4 -4
- data/.travis.yml +11 -4
- data/README.md +20 -17
- data/berkshelf-bzr.gemspec +4 -3
- data/lib/berkshelf/bzr/version.rb +1 -1
- data/lib/berkshelf/locations/bzr.rb +32 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/unit/locations/bzr_spec.rb +30 -29
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df4ee900cfdfca48b8846ab67bb0f4276fd8217
|
4
|
+
data.tar.gz: 77e4f1ab05c61d938403d4eadf2edd95f5623c73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fd1115f955ff0d8541d611fdc6d8db9026e947785e4c6d0e1b694180d3d870ca5db7944aa4a15ac006505f56fb97dab5da4fd75c2c41e5331305f87e49f57d8
|
7
|
+
data.tar.gz: b5481a28137f178a78b52ca1dce8e64c158db0afc919df55a739123755396abcebee7fadd4534b5b1f8133fb1bee2db99f6f75942f810b72a73a2c634b64d113
|
data/.travis.yml
CHANGED
@@ -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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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.
|
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
|
-
|
11
|
+
```
|
12
|
+
gem 'berkshelf-bzr'
|
13
|
+
```
|
14
14
|
|
15
15
|
And then execute:
|
16
16
|
|
17
|
-
|
17
|
+
```
|
18
|
+
$ bundle
|
19
|
+
```
|
18
20
|
|
19
21
|
Or install it yourself as:
|
20
22
|
|
21
|
-
|
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://
|
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
|
|
data/berkshelf-bzr.gemspec
CHANGED
@@ -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', '~>
|
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', '~>
|
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'
|
31
|
+
spec.add_development_dependency 'rake'
|
31
32
|
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]
|
data/spec/spec_helper.rb
CHANGED
@@ -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.
|
35
|
-
expect(subject.installed?).to
|
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.
|
39
|
-
subject.
|
40
|
-
expect(subject.installed?).to
|
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.
|
45
|
-
subject.
|
46
|
-
expect(subject.installed?).to
|
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.
|
53
|
-
FileUtils.
|
54
|
-
File.
|
55
|
-
subject.
|
56
|
-
subject.
|
57
|
-
subject.
|
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.
|
63
|
-
subject.
|
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.
|
72
|
-
subject.
|
73
|
-
FileUtils.
|
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.
|
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.
|
88
|
-
CachedCookbook.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
|
+
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:
|
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: '
|
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: '
|
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: '
|
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: '
|
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
|
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
|
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:
|
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.
|
126
|
+
rubygems_version: 2.6.6
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Bazaar support for Berkshelf
|