vagrant-cookbook-fetcher 0.0.4 → 0.0.5
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.
- data/lib/vagrant_cookbook_fetcher.rb +64 -10
- metadata +40 -21
@@ -92,15 +92,46 @@ class CookbookFetcher
|
|
92
92
|
# pull
|
93
93
|
Dir.chdir(info[:dir]) do
|
94
94
|
# TODO ignores git creds
|
95
|
-
cmd = "git
|
95
|
+
cmd = "git remote set-url origin #{info[:repo]}"
|
96
96
|
unless system cmd then raise "Could not '#{cmd}'" end
|
97
|
-
cmd = "git
|
97
|
+
cmd = "git fetch origin"
|
98
98
|
unless system cmd then raise "Could not '#{cmd}'" end
|
99
|
+
local_branch = `git rev-parse --verify --symbolic-full-name #{info[:branch]} 2> /dev/null`
|
100
|
+
# no local branch
|
101
|
+
if ! $?.success? then
|
102
|
+
remote_branch = `git rev-parse --verify --symbolic-full-name origin/#{info[:branch]} 2> /dev/null`
|
103
|
+
unless $?.success? then raise "Unable to find branch or commit #{info[:branch]}" end
|
104
|
+
cmd = "git checkout -b #{info[:branch]} origin/#{info[:branch]}"
|
105
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
106
|
+
# no branch
|
107
|
+
elsif local_branch.empty? then
|
108
|
+
cmd = "git checkout #{info[:branch]}"
|
109
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
110
|
+
# local branch already exists
|
111
|
+
else
|
112
|
+
cmd = "git checkout #{info[:branch]}"
|
113
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
114
|
+
cmd = "git merge origin/#{info[:branch]}"
|
115
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
116
|
+
end
|
99
117
|
end
|
100
118
|
else
|
101
119
|
# clone
|
102
|
-
|
120
|
+
# can't use --branch because it won't work with commit ids
|
121
|
+
cmd = "git clone --no-checkout #{info[:repo]} #{info[:dir]}"
|
103
122
|
unless system cmd then raise "Could not '#{cmd}'" end
|
123
|
+
Dir.chdir(info[:dir]) do
|
124
|
+
remote_branch=`git rev-parse --verify -q origin/#{info[:branch]} 2> /dev/null`
|
125
|
+
# branch
|
126
|
+
if $?.success? then
|
127
|
+
cmd = "git checkout -B #{info[:branch]} origin/#{info[:branch]}"
|
128
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
129
|
+
#commit
|
130
|
+
else
|
131
|
+
cmd = "git checkout #{info[:branch]}"
|
132
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
133
|
+
end
|
134
|
+
end
|
104
135
|
end
|
105
136
|
else
|
106
137
|
raise "Unsupported VCS '#{info[:vcs]}' in checkout list for entry '#{dir}'"
|
@@ -119,8 +150,16 @@ class CookbookFetcher
|
|
119
150
|
# Create/clear the subdirs
|
120
151
|
things_to_link.each do |thing|
|
121
152
|
if !Dir.exists?(thing) then Dir.mkdir(thing) end
|
122
|
-
|
123
|
-
|
153
|
+
if (thing == "data_bags") then
|
154
|
+
Dir.foreach(thing) do |dbag_dir|
|
155
|
+
Dir.foreach(thing + '/' + dbag_dir) do |file|
|
156
|
+
if FileTest.symlink?(file) then File.delete(file) end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
else
|
160
|
+
Dir.foreach(thing) do |file|
|
161
|
+
if FileTest.symlink?(file) then File.delete(file) end
|
162
|
+
end
|
124
163
|
end
|
125
164
|
end
|
126
165
|
end
|
@@ -132,11 +171,26 @@ class CookbookFetcher
|
|
132
171
|
co_thing_dir = "checkouts/#{checkout_dir}/#{thing}"
|
133
172
|
combined_dir = "combined/#{thing}"
|
134
173
|
if Dir.exists?(co_thing_dir) then
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
174
|
+
if (thing == "data_bags") then
|
175
|
+
Dir.foreach(co_thing_dir) do |co_dbag_dir|
|
176
|
+
next unless File.directory?(co_thing_dir + '/' + co_dbag_dir)
|
177
|
+
next if co_dbag_dir.start_with?('.')
|
178
|
+
combined_dbag_dir = combined_dir + '/' + co_dbag_dir
|
179
|
+
if !Dir.exists?(combined_dbag_dir) then Dir.mkdir(combined_dbag_dir) end
|
180
|
+
Dir.entries(co_thing_dir + '/' + co_dbag_dir).grep(/\.(rb|json)$/).each do |file|
|
181
|
+
# Under vagrant, we see this directory as /vagrant/checkouts/<checkout>/data_bags/<dbag>/<dbag_entry.json>
|
182
|
+
# Use -f so later checkouts can override earlier ones
|
183
|
+
cmd = "ln -sf /vagrant/#{co_thing_dir + '/' + co_dbag_dir}/#{file} combined/#{thing}/#{co_dbag_dir}/#{file}"
|
184
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
else
|
188
|
+
Dir.entries(co_thing_dir).grep(/\.(rb|json)$/).each do |file|
|
189
|
+
# Under vagrant, we see this directory as /vagrant/checkouts/foo/role/bar.rb
|
190
|
+
# Use -f so later checkouts can override earlier ones
|
191
|
+
cmd = "ln -sf /vagrant/#{co_thing_dir}/#{file} combined/#{thing}/#{file}"
|
192
|
+
unless system cmd then raise "Could not '#{cmd}'" end
|
193
|
+
end
|
140
194
|
end
|
141
195
|
end
|
142
196
|
end
|
metadata
CHANGED
@@ -1,50 +1,69 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-cookbook-fetcher
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Clinton Wolfe
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2012-09-21 00:00:00 Z
|
13
19
|
dependencies: []
|
14
|
-
|
15
|
-
|
16
|
-
roles directory, with symlinks.
|
20
|
+
|
21
|
+
description: Whenever you run start, up, or provision, this plugin will dynamically fetch a list of checkouts from a URL; checkout each one; then create a combined roles directory, with symlinks.
|
17
22
|
email: clinton@NOSPAM.omniti.com
|
18
23
|
executables: []
|
24
|
+
|
19
25
|
extensions: []
|
26
|
+
|
20
27
|
extra_rdoc_files: []
|
21
|
-
|
28
|
+
|
29
|
+
files:
|
22
30
|
- LICENSE
|
23
31
|
- README.md
|
24
32
|
- lib/vagrant_init.rb
|
25
33
|
- lib/vagrant_cookbook_fetcher.rb
|
26
34
|
homepage: https://github.com/clintoncwolfe/vagrant-cookbook-fetcher
|
27
35
|
licenses: []
|
36
|
+
|
28
37
|
post_install_message:
|
29
38
|
rdoc_options: []
|
30
|
-
|
39
|
+
|
40
|
+
require_paths:
|
31
41
|
- lib
|
32
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
43
|
none: false
|
34
|
-
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
|
38
|
-
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
hash: 3
|
48
|
+
segments:
|
49
|
+
- 0
|
50
|
+
version: "0"
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
52
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
44
60
|
requirements: []
|
61
|
+
|
45
62
|
rubyforge_project:
|
46
|
-
rubygems_version: 1.
|
63
|
+
rubygems_version: 1.7.2
|
47
64
|
signing_key:
|
48
65
|
specification_version: 3
|
49
66
|
summary: Fetch your Chef cookbooks whenever you provision
|
50
67
|
test_files: []
|
68
|
+
|
69
|
+
has_rdoc:
|