externals 1.0.2
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/MIT-LICENSE +20 -0
- data/README.markdown +55 -0
- data/Rakefile +48 -0
- data/bin/externals +7 -0
- data/externals.gemspec +29 -0
- data/lib/externals.rb +3 -0
- data/lib/externals/app.rb +42 -0
- data/lib/externals/repository.rb +119 -0
- data/lib/externals/yaml_config.rb +32 -0
- data/spec/externals/app_spec.rb +59 -0
- data/spec/externals/repository_spec.rb +141 -0
- data/spec/externals/yaml_config_spec.rb +44 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +11 -0
- metadata +68 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Winton Welsh
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
Externals
|
2
|
+
=========
|
3
|
+
|
4
|
+
Quickly freeze and unfreeze external git dependencies.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
<pre>
|
10
|
+
sudo gem install winton-externals
|
11
|
+
</pre>
|
12
|
+
|
13
|
+
Configuration
|
14
|
+
-------------
|
15
|
+
|
16
|
+
Create *config/externals.yml*:
|
17
|
+
|
18
|
+
<pre>
|
19
|
+
acts_as_archive:
|
20
|
+
repo: git://github.com/winton/acts_as_archive.git
|
21
|
+
path: vendor/plugins
|
22
|
+
rails:
|
23
|
+
repo: git://github.com/rails/rails.git
|
24
|
+
path: vendor
|
25
|
+
</pre>
|
26
|
+
|
27
|
+
Freeze or unfreeze
|
28
|
+
------------------
|
29
|
+
|
30
|
+
You can run either of these for the first time, depending on what you want:
|
31
|
+
|
32
|
+
<pre>
|
33
|
+
externals freeze
|
34
|
+
externals unfreeze
|
35
|
+
</pre>
|
36
|
+
|
37
|
+
If you only want to freeze one of the items in config/externals.yml
|
38
|
+
|
39
|
+
<pre>
|
40
|
+
externals freeze acts_as_archive
|
41
|
+
externals unfreeze acts_as_archive
|
42
|
+
</pre>
|
43
|
+
|
44
|
+
The usual flow is to unfreeze, commit to the external, freeze, and commit to the parent project.
|
45
|
+
|
46
|
+
Your .git directories will be zipped and stored in /tmp when frozen, and moved back to the external when unfrozen.
|
47
|
+
|
48
|
+
Are my externals frozen?
|
49
|
+
------------------------
|
50
|
+
|
51
|
+
When you want to know the status of your externals:
|
52
|
+
|
53
|
+
<pre>
|
54
|
+
externals status
|
55
|
+
</pre>
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'spec/rake/spectask'
|
5
|
+
|
6
|
+
GEM_NAME = 'externals'
|
7
|
+
PKG_FILES = FileList['**/*'] - FileList['coverage', 'coverage/**/*', 'pkg', 'pkg/**/*']
|
8
|
+
|
9
|
+
spec = Gem::Specification.new do |s|
|
10
|
+
s.author = "Winton Welsh"
|
11
|
+
s.email = "mail@wintoni.us"
|
12
|
+
s.executables << GEM_NAME
|
13
|
+
s.extra_rdoc_files = [ "README.markdown" ]
|
14
|
+
s.files = PKG_FILES.to_a
|
15
|
+
s.has_rdoc = false
|
16
|
+
s.homepage = "http://github.com/winton/#{GEM_NAME}"
|
17
|
+
s.name = GEM_NAME
|
18
|
+
s.platform = Gem::Platform::RUBY
|
19
|
+
s.require_path = "lib"
|
20
|
+
s.summary = "Quickly freeze and unfreeze external git dependencies"
|
21
|
+
s.version = "1.0.2"
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Package gem"
|
25
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
26
|
+
pkg.gem_spec = spec
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Install gem"
|
30
|
+
task :install do
|
31
|
+
Rake::Task['gem'].invoke
|
32
|
+
`sudo gem uninstall #{GEM_NAME} -x`
|
33
|
+
`sudo gem install pkg/#{GEM_NAME}*.gem`
|
34
|
+
`rm -Rf pkg`
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Generate gemspec"
|
38
|
+
task :gemspec do
|
39
|
+
File.open("#{File.dirname(__FILE__)}/#{GEM_NAME}.gemspec", 'w') do |f|
|
40
|
+
f.write(spec.to_ruby)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "Run specs"
|
45
|
+
Spec::Rake::SpecTask.new do |t|
|
46
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
47
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
48
|
+
end
|
data/bin/externals
ADDED
data/externals.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{externals}
|
5
|
+
s.version = "1.0.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Winton Welsh"]
|
9
|
+
s.date = %q{2009-05-28}
|
10
|
+
s.default_executable = %q{externals}
|
11
|
+
s.email = %q{mail@wintoni.us}
|
12
|
+
s.executables = ["externals"]
|
13
|
+
s.extra_rdoc_files = ["README.markdown"]
|
14
|
+
s.files = ["bin", "bin/externals", "externals.gemspec", "lib", "lib/externals", "lib/externals/app.rb", "lib/externals/repository.rb", "lib/externals/yaml_config.rb", "lib/externals.rb", "MIT-LICENSE", "Rakefile", "README.markdown", "spec", "spec/externals", "spec/externals/app_spec.rb", "spec/externals/repository_spec.rb", "spec/externals/yaml_config_spec.rb", "spec/spec.opts", "spec/spec_helper.rb"]
|
15
|
+
s.homepage = %q{http://github.com/winton/externals}
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubygems_version = %q{1.3.1}
|
18
|
+
s.summary = %q{Quickly freeze and unfreeze external git dependencies}
|
19
|
+
|
20
|
+
if s.respond_to? :specification_version then
|
21
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
22
|
+
s.specification_version = 2
|
23
|
+
|
24
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
25
|
+
else
|
26
|
+
end
|
27
|
+
else
|
28
|
+
end
|
29
|
+
end
|
data/lib/externals.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Externals
|
2
|
+
class App
|
3
|
+
|
4
|
+
def initialize(base_dir)
|
5
|
+
@base_dir = base_dir
|
6
|
+
end
|
7
|
+
|
8
|
+
def config
|
9
|
+
return @config if @config
|
10
|
+
config_path = ['config/externals.yml', '.externals.yml'].detect do |file|
|
11
|
+
File.exists? File.expand_path(@base_dir + '/' + file)
|
12
|
+
end
|
13
|
+
@config = YamlConfig.new(@base_dir, config_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def freeze(filter = nil)
|
17
|
+
config.each_repo(filter) { |r| r.freeze }
|
18
|
+
end
|
19
|
+
|
20
|
+
def run(action, filter_str = nil)
|
21
|
+
available_actions = %w(st status fr freeze un unfreeze)
|
22
|
+
if available_actions.include?(action)
|
23
|
+
filter = Regexp.new(filter_str) if filter_str
|
24
|
+
send(action, filter)
|
25
|
+
else
|
26
|
+
puts "Usage: externals (#{available_actions.join(':')}) optional_regex_string"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def status(filter = nil)
|
31
|
+
config.each_repo(filter) { |r| r.status }
|
32
|
+
end
|
33
|
+
|
34
|
+
def unfreeze(filter = nil)
|
35
|
+
config.each_repo(filter) { |r| r.unfreeze }
|
36
|
+
end
|
37
|
+
|
38
|
+
alias_method :fr, :freeze
|
39
|
+
alias_method :st, :status
|
40
|
+
alias_method :un, :unfreeze
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Externals
|
4
|
+
class Repository
|
5
|
+
|
6
|
+
attr_reader :name
|
7
|
+
|
8
|
+
def initialize(base_dir, name, repo_url, rel_path)
|
9
|
+
@base_dir = base_dir
|
10
|
+
@name = name
|
11
|
+
@repo_url = repo_url
|
12
|
+
@rel_path = rel_path
|
13
|
+
end
|
14
|
+
|
15
|
+
def exists?
|
16
|
+
File.exist?(repo_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def freeze
|
20
|
+
install unless exists?
|
21
|
+
if is_not_a_git_repo?
|
22
|
+
puts "already frozen: #{@name}"
|
23
|
+
elsif is_a_git_repo?
|
24
|
+
overwrite = true
|
25
|
+
# Conditionally destroy compressed repo
|
26
|
+
if is_compressed?
|
27
|
+
puts "You already have a frozen git snapshot. Overwrite?"
|
28
|
+
overwrite = STDIN.gets.downcase[0..0] == 'y'
|
29
|
+
end
|
30
|
+
Dir.chdir(repo_path) do
|
31
|
+
if overwrite
|
32
|
+
# Make temp directory
|
33
|
+
FileUtils.mkdir_p(temp_path)
|
34
|
+
# Compress .git folder to temp
|
35
|
+
`tar czf #{temp_path}/#{@name}.git.tgz .git` unless $TESTING
|
36
|
+
end
|
37
|
+
# Remove repository's .git folder
|
38
|
+
FileUtils.rm_r('.git')
|
39
|
+
end
|
40
|
+
puts "frozen: #{@name}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def install
|
45
|
+
# Create directory that we will clone into
|
46
|
+
unless File.exist?(checkout_path)
|
47
|
+
FileUtils.mkdir_p(checkout_path)
|
48
|
+
end
|
49
|
+
Dir.chdir(checkout_path) do
|
50
|
+
# Remove repository if exists
|
51
|
+
FileUtils.rm_rf(@name)
|
52
|
+
# Clone repository
|
53
|
+
`git clone #{@repo_url} #{@name}` unless $TESTING
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def is_a_git_repo?
|
58
|
+
File.exist?("#{repo_path}/.git")
|
59
|
+
end
|
60
|
+
|
61
|
+
def is_not_a_git_repo?
|
62
|
+
!is_a_git_repo?
|
63
|
+
end
|
64
|
+
|
65
|
+
def is_compressed?
|
66
|
+
File.exists?("#{temp_path}/#{@name}.git.tgz")
|
67
|
+
end
|
68
|
+
|
69
|
+
def is_not_compressed?
|
70
|
+
!is_compressed?
|
71
|
+
end
|
72
|
+
|
73
|
+
def status
|
74
|
+
if exists?
|
75
|
+
puts "#{is_a_git_repo? ? "not frozen" : "frozen and #{is_compressed? ? "has" : "does not have"} a snapshot"}: #{@name}"
|
76
|
+
else
|
77
|
+
puts "does not exist and #{is_compressed? ? "has" : "does not have"} a snapshot: #{@name}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def unfreeze
|
82
|
+
if is_a_git_repo?
|
83
|
+
puts "already unfrozen: #{@name}"
|
84
|
+
elsif !exists?
|
85
|
+
install
|
86
|
+
puts "#{@name} unfrozen"
|
87
|
+
elsif is_not_a_git_repo?
|
88
|
+
if is_compressed?
|
89
|
+
Dir.chdir(temp_path) do
|
90
|
+
# Decompress git snapshot
|
91
|
+
`tar xzf #{@name}.git.tgz` unless $TESTING
|
92
|
+
# Move back to repo
|
93
|
+
FileUtils.mv(".git", repo_path)
|
94
|
+
# Remove snapshot
|
95
|
+
FileUtils.rm_f("#{@name}.git.tgz")
|
96
|
+
end
|
97
|
+
else
|
98
|
+
# Clone fresh repo if no snapshot found
|
99
|
+
install
|
100
|
+
end
|
101
|
+
puts "unfrozen: #{@name}"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def checkout_path
|
108
|
+
File.expand_path(File.join(@base_dir, @rel_path))
|
109
|
+
end
|
110
|
+
|
111
|
+
def repo_path
|
112
|
+
File.expand_path(checkout_path + '/' + @name)
|
113
|
+
end
|
114
|
+
|
115
|
+
def temp_path
|
116
|
+
@base_dir + '/tmp'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Externals
|
4
|
+
class YamlConfig
|
5
|
+
|
6
|
+
attr_reader :repositories
|
7
|
+
|
8
|
+
def initialize(base_dir, config_path)
|
9
|
+
@base_dir = base_dir
|
10
|
+
if config_path && File.exists?(config_path)
|
11
|
+
config = YAML.load(File.read(config_path))
|
12
|
+
@repositories = config.map do |name, attributes|
|
13
|
+
Repository.new(@base_dir, name, attributes["repo"], attributes["path"])
|
14
|
+
end
|
15
|
+
@repositories = @repositories.sort do |a, b|
|
16
|
+
a.name <=> b.name
|
17
|
+
end
|
18
|
+
else
|
19
|
+
$stderr.puts "config/externals.yml is missing"
|
20
|
+
@repositories = []
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def each_repo(filter = nil)
|
25
|
+
repositories.each do |r|
|
26
|
+
if block_given? and (!filter or filter.match(r.name))
|
27
|
+
yield(r)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
module Externals
|
4
|
+
describe Externals::App do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@app = App.new("some_fake_dir")
|
8
|
+
@mock_config = stub("config", :null_object => true)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "loading the config file" do
|
12
|
+
|
13
|
+
before(:each) do
|
14
|
+
File.stub!(:exists?).and_return(true)
|
15
|
+
YamlConfig.stub!(:new).and_return(@mock_config)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should look for config/externals.yml" do
|
19
|
+
File.should_receive(:exists?).with(/some_fake_dir\/config\/externals\.yml/)
|
20
|
+
@app.config
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should look for .externals.yml if externals.yml does not exist" do
|
24
|
+
File.should_receive(:exists?).with(/some_fake_dir\/config\/externals\.yml/).and_return(false)
|
25
|
+
File.should_receive(:exists?).with(/some_fake_dir\/\.externals\.yml/).and_return(true)
|
26
|
+
@app.config
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should create a config from the config file" do
|
30
|
+
YamlConfig.should_receive(:new).with('some_fake_dir', "config/externals.yml").and_return(@mock_config)
|
31
|
+
@app.config
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "app actions" do
|
36
|
+
|
37
|
+
before(:each) do
|
38
|
+
@app.stub!(:config).and_return(@mock_config)
|
39
|
+
@mock_repo = mock("repo")
|
40
|
+
@mock_config.stub!(:each_repo).and_yield(@mock_repo)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should give the status of each of the repositories" do
|
44
|
+
@mock_repo.should_receive(:status)
|
45
|
+
@app.status
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should freeze each of the repositories" do
|
49
|
+
@mock_repo.should_receive(:freeze)
|
50
|
+
@app.freeze
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should unfreeze each of the repositories" do
|
54
|
+
@mock_repo.should_receive(:unfreeze)
|
55
|
+
@app.unfreeze
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
module Externals
|
4
|
+
describe Externals::Repository do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@stdout = $stdout
|
8
|
+
$stdout = StringIO.new
|
9
|
+
@repo = Repository.new("/", "tmp", "git://", "/")
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:each) do
|
13
|
+
$stdout = @stdout
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "freeze" do
|
17
|
+
|
18
|
+
before(:each) do
|
19
|
+
@repo.stub!(:exists?).and_return(false)
|
20
|
+
@repo.stub!(:install)
|
21
|
+
@repo.stub!(:is_not_a_git_repo?)
|
22
|
+
@repo.stub!(:is_a_git_repo?).and_return(true)
|
23
|
+
@repo.stub!(:is_compressed?).and_return(true)
|
24
|
+
STDIN.stub!(:gets).and_return('y')
|
25
|
+
FileUtils.stub!(:mkdir_p)
|
26
|
+
FileUtils.stub!(:rm_r)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should install the repository if it does not exist" do
|
30
|
+
@repo.should_receive(:install)
|
31
|
+
@repo.freeze
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should display a message if the repository is already frozen" do
|
35
|
+
@repo.stub!(:is_not_a_git_repo?).and_return(true)
|
36
|
+
@repo.freeze
|
37
|
+
$stdout.string.include?("already frozen").should == true
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should ask if the compressed file should be overwritten if exists" do
|
41
|
+
@repo.stub!(:is_not_a_git_repo?).and_return(false)
|
42
|
+
@repo.freeze
|
43
|
+
$stdout.string.include?("Overwrite?").should == true
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should remove the repository's .git file" do
|
47
|
+
FileUtils.should_receive(:rm_r).with('.git')
|
48
|
+
@repo.freeze
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "install" do
|
53
|
+
|
54
|
+
before(:each) do
|
55
|
+
File.stub!(:exist?)
|
56
|
+
FileUtils.stub!(:mkdir_p)
|
57
|
+
FileUtils.stub!(:rm_f)
|
58
|
+
end
|
59
|
+
|
60
|
+
after(:each) do
|
61
|
+
@repo.install
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should create the checkout path if does not exist" do
|
65
|
+
File.should_receive(:exist?).and_return(false)
|
66
|
+
FileUtils.should_receive(:mkdir_p)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should remove repository if exists" do
|
70
|
+
FileUtils.should_receive(:rm_rf)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "unfreeze" do
|
75
|
+
|
76
|
+
before(:each) do
|
77
|
+
@repo.stub!(:is_a_git_repo?)
|
78
|
+
@repo.stub!(:exists?)
|
79
|
+
@repo.stub!(:install)
|
80
|
+
@repo.stub!(:is_not_a_git_repo?)
|
81
|
+
@repo.stub!(:is_compressed?)
|
82
|
+
FileUtils.stub!(:mv)
|
83
|
+
FileUtils.stub!(:rm_f)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should display a message if the repository is already unfrozen" do
|
87
|
+
@repo.should_receive(:is_a_git_repo?).and_return(true)
|
88
|
+
@repo.unfreeze
|
89
|
+
$stdout.string.include?("already unfrozen").should == true
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should install the repository if it does not exist" do
|
93
|
+
@repo.should_receive(:exists?).and_return(false)
|
94
|
+
@repo.should_receive(:install)
|
95
|
+
@repo.unfreeze
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should display a message after the install" do
|
99
|
+
@repo.should_receive(:is_a_git_repo?).and_return(false)
|
100
|
+
@repo.should_receive(:exists?).and_return(false)
|
101
|
+
@repo.unfreeze
|
102
|
+
$stdout.string.include?("unfrozen").should == true
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should move the uncompressed .git directory back to the repo if compressed file exists" do
|
106
|
+
@repo.should_receive(:is_a_git_repo?).and_return(false)
|
107
|
+
@repo.should_receive(:exists?).and_return(true)
|
108
|
+
@repo.should_receive(:is_not_a_git_repo?).and_return(true)
|
109
|
+
@repo.should_receive(:is_compressed?).and_return(true)
|
110
|
+
FileUtils.should_receive(:mv)
|
111
|
+
@repo.unfreeze
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should remove the snapshot if compressed file exists" do
|
115
|
+
@repo.should_receive(:is_a_git_repo?).and_return(false)
|
116
|
+
@repo.should_receive(:exists?).and_return(true)
|
117
|
+
@repo.should_receive(:is_not_a_git_repo?).and_return(true)
|
118
|
+
@repo.should_receive(:is_compressed?).and_return(true)
|
119
|
+
FileUtils.should_receive(:rm_f)
|
120
|
+
@repo.unfreeze
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should install the repository if no snapshot found" do
|
124
|
+
@repo.should_receive(:is_a_git_repo?).and_return(false)
|
125
|
+
@repo.should_receive(:exists?).and_return(true)
|
126
|
+
@repo.should_receive(:is_not_a_git_repo?).and_return(true)
|
127
|
+
@repo.should_receive(:is_compressed?).and_return(false)
|
128
|
+
@repo.should_receive(:install)
|
129
|
+
@repo.unfreeze
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should display a message when finished" do
|
133
|
+
@repo.should_receive(:is_a_git_repo?).and_return(false)
|
134
|
+
@repo.should_receive(:exists?).and_return(true)
|
135
|
+
@repo.should_receive(:is_not_a_git_repo?).and_return(true)
|
136
|
+
@repo.unfreeze
|
137
|
+
$stdout.string.include?("unfrozen").should == true
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
module Externals
|
4
|
+
describe Externals::YamlConfig do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@rspec = mock("rspec")
|
8
|
+
@foo = mock("foo")
|
9
|
+
@rspec.stub!(:name).and_return('rspec')
|
10
|
+
@foo.stub!(:name).and_return('foo')
|
11
|
+
File.stub!(:read).and_return(
|
12
|
+
"rspec:\n repo: git://rspec\n path: vendor/plugins\n" +
|
13
|
+
"foo:\n repo: git://at/foo\n path: path/to/foo\n"
|
14
|
+
)
|
15
|
+
Repository.stub!(:new).and_return(@rspec)
|
16
|
+
Repository.stub!(:new).and_return(@foo)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should create repositories" do
|
20
|
+
File.stub!(:exists?).and_return(true)
|
21
|
+
Repository.should_receive(:new).with(
|
22
|
+
"base_dir", "rspec", "git://rspec", "vendor/plugins"
|
23
|
+
)
|
24
|
+
Repository.should_receive(:new).with(
|
25
|
+
"base_dir", "foo", "git://at/foo", "path/to/foo"
|
26
|
+
)
|
27
|
+
config = YamlConfig.new("base_dir", "config/externals.yml")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should allow repository iteration" do
|
31
|
+
File.stub!(:exists?).and_return(true)
|
32
|
+
config = YamlConfig.new("base_dir", "config/externals.yml")
|
33
|
+
config.each_repo { |r| [ @rspec, @foo ].include?(r).should == true }
|
34
|
+
config.each_repo('r') { |r| r.should == @rspec }
|
35
|
+
config.each_repo('f') { |r| r.should == @foo }
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should error if config doesn't exist" do
|
39
|
+
File.stub!(:exists?).and_return(false)
|
40
|
+
$stderr.should_receive(:puts)
|
41
|
+
config = YamlConfig.new('base_dir', 'config/externals.yml')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: externals
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Winton Welsh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-06 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: mail@wintoni.us
|
18
|
+
executables:
|
19
|
+
- externals
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.markdown
|
24
|
+
files:
|
25
|
+
- bin/externals
|
26
|
+
- externals.gemspec
|
27
|
+
- lib/externals/app.rb
|
28
|
+
- lib/externals/repository.rb
|
29
|
+
- lib/externals/yaml_config.rb
|
30
|
+
- lib/externals.rb
|
31
|
+
- MIT-LICENSE
|
32
|
+
- Rakefile
|
33
|
+
- README.markdown
|
34
|
+
- spec/externals/app_spec.rb
|
35
|
+
- spec/externals/repository_spec.rb
|
36
|
+
- spec/externals/yaml_config_spec.rb
|
37
|
+
- spec/spec.opts
|
38
|
+
- spec/spec_helper.rb
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/winton/externals
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.3.5
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Quickly freeze and unfreeze external git dependencies
|
67
|
+
test_files: []
|
68
|
+
|