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 +36 -1
- data/bin/externals +1 -1
- data/externals.gemspec +1 -1
- data/lib/externals/app.rb +4 -4
- data/lib/externals/repository.rb +46 -10
- metadata +1 -1
data/README.markdown
CHANGED
@@ -1 +1,36 @@
|
|
1
|
-
|
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(
|
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
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
|
8
|
-
config.each_repo {|r| r.
|
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 "
|
22
|
-
|
21
|
+
when "status"
|
22
|
+
status
|
23
23
|
when "freeze"
|
24
24
|
freezify
|
25
25
|
when "unfreeze"
|
data/lib/externals/repository.rb
CHANGED
@@ -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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
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
|