winton-externals 0.1.5 → 0.1.6

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/README.markdown CHANGED
@@ -19,6 +19,9 @@ Create *config/externals.yml*:
19
19
  pa_stats:
20
20
  repo: git@github.com:br/pa_stats.git
21
21
  path: vendor/gems
22
+ acts_as_archive:
23
+ repo: git@github.com:winton/acts_as_archive.git
24
+ path: vendor/plugins
22
25
  </pre>
23
26
 
24
27
  Freeze or unfreeze
@@ -31,6 +34,13 @@ externals freeze
31
34
  externals unfreeze
32
35
  </pre>
33
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
+
34
44
  The usual flow is to unfreeze, commit to the external, freeze, and commit to the parent project.
35
45
 
36
46
  Your .git directories will be zipped and stored in /tmp when frozen, and moved back to the external when unfrozen.
data/bin/externals CHANGED
@@ -4,4 +4,4 @@ require 'rubygems'
4
4
  require 'externals'
5
5
 
6
6
  app = Externals::App.new(FileUtils.pwd)
7
- app.run(ARGV[0])
7
+ app.run(ARGV[0], ARGV[1])
data/externals.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'externals'
3
- s.version = '0.1.5'
3
+ s.version = '0.1.6'
4
4
  s.date = '2008-03-12'
5
5
 
6
6
  s.summary = "Work on git externals without affecting others"
@@ -25,6 +25,9 @@ Gem::Specification.new do |s|
25
25
  lib/externals/app.rb
26
26
  lib/externals/repository.rb
27
27
  lib/externals/yaml_config.rb
28
+ spec/bin/externals_spec.rb
29
+ spec/lib/app_spec.rb
30
+ spec/lib/yaml_config_spec.rb
28
31
  spec/spec.opts
29
32
  spec/spec_helper.rb
30
33
  ]
data/lib/externals/app.rb CHANGED
@@ -4,24 +4,26 @@ module Externals
4
4
  @base_dir = base_dir
5
5
  end
6
6
 
7
- def status
8
- config.each_repo {|r| r.status }
7
+ def status(filtr = nil)
8
+ config.each_repo(filtr) {|r| r.status }
9
9
  end
10
+ alias_method :st, :status
10
11
 
11
- def freeze
12
- config.each_repo {|r| r.freeze }
12
+ def freeze(filtr = nil)
13
+ config.each_repo(filtr) {|r| r.freeze }
13
14
  end
14
15
 
15
- def unfreeze
16
- config.each_repo {|r| r.unfreeze }
16
+ def unfreeze(filtr = nil)
17
+ config.each_repo(filtr) {|r| r.unfreeze }
17
18
  end
18
19
 
19
- def run(action)
20
+ def run(action, filtr_str = nil)
20
21
  available_actions = %w(status freeze unfreeze)
21
22
  if available_actions.include?(action)
22
- send(action)
23
+ filtr = Regexp.new(filtr_str) if filtr_str
24
+ send(action, filtr)
23
25
  else
24
- puts "Usage: externals (#{available_actions.join(':')})"
26
+ puts "Usage: externals (#{available_actions.join(':')}) optional_regex_string"
25
27
  end
26
28
  end
27
29
 
@@ -9,6 +9,7 @@ module Externals
9
9
  @repo_url = repo_url
10
10
  @rel_path = rel_path
11
11
  end
12
+ attr_reader :name
12
13
 
13
14
  def install
14
15
  # Create directory that we will clone into
@@ -7,8 +7,8 @@ module Externals
7
7
  @config_hash = YAML.load yaml_string
8
8
  end
9
9
 
10
- def each_repo
11
- repositories.each { |r| yield(r) if block_given? }
10
+ def each_repo(filtr = nil)
11
+ repositories.each { |r| yield(r) if block_given? and (!filtr or filtr.match(r.name)) }
12
12
  end
13
13
 
14
14
  private
@@ -0,0 +1,100 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe :externals do
4
+ before(:all) do
5
+ @stdout = $stdout
6
+ $stdout = StringIO.new
7
+ # Test $stdout.string
8
+ end
9
+
10
+ after(:all) do
11
+ $stdout = @stdout
12
+ end
13
+
14
+ describe "help" do
15
+ it "should show a help message with no input" do
16
+ run
17
+ $stdout.string.should match(/Usage: externals/)
18
+ end
19
+ end
20
+
21
+ describe "status" do
22
+ it "should tell the user if the repository exists" do
23
+ end
24
+
25
+ it "should tell the user if the repository is frozen" do
26
+ end
27
+
28
+ it "should tell the user if a snapshot exists" do
29
+ end
30
+ end
31
+
32
+ describe "freeze" do
33
+ describe "on a non-existent repository" do
34
+ it "should clone a new repository" do
35
+ end
36
+ end
37
+
38
+ describe "on a frozen repository" do
39
+ it "should tell the user the repository is already frozen" do
40
+ end
41
+ end
42
+
43
+ describe "on an unfrozen repository" do
44
+ it "should make the temp directory if it does not exist" do
45
+ end
46
+
47
+ it "should compress the repository's .git folder to the temp directory" do
48
+ end
49
+
50
+ it "should remove the repository's .git folder" do
51
+ end
52
+
53
+ describe "when a snapshot exists" do
54
+ it "should ask the user if the user wants to overwrite the snapshot" do
55
+ end
56
+
57
+ it "should not overwrite if the user says no" do
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ describe "unfreeze" do
64
+ describe "on a frozen repository" do
65
+ it "should tell the user the repository is already unfrozen" do
66
+ end
67
+ end
68
+
69
+ describe "on a non-existent repository" do
70
+ it "should clone the repository" do
71
+ end
72
+ end
73
+
74
+ describe "on a frozen repository" do
75
+ describe "that has a snapshot" do
76
+ it "should decompress the snapshot" do
77
+ end
78
+
79
+ it "should move the snapshot back to the repository" do
80
+ end
81
+
82
+ it "should remove the snapshot" do
83
+ end
84
+
85
+ it "should reset the repository" do
86
+ end
87
+ end
88
+
89
+ describe "that does not have a snapshot" do
90
+ it "should clone a new repository" do
91
+ end
92
+ end
93
+ end
94
+ end
95
+
96
+ def run(action=nil)
97
+ app = Externals::App.new(FileUtils.pwd)
98
+ app.run(action)
99
+ end
100
+ end
@@ -0,0 +1,63 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ module Externals
4
+ describe App do
5
+ before(:each) do
6
+ @app = App.new("some_fake_dir")
7
+ @mock_config = stub("config", :null_object => true)
8
+ end
9
+
10
+ describe "loading the config file" do
11
+ before(:each) do
12
+ File.stub!(:file?).and_return(true)
13
+ File.stub!(:read).and_return("yaml config")
14
+ YamlConfig.stub!(:new).and_return(@mock_config)
15
+ end
16
+
17
+ it "should look for config/externals.yml" do
18
+ File.should_receive(:file?).with(/some_fake_dir\/config\/externals\.yml/)
19
+ @app.config
20
+ end
21
+
22
+ it "should look for .externals.yml if externals.yml does not exist" do
23
+ File.should_receive(:file?).with(/some_fake_dir\/config\/externals\.yml/).and_return(false)
24
+ File.should_receive(:file?).with(/some_fake_dir\/\.externals\.yml/).and_return(true)
25
+ @app.config
26
+ end
27
+
28
+ it "should exit with an error when no config file exists" do
29
+ File.stub!(:file?).and_return(false)
30
+ $stderr.should_receive(:puts)
31
+ @app.config
32
+ end
33
+
34
+ it "should create a config from the config file" do
35
+ YamlConfig.should_receive(:new).with('some_fake_dir', "yaml config").and_return(@mock_config)
36
+ @app.config
37
+ end
38
+ end
39
+
40
+ describe "app actions" do
41
+ before(:each) do
42
+ @app.stub!(:config).and_return(@mock_config)
43
+ @mock_repo = mock("repo")
44
+ @mock_config.stub!(:each_repo).and_yield(@mock_repo)
45
+ end
46
+
47
+ it "should give the status of each of the repositories" do
48
+ @mock_repo.should_receive(:status)
49
+ @app.status
50
+ end
51
+
52
+ it "should freeze each of the repositories" do
53
+ @mock_repo.should_receive(:freezify)
54
+ @app.freezify
55
+ end
56
+
57
+ it "should unfreeze each of the repositories" do
58
+ @mock_repo.should_receive(:unfreezify)
59
+ @app.unfreezify
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ module Externals
4
+ describe YamlConfig do
5
+ it "should create repositories from the config" do
6
+ config = YamlConfig.new(
7
+ 'base_dir',
8
+ "rspec:\n repo: git://rspec\n path: vendor/plugins\n" +
9
+ "foo:\n repo: git://at/foo\n path: path/to/foo\n"
10
+ )
11
+ Repository.should_receive(:new).with(
12
+ 'base_dir', "rspec", "git://rspec", "vendor/plugins"
13
+ ).and_return :a_repo
14
+ Repository.should_receive(:new).with(
15
+ 'base_dir', "foo", "git://at/foo", "path/to/foo"
16
+ ).and_return :a_repo
17
+ config.each_repo { |r| r.should == :a_repo }
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winton-externals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winton Welsh
@@ -32,6 +32,9 @@ files:
32
32
  - lib/externals/app.rb
33
33
  - lib/externals/repository.rb
34
34
  - lib/externals/yaml_config.rb
35
+ - spec/bin/externals_spec.rb
36
+ - spec/lib/app_spec.rb
37
+ - spec/lib/yaml_config_spec.rb
35
38
  - spec/spec.opts
36
39
  - spec/spec_helper.rb
37
40
  has_rdoc: false