vendorificator 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile +5 -1
- data/README.md +33 -0
- data/Rakefile +7 -0
- data/cucumber.yml +1 -1
- data/features/download.feature +14 -0
- data/features/environment.feature +27 -2
- data/features/fixtures/rubygems/.gitignore +1 -0
- data/features/fixtures/rubygems/Marshal.4.8 +0 -0
- data/features/fixtures/rubygems/Marshal.4.8.Z +2 -0
- data/features/fixtures/rubygems/Rakefile +46 -0
- data/features/fixtures/rubygems/gems/first-0.gem +0 -0
- data/features/fixtures/rubygems/gems/hello-0.0.1.gem +0 -0
- data/features/fixtures/rubygems/gems/second-0.gem +0 -0
- data/features/fixtures/rubygems/latest_specs.4.8 +0 -0
- data/features/fixtures/rubygems/latest_specs.4.8.gz +0 -0
- data/features/fixtures/rubygems/prerelease_specs.4.8 +0 -0
- data/features/fixtures/rubygems/prerelease_specs.4.8.gz +0 -0
- data/features/fixtures/rubygems/quick/Marshal.4.8/first-0.gemspec.rz +0 -0
- data/features/fixtures/rubygems/quick/Marshal.4.8/hello-0.0.1.gemspec.rz +3 -0
- data/features/fixtures/rubygems/quick/Marshal.4.8/second-0.gemspec.rz +0 -0
- data/features/fixtures/rubygems/specs.4.8 +0 -0
- data/features/fixtures/rubygems/specs.4.8.gz +0 -0
- data/features/fixtures/rubygems/src/README.md +4 -0
- data/features/fixtures/rubygems/src/first.gemspec +16 -0
- data/features/fixtures/rubygems/src/second.gemspec +14 -0
- data/features/fixtures/vcr/vendorificator.yml +551 -56
- data/features/git.feature +5 -2
- data/features/step_definitions/aruba_ext.rb +1 -0
- data/features/step_definitions/basic.rb +7 -0
- data/features/step_definitions/git.rb +14 -1
- data/features/step_definitions/vendorificator.rb +6 -2
- data/features/support/aruba_ext.rb +8 -0
- data/features/support/env.rb +3 -0
- data/features/support/minigit.rb +6 -0
- data/features/tarball.feature +3 -0
- data/features/tool.feature +67 -0
- data/features/tool_shortcuts.feature +42 -0
- data/features/vendor.feature +4 -1
- data/lib/vendorificator/cli.rb +7 -2
- data/lib/vendorificator/commit.rb +56 -0
- data/lib/vendorificator/config.rb +6 -0
- data/lib/vendorificator/environment.rb +66 -9
- data/lib/vendorificator/vendor/archive.rb +62 -40
- data/lib/vendorificator/vendor/download.rb +20 -10
- data/lib/vendorificator/vendor/git.rb +20 -13
- data/lib/vendorificator/vendor/tool.rb +60 -0
- data/lib/vendorificator/vendor.rb +113 -74
- data/lib/vendorificator/version.rb +1 -1
- data/lib/vendorificator.rb +2 -0
- data/spec/spec_helper.rb +18 -8
- data/spec/vendorificator/config_spec.rb +7 -0
- data/spec/vendorificator/environment_spec.rb +21 -0
- data/spec/vendorificator/vendor/git_spec.rb +23 -0
- data/spec/vendorificator/vendor_spec.rb +68 -0
- data/vendorificator.gemspec +9 -3
- metadata +110 -9
data/features/git.feature
CHANGED
@@ -11,6 +11,7 @@ Scenario: Vendorificating a git repo
|
|
11
11
|
| Version | 10e9ac58c77bc229d8c59a5b4eb7422916453148 |
|
12
12
|
| With file | test/alias.c |
|
13
13
|
And there's a git log message including "at revision 10e9ac58c77bc229d8c59a5b4eb7422916453148"
|
14
|
+
And there's a git commit note including "10e9ac" in "git_revision"
|
14
15
|
|
15
16
|
Scenario: Vendorificating a subdirectory from a git repo
|
16
17
|
Given a repository with following Vendorfile:
|
@@ -38,8 +39,8 @@ Scenario: Vendorificating a certain branch from a git repo
|
|
38
39
|
| Version | ecbfa229ba5f11c05b18bcc4f7c32b8f25d63f8c |
|
39
40
|
| With file | README.md |
|
40
41
|
And there's a git log message including "at revision ecbfa229ba5f11c05b18bcc4f7c32b8f25d63f8c"
|
42
|
+
And there's a git commit note including "ecbfa2" in "git_revision"
|
41
43
|
|
42
|
-
@wip
|
43
44
|
Scenario: Vendorificating a certain tag from a git repo
|
44
45
|
Given a repository with following Vendorfile:
|
45
46
|
"""ruby
|
@@ -51,8 +52,9 @@ Scenario: Vendorificating a certain tag from a git repo
|
|
51
52
|
| Name | testrepo |
|
52
53
|
| Version | email-v0 |
|
53
54
|
| Without file | README.md |
|
54
|
-
| With file | test/alias.c |
|
55
|
+
| With file | test/alias.c |
|
55
56
|
And there's a git log message including "at revision f81247bde4ef7a1c7d280140cc0bcf0b8221a51f"
|
57
|
+
And there's a git commit note including "f81247" in "git_revision"
|
56
58
|
|
57
59
|
Scenario: Vendorificating a certain revision from a git repo
|
58
60
|
Given a repository with following Vendorfile:
|
@@ -67,3 +69,4 @@ Scenario: Vendorificating a certain revision from a git repo
|
|
67
69
|
| With file | alias.c |
|
68
70
|
| Without file | test/alias.c |
|
69
71
|
And there's a git log message including "at revision 6ff1be9c3819c93a2f41e0ddc09f252fcf154f34"
|
72
|
+
And there's a git commit note including "6ff1be" in "git_revision"
|
@@ -30,6 +30,13 @@ Given /^a remote repository$/ do
|
|
30
30
|
run_simple 'git remote add origin ../remote-repository'
|
31
31
|
end
|
32
32
|
|
33
|
+
When /(?:I have following Gemfile|I change Gemfile to|following Gemfile):$/ do |gemfile_contents|
|
34
|
+
write_file('Gemfile', gemfile_contents)
|
35
|
+
run_simple(without_bundler('bundle'))
|
36
|
+
run_simple 'git add Gemfile Gemfile.lock'
|
37
|
+
run_simple 'git commit -m bundle'
|
38
|
+
end
|
39
|
+
|
33
40
|
When /^I change Vendorfile to:$/ do |vendorfile_contents|
|
34
41
|
write_file('Vendorfile', vendorfile_contents)
|
35
42
|
run_simple 'git commit -m "Updated Vendorfile" Vendorfile'
|
@@ -38,10 +38,19 @@ Then /^tag matching (#{PATTERN}) does not exist$/ do |pat|
|
|
38
38
|
deny { git.tags.any? { |t| t =~ pat } }
|
39
39
|
end
|
40
40
|
|
41
|
-
Then
|
41
|
+
Then /^there's a git log message including "(.*?)"$/ do |message|
|
42
42
|
assert { git.log.lines.any? { |ln| ln.include?(message) } }
|
43
43
|
end
|
44
44
|
|
45
|
+
Then /^there's a git commit note including "(.*?)" in "(.*?)"$/ do |value, key|
|
46
|
+
# Not in the assert block, because it raises an exception on failure.
|
47
|
+
contains_note = git.notes({:ref => 'vendor'}, 'list').lines.any? do |line|
|
48
|
+
note = YAML.load git.show(line.split[0])
|
49
|
+
(note[key] || note[key.to_sym]).to_s.include? value
|
50
|
+
end
|
51
|
+
assert { contains_note == true }
|
52
|
+
end
|
53
|
+
|
45
54
|
Then /^branch "(.*?)" exists in the remote repo$/ do |branch_name|
|
46
55
|
assert { remote_git.heads.include?(branch_name) }
|
47
56
|
end
|
@@ -49,3 +58,7 @@ end
|
|
49
58
|
Then /^tag "(.*?)" exists in the remote repo$/ do |tag_name|
|
50
59
|
assert { remote_git.tags.include?(tag_name) }
|
51
60
|
end
|
61
|
+
|
62
|
+
Then /^notes ref "(.*?)" exists in the remote repo$/ do |ref_name|
|
63
|
+
assert { remote_git.note_refs.include?(ref_name) }
|
64
|
+
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
def vendor_path_for(mod, path)
|
2
|
+
File.join('vendor', mod['Path'] || mod['Name'], path)
|
3
|
+
end
|
4
|
+
|
1
5
|
Then /^(?:the )?following has( not)? been conjured:$/ do |not_p, table|
|
2
6
|
exists_p = not_p ? "does not exist" : "exists"
|
3
7
|
|
@@ -14,12 +18,12 @@ Then /^(?:the )?following has( not)? been conjured:$/ do |not_p, table|
|
|
14
18
|
|
15
19
|
if mod['With file']
|
16
20
|
check_file_presence(mod['With file'].lines.
|
17
|
-
map { |ln|
|
21
|
+
map { |ln| vendor_path_for(mod, ln.strip) }, !not_p)
|
18
22
|
end
|
19
23
|
|
20
24
|
if mod['Without file']
|
21
25
|
check_file_presence(mod['Without file'].lines.
|
22
|
-
map { |ln|
|
26
|
+
map { |ln| vendor_path_for(mod, ln.strip) }, !!not_p)
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
1
3
|
module Vendorificator
|
2
4
|
module TestSupport
|
3
5
|
module ArubaExt
|
@@ -16,6 +18,12 @@ module Vendorificator
|
|
16
18
|
def last_output
|
17
19
|
last_stdout + last_stderr
|
18
20
|
end
|
21
|
+
|
22
|
+
def without_bundler(cmd)
|
23
|
+
cmd = %w[ RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE
|
24
|
+
].map { |v| "unset #{v} ; " }.join << cmd
|
25
|
+
"sh -c #{Shellwords.escape(cmd)}"
|
26
|
+
end
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
data/features/support/env.rb
CHANGED
@@ -5,6 +5,9 @@ require 'tmpdir'
|
|
5
5
|
require 'aruba/cucumber'
|
6
6
|
require 'wrong'
|
7
7
|
|
8
|
+
ENV['GIT_AUTHOR_NAME'] = ENV['GIT_COMMITTER_NAME'] = 'Vendorificator Cucumber'
|
9
|
+
ENV['GIT_AUTHOR_EMAIL'] = ENV['GIT_COMMITTER_EMAIL'] = 'nonexistent@example.com'
|
10
|
+
|
8
11
|
World(Wrong)
|
9
12
|
|
10
13
|
ENV['FIXTURES_DIR'] = Pathname.new(__FILE__).
|
data/features/support/minigit.rb
CHANGED
data/features/tarball.feature
CHANGED
@@ -36,6 +36,9 @@ Scenario: Version & checksum
|
|
36
36
|
| Name | testrepo |
|
37
37
|
| Version | 0.1 |
|
38
38
|
| With file | test/alias.c |
|
39
|
+
And there's a git commit note including "ea207a" in "archive_checksum"
|
40
|
+
And there's a git commit note including "20480" in "archive_filesize"
|
41
|
+
And there's a git commit note including "test-assets.3ofcoins" in "archive_url"
|
39
42
|
|
40
43
|
Scenario: Wrong checksum
|
41
44
|
Given a repository with following Vendorfile:
|
@@ -0,0 +1,67 @@
|
|
1
|
+
Feature: use a tool to download stuff
|
2
|
+
|
3
|
+
Background:
|
4
|
+
Given a repository with following Vendorfile:
|
5
|
+
"""ruby
|
6
|
+
# Delete Bundler's variables
|
7
|
+
%w[RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE].each do |var|
|
8
|
+
ENV.delete(var)
|
9
|
+
end
|
10
|
+
|
11
|
+
tool 'bundler',
|
12
|
+
:path => 'cache', # Hardcoded, meh
|
13
|
+
:specs => [ 'Gemfile', 'Gemfile.lock' ],
|
14
|
+
:command => 'bundle package --all'
|
15
|
+
"""
|
16
|
+
|
17
|
+
Scenario: Use Gem bundler to download rubygems, and Vendorificator to vendor them
|
18
|
+
Given I have following Gemfile:
|
19
|
+
"""ruby
|
20
|
+
source "file://#{ENV['FIXTURES_DIR']}/rubygems"
|
21
|
+
gem "hello"
|
22
|
+
"""
|
23
|
+
When I successfully run `vendor sync`
|
24
|
+
Then following has been conjured:
|
25
|
+
| Name | bundler |
|
26
|
+
| Path | cache |
|
27
|
+
| With file | hello-0.0.1.gem |
|
28
|
+
| Without file | first-0.gem |
|
29
|
+
|
30
|
+
Scenario: Bundler correctly downloads and caches dependencies
|
31
|
+
Given I have following Gemfile:
|
32
|
+
"""ruby
|
33
|
+
source "file://#{ENV['FIXTURES_DIR']}/rubygems"
|
34
|
+
gem "first"
|
35
|
+
"""
|
36
|
+
When I successfully run `vendor sync`
|
37
|
+
Then following has been conjured:
|
38
|
+
| Name | bundler |
|
39
|
+
| Path | cache |
|
40
|
+
| Without file | hello-0.0.1.gem |
|
41
|
+
| With file | first-0.gem |
|
42
|
+
| With file | second-0.gem |
|
43
|
+
|
44
|
+
Scenario: directory contents are completely replaced on re-vendoring
|
45
|
+
Given I have following Gemfile:
|
46
|
+
"""ruby
|
47
|
+
source "file://#{ENV['FIXTURES_DIR']}/rubygems"
|
48
|
+
gem "hello"
|
49
|
+
"""
|
50
|
+
When I successfully run `vendor sync`
|
51
|
+
Then following has been conjured:
|
52
|
+
| Name | bundler |
|
53
|
+
| Path | cache |
|
54
|
+
| With file | hello-0.0.1.gem |
|
55
|
+
| Without file | first-0.gem |
|
56
|
+
When I change Gemfile to:
|
57
|
+
"""ruby
|
58
|
+
source "file://#{ENV['FIXTURES_DIR']}/rubygems"
|
59
|
+
gem "first"
|
60
|
+
"""
|
61
|
+
And I successfully run `vendor sync`
|
62
|
+
Then following has been conjured:
|
63
|
+
| Name | bundler |
|
64
|
+
| Path | cache |
|
65
|
+
| Without file | hello-0.0.1.gem |
|
66
|
+
| With file | first-0.gem |
|
67
|
+
| With file | second-0.gem |
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Feature: `rubygems_bundler` and `chef_berkshelf` shortcuts for tools
|
2
|
+
|
3
|
+
Scenario: rubygems_bundler
|
4
|
+
Given a repository with following Vendorfile:
|
5
|
+
"""ruby
|
6
|
+
# Delete Bundler's variables
|
7
|
+
%w[RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE].each do |var|
|
8
|
+
ENV.delete(var)
|
9
|
+
end
|
10
|
+
rubygems_bundler
|
11
|
+
"""
|
12
|
+
And following Gemfile:
|
13
|
+
"""ruby
|
14
|
+
source "file://#{ENV['FIXTURES_DIR']}/rubygems"
|
15
|
+
gem "hello"
|
16
|
+
"""
|
17
|
+
When I successfully run `vendor sync`
|
18
|
+
Then following has been conjured:
|
19
|
+
| Name | rubygems |
|
20
|
+
| Path | cache |
|
21
|
+
| With file | hello-0.0.1.gem |
|
22
|
+
| Without file | first-0.gem |
|
23
|
+
|
24
|
+
@berkshelf
|
25
|
+
Scenario: chef_berkshelf
|
26
|
+
Given a repository with following Vendorfile:
|
27
|
+
"""ruby
|
28
|
+
chef_berkshelf
|
29
|
+
"""
|
30
|
+
And a file named "Berksfile" with:
|
31
|
+
"""ruby
|
32
|
+
site :opscode
|
33
|
+
cookbook 'build-essential'
|
34
|
+
"""
|
35
|
+
And I successfully run `berks install`
|
36
|
+
And I successfully run `git add Berksfile Berksfile.lock`
|
37
|
+
And I successfully run `git commit -m Berksfile`
|
38
|
+
When I successfully run `vendor sync`
|
39
|
+
Then following has been conjured:
|
40
|
+
| Name | cookbooks |
|
41
|
+
| With file | build-essential/metadata.rb |
|
42
|
+
|
data/features/vendor.feature
CHANGED
@@ -3,7 +3,8 @@ Feature: bare 'vendor' clause
|
|
3
3
|
Scenario:
|
4
4
|
Given a repository with following Vendorfile:
|
5
5
|
"""ruby
|
6
|
-
|
6
|
+
annotate 'foo', 'bar'
|
7
|
+
vendor 'generated', :version => '0.23', :annotate => 'by Przemo' do |v|
|
7
8
|
File.open('README', 'w') { |f| f.puts "Hello, World!" }
|
8
9
|
File.open('VERSION', 'w') { |f| f.puts v.version }
|
9
10
|
end
|
@@ -14,3 +15,5 @@ Scenario:
|
|
14
15
|
| Version | 0.23 |
|
15
16
|
| With file | README |
|
16
17
|
And the file "vendor/generated/VERSION" should contain "0.23"
|
18
|
+
And there's a git commit note including "bar" in "foo"
|
19
|
+
And there's a git commit note including "by Przemo" in "module_annotations"
|
data/lib/vendorificator/cli.rb
CHANGED
@@ -85,10 +85,15 @@ module Vendorificator
|
|
85
85
|
end
|
86
86
|
|
87
87
|
say_status( mod.status.to_s.gsub('_', ' '), status_line,
|
88
|
-
( mod.status
|
88
|
+
( mod.status == :up_to_date ? :green : :yellow ) )
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
desc 'info MODULE', "Show module information"
|
93
|
+
def info(mod_name)
|
94
|
+
environment.info mod_name, options
|
95
|
+
end
|
96
|
+
|
92
97
|
desc :pull, "Pull upstream branches from a remote repository"
|
93
98
|
method_option :remote, :aliases => ['-r'], :default => nil
|
94
99
|
method_option :dry_run, :aliases => ['-n'], :default => false, :type => :boolean
|
@@ -111,7 +116,7 @@ module Vendorificator
|
|
111
116
|
long_desc <<EOF
|
112
117
|
Run a git command for specified modules. Within GIT_ARGS arguments,
|
113
118
|
you can use @MERGED@ and @PATH@ tags, which will be substituted with
|
114
|
-
|
119
|
+
module's most recently merged revision and full path of its work
|
115
120
|
directory.
|
116
121
|
|
117
122
|
The 'diff' and 'log' commands are simple aliases for 'git' command.
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Vendorificator
|
4
|
+
class Commit
|
5
|
+
attr_reader :git, :rev
|
6
|
+
|
7
|
+
# Public: Initializes the object
|
8
|
+
#
|
9
|
+
# rev - The String containing revision expression for this commit.
|
10
|
+
# git - The MiniGit instance to use.
|
11
|
+
#
|
12
|
+
# Returns Commit object.
|
13
|
+
def initialize(rev, git)
|
14
|
+
@rev = rev
|
15
|
+
@git = git
|
16
|
+
end
|
17
|
+
|
18
|
+
# Public: Finds branches that contain this commit.
|
19
|
+
#
|
20
|
+
# Returns Array of branch names.
|
21
|
+
def branches
|
22
|
+
git.capturing.branch({:contains => true}, rev).split("\n").map do |name|
|
23
|
+
name.tr('*', '').strip
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Public: Checks if such a commit exists in the repository.
|
28
|
+
#
|
29
|
+
# Returns Boolean.
|
30
|
+
def exists?
|
31
|
+
git.capturing.rev_parse rev
|
32
|
+
true
|
33
|
+
rescue MiniGit::GitError
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
# Public: Returns vendorificator git notes for the commit.
|
38
|
+
#
|
39
|
+
# Returns the notes Hash.
|
40
|
+
def notes
|
41
|
+
YAML.load(git.capturing.notes({:ref => 'vendor'}, 'show', rev))
|
42
|
+
end
|
43
|
+
|
44
|
+
# Public: Returns vendorificator git notes for the commit if it exists.
|
45
|
+
#
|
46
|
+
# Returns the notes Hash or an empty one.
|
47
|
+
def notes?
|
48
|
+
if exists?
|
49
|
+
YAML.load(git.capturing.notes({:ref => 'vendor'}, 'show', rev))
|
50
|
+
else
|
51
|
+
{}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -3,6 +3,7 @@ require 'pathname'
|
|
3
3
|
module Vendorificator
|
4
4
|
class Config
|
5
5
|
attr_accessor :environment
|
6
|
+
attr_reader :metadata
|
6
7
|
|
7
8
|
@defaults = {}
|
8
9
|
@modules = {}
|
@@ -34,6 +35,7 @@ module Vendorificator
|
|
34
35
|
|
35
36
|
def initialize(params = {})
|
36
37
|
@configuration = self.class.defaults.merge(params)
|
38
|
+
@metadata = {}
|
37
39
|
end
|
38
40
|
|
39
41
|
def read_file(filename)
|
@@ -66,6 +68,10 @@ module Vendorificator
|
|
66
68
|
self.class.modules
|
67
69
|
end
|
68
70
|
|
71
|
+
def annotate key, value
|
72
|
+
@metadata.merge!({key => value})
|
73
|
+
end
|
74
|
+
|
69
75
|
def method_missing(method_symbol, *args, &block)
|
70
76
|
if modules.keys.include? method_symbol
|
71
77
|
modules[method_symbol].new(environment, args.delete_at(0).to_s, *args, &block)
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
|
3
2
|
require 'minigit'
|
4
|
-
|
3
|
+
require 'awesome_print'
|
5
4
|
require 'vendorificator/config'
|
6
5
|
|
7
6
|
module Vendorificator
|
@@ -9,12 +8,15 @@ module Vendorificator
|
|
9
8
|
attr_reader :config
|
10
9
|
attr_accessor :shell, :vendor_instances
|
11
10
|
|
12
|
-
def initialize(vendorfile=nil)
|
11
|
+
def initialize(vendorfile=nil, &block)
|
13
12
|
@vendor_instances = []
|
14
13
|
|
15
14
|
@config = Vendorificator::Config.new
|
16
15
|
@config.environment = self
|
17
|
-
|
16
|
+
if vendorfile || !block_given?
|
17
|
+
@config.read_file(find_vendorfile(vendorfile).to_s)
|
18
|
+
end
|
19
|
+
@config.instance_eval(&block) if block_given?
|
18
20
|
|
19
21
|
self.each_vendor_instance{ |mod| mod.compute_dependencies! }
|
20
22
|
end
|
@@ -66,6 +68,7 @@ module Vendorificator
|
|
66
68
|
|
67
69
|
git.fetch(remote)
|
68
70
|
git.fetch({:tags => true}, remote)
|
71
|
+
git.fetch(remote, 'refs/notes/vendor:refs/notes/vendor')
|
69
72
|
|
70
73
|
ref_rx = /^refs\/remotes\/#{Regexp.quote(remote)}\//
|
71
74
|
remote_branches = Hash[ git.capturing.show_ref.
|
@@ -97,6 +100,26 @@ module Vendorificator
|
|
97
100
|
end
|
98
101
|
end
|
99
102
|
|
103
|
+
# Public: Displays info about the last merged version of module.
|
104
|
+
#
|
105
|
+
# mod - String with the module name
|
106
|
+
# options - Hash containing options
|
107
|
+
#
|
108
|
+
# Returns nothing.
|
109
|
+
def info(mod_name, options = {})
|
110
|
+
if vendor = find_vendor_instance_by_name(mod_name)
|
111
|
+
shell.say "Module name: #{vendor.name}\n"
|
112
|
+
shell.say "Module category: #{vendor.category}\n"
|
113
|
+
shell.say "Module merged version: #{vendor.merged_version}\n"
|
114
|
+
shell.say "Module merged notes: #{vendor.merged_notes.ai}\n"
|
115
|
+
elsif (commit = Commit.new(mod_name, git)).exists?
|
116
|
+
shell.say "Branches that contain this commit: #{commit.branches.join(', ')}\n"
|
117
|
+
shell.say "Vendorificator notes on this commit: #{commit.notes.ai}\n"
|
118
|
+
else
|
119
|
+
shell.say "Module or ref #{mod_name.inspect} not found."
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
100
123
|
# Public: Push changes on module branches.
|
101
124
|
#
|
102
125
|
# options - The Hash containing options
|
@@ -109,9 +132,11 @@ module Vendorificator
|
|
109
132
|
each_vendor_instance{ |mod| pushable += mod.pushable_refs }
|
110
133
|
|
111
134
|
remotes = options[:remote] ? options[:remote].split(',') : config[:remotes]
|
112
|
-
remotes.each
|
113
|
-
|
114
|
-
|
135
|
+
remotes.each do |remote|
|
136
|
+
git.push remote, pushable
|
137
|
+
git.push remote, :tags => true
|
138
|
+
git.push remote, 'refs/notes/vendor'
|
139
|
+
end
|
115
140
|
end
|
116
141
|
|
117
142
|
# Public: Runs all the vendor modules.
|
@@ -122,11 +147,12 @@ module Vendorificator
|
|
122
147
|
def sync(options = {})
|
123
148
|
ensure_clean!
|
124
149
|
config[:use_upstream_version] = options[:update]
|
150
|
+
metadata = metadata_snapshot
|
125
151
|
|
126
152
|
each_vendor_instance(*options[:modules]) do |mod|
|
127
153
|
say_status :module, mod.name
|
128
154
|
indent do
|
129
|
-
mod.run!
|
155
|
+
mod.run!(:metadata => metadata)
|
130
156
|
end
|
131
157
|
end
|
132
158
|
end
|
@@ -166,8 +192,40 @@ module Vendorificator
|
|
166
192
|
false
|
167
193
|
end
|
168
194
|
|
195
|
+
def metadata_snapshot
|
196
|
+
{
|
197
|
+
:vendorificator_version => ::Vendorificator::VERSION,
|
198
|
+
:current_branch => git.capturing.rev_parse({:abbrev_ref => true}, 'HEAD').strip,
|
199
|
+
:current_sha => git.capturing.rev_parse('HEAD').strip,
|
200
|
+
:git_describe => (git.capturing.describe.strip rescue '')
|
201
|
+
}
|
202
|
+
end
|
203
|
+
|
204
|
+
# Public: returns `config[:root_dir]` relative to Git repository root
|
205
|
+
def relative_root_dir
|
206
|
+
@relative_root_dir ||= config[:root_dir].relative_path_from(
|
207
|
+
Pathname.new(git.git_work_tree))
|
208
|
+
end
|
209
|
+
|
210
|
+
# Public: Returns module with given name
|
211
|
+
def [](name)
|
212
|
+
vendor_instances.find { |v| v.name == name }
|
213
|
+
end
|
214
|
+
|
169
215
|
private
|
170
216
|
|
217
|
+
# Private: Finds a vendor instance by module name.
|
218
|
+
#
|
219
|
+
# mod_name - The String containing the module name.
|
220
|
+
#
|
221
|
+
# Returns Vendor instance.
|
222
|
+
def find_vendor_instance_by_name(mod_name)
|
223
|
+
each_vendor_instance do |mod|
|
224
|
+
return mod if mod.name == mod_name
|
225
|
+
end
|
226
|
+
nil
|
227
|
+
end
|
228
|
+
|
171
229
|
# Private: Finds the vendorfile to use.
|
172
230
|
#
|
173
231
|
# given - the optional String containing vendorfile path.
|
@@ -213,6 +271,5 @@ module Vendorificator
|
|
213
271
|
ensure
|
214
272
|
shell.padding -= 1 if shell
|
215
273
|
end
|
216
|
-
|
217
274
|
end
|
218
275
|
end
|