winton-externals 0.1.1 → 0.1.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/README.markdown CHANGED
@@ -1 +1,36 @@
1
- # Externals
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
+ pa_stats:
20
+ repo: git@github.com:br/pa_stats.git
21
+ path: vendor/gems
22
+ </pre>
23
+
24
+ Freeze or unfreeze
25
+ ------------------
26
+
27
+ You can run either of these for the first time, depending on what you want:
28
+
29
+ <pre>
30
+ externals freeze
31
+ externals unfreeze
32
+ </pre>
33
+
34
+ The usual flow is to unfreeze, commit to the external, freeze, and commit to the parent project.
35
+
36
+ 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,7 +4,7 @@ require 'rubygems'
4
4
  require 'externals'
5
5
 
6
6
  action = ARGV[0]
7
- available_actions = %w(install freeze unfreeze)
7
+ available_actions = %w(status freeze unfreeze)
8
8
  unless available_actions.include?(action)
9
9
  puts "Usage: externals (#{available_actions.join(':')})"
10
10
  exit 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.1'
3
+ s.version = '0.1.2'
4
4
  s.date = '2008-03-11'
5
5
 
6
6
  s.summary = "Work on git externals without affecting others"
data/lib/externals/app.rb CHANGED
@@ -4,8 +4,8 @@ module Externals
4
4
  @base_dir = base_dir
5
5
  end
6
6
 
7
- def install
8
- config.each_repo {|r| r.install }
7
+ def status
8
+ config.each_repo {|r| r.status }
9
9
  end
10
10
 
11
11
  def freezify
@@ -18,8 +18,8 @@ module Externals
18
18
 
19
19
  def run(action)
20
20
  case action
21
- when "install"
22
- install
21
+ when "status"
22
+ status
23
23
  when "freeze"
24
24
  freezify
25
25
  when "unfreeze"
@@ -13,30 +13,66 @@ module Externals
13
13
  def install
14
14
  FileUtils.mkdir_p checkout_path unless File.exist?(checkout_path)
15
15
  `cd #{checkout_path} && rm -Rf #{@name} && git clone #{@repo_url} #{@name}`
16
+ puts "#{@name} unfrozen"
16
17
  true
17
18
  end
18
19
 
19
20
  def freezify
20
- return true if frozen?
21
- Dir.chdir(repo_path) do
22
- `tar czf #{temp_path}/#{@name}.git.tgz .git`
23
- FileUtils.rm_r('.git')
21
+ install unless File.exist?(repo_path)
22
+ if frozen?
23
+ puts "#{@name} is already frozen"
24
+ elsif can_be_frozen?
25
+ Dir.chdir(repo_path) do
26
+ `rm #{temp_path}/#{@name}.git.tgz` if can_be_unfrozen?
27
+ `mkdir -p #{temp_path}`
28
+ `tar czf #{temp_path}/#{@name}.git.tgz .git`
29
+ FileUtils.rm_r('.git')
30
+ end
31
+ puts "#{@name} frozen"
32
+ else
33
+ install
34
+ freezify
24
35
  end
25
36
  true
26
37
  end
38
+
39
+ def status
40
+ puts "#{@name} is #{frozen? ? "frozen" : "not frozen"}"
41
+ end
27
42
 
28
43
  def unfreezify
29
- return true unless frozen?
30
- Dir.chdir(temp_path) do
31
- `tar xzf #{@name}.git.tgz`
32
- FileUtils.mv(".git", repo_path)
33
- FileUtils.rm("#{@name}.git.tgz")
44
+ install unless File.exist?(repo_path)
45
+ if unfrozen?
46
+ puts "#{@name} is already unfrozen"
47
+ elsif can_be_unfrozen?
48
+ Dir.chdir(temp_path) do
49
+ `tar xzf #{@name}.git.tgz`
50
+ FileUtils.mv(".git", repo_path)
51
+ FileUtils.rm("#{@name}.git.tgz")
52
+ end
53
+ puts "#{@name} unfrozen"
54
+ else
55
+ install
34
56
  end
35
57
  true
36
58
  end
59
+
60
+ def can_be_frozen?
61
+ File.exist?("#{repo_path}/.git")
62
+ end
63
+
64
+ def can_be_unfrozen?
65
+ File.exists?("#{temp_path}/#{@name}.git.tgz")
66
+ end
37
67
 
38
68
  def frozen?
39
- File.exist?(repo_path) && !File.exist?("#{repo_path}/.git")
69
+ !File.exist?("#{repo_path}/.git") &&
70
+ File.exists?("#{temp_path}/#{@name}.git.tgz")
71
+ end
72
+
73
+ def unfrozen?
74
+ File.exist?("#{repo_path}/.git") &&
75
+ !File.exists?("#{temp_path}/#{@name}.git.tgz")
40
76
  end
41
77
 
42
78
  private
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winton Welsh