winton-externals 0.1.4 → 0.1.5
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/bin/externals +1 -8
- data/externals.gemspec +2 -2
- data/lib/externals/app.rb +11 -14
- data/lib/externals/repository.rb +65 -43
- data/spec/spec_helper.rb +4 -5
- metadata +2 -2
data/bin/externals
CHANGED
@@ -3,12 +3,5 @@
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'externals'
|
5
5
|
|
6
|
-
action = ARGV[0]
|
7
|
-
available_actions = %w(status freeze unfreeze)
|
8
|
-
unless available_actions.include?(action)
|
9
|
-
puts "Usage: externals (#{available_actions.join(':')})"
|
10
|
-
exit 1
|
11
|
-
end
|
12
|
-
|
13
6
|
app = Externals::App.new(FileUtils.pwd)
|
14
|
-
app.run(
|
7
|
+
app.run(ARGV[0])
|
data/externals.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'externals'
|
3
|
-
s.version = '0.1.
|
4
|
-
s.date = '2008-03-
|
3
|
+
s.version = '0.1.5'
|
4
|
+
s.date = '2008-03-12'
|
5
5
|
|
6
6
|
s.summary = "Work on git externals without affecting others"
|
7
7
|
s.description = "Work on git externals without affecting others"
|
data/lib/externals/app.rb
CHANGED
@@ -8,22 +8,20 @@ module Externals
|
|
8
8
|
config.each_repo {|r| r.status }
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
config.each_repo {|r| r.
|
11
|
+
def freeze
|
12
|
+
config.each_repo {|r| r.freeze }
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
16
|
-
config.each_repo {|r| r.
|
15
|
+
def unfreeze
|
16
|
+
config.each_repo {|r| r.unfreeze }
|
17
17
|
end
|
18
18
|
|
19
19
|
def run(action)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
when "unfreeze"
|
26
|
-
unfreezify
|
20
|
+
available_actions = %w(status freeze unfreeze)
|
21
|
+
if available_actions.include?(action)
|
22
|
+
send(action)
|
23
|
+
else
|
24
|
+
puts "Usage: externals (#{available_actions.join(':')})"
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
@@ -36,10 +34,9 @@ module Externals
|
|
36
34
|
|
37
35
|
if config_file.nil?
|
38
36
|
$stderr.puts "config/externals.yml is missing"
|
39
|
-
|
37
|
+
else
|
38
|
+
@config = YamlConfig.new(@base_dir, File.read(config_file))
|
40
39
|
end
|
41
|
-
|
42
|
-
@config = YamlConfig.new(@base_dir, File.read(config_file))
|
43
40
|
end
|
44
41
|
end
|
45
42
|
end
|
data/lib/externals/repository.rb
CHANGED
@@ -11,71 +11,97 @@ module Externals
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def install
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
# Create directory that we will clone into
|
15
|
+
unless File.exist?(checkout_path)
|
16
|
+
FileUtils.mkdir_p(checkout_path)
|
17
|
+
end
|
18
|
+
Dir.chdir(checkout_path) do
|
19
|
+
# Remove repository if exists
|
20
|
+
FileUtils.rm_rf(@name)
|
21
|
+
# Clone repository
|
22
|
+
`git clone #{@repo_url} #{@name}`
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
|
-
def
|
21
|
-
install unless
|
22
|
-
if
|
26
|
+
def freeze
|
27
|
+
install unless exists?
|
28
|
+
if is_not_a_git_repo?
|
23
29
|
puts "#{@name} is already frozen"
|
24
|
-
elsif
|
30
|
+
elsif is_a_git_repo?
|
31
|
+
overwrite = true
|
32
|
+
# Conditionally destroy compressed repo
|
33
|
+
if is_compressed?
|
34
|
+
puts "You already have a frozen git snapshot. Overwrite?"
|
35
|
+
overwrite = STDIN.gets.downcase[0..0] == 'y'
|
36
|
+
end
|
25
37
|
Dir.chdir(repo_path) do
|
26
|
-
|
27
|
-
|
28
|
-
|
38
|
+
if overwrite
|
39
|
+
# Make temp directory
|
40
|
+
FileUtils.mkdir_p(temp_path)
|
41
|
+
# Compress .git folder to temp
|
42
|
+
`tar czf #{temp_path}/#{@name}.git.tgz .git`
|
43
|
+
end
|
44
|
+
# Remove repository's .git folder
|
29
45
|
FileUtils.rm_r('.git')
|
30
46
|
end
|
31
47
|
puts "#{@name} frozen"
|
32
|
-
else
|
33
|
-
install
|
34
|
-
freezify
|
35
48
|
end
|
36
|
-
true
|
37
49
|
end
|
38
50
|
|
39
51
|
def status
|
40
|
-
|
52
|
+
if exists?
|
53
|
+
puts "#{@name} is #{is_a_git_repo? ? "not frozen" : "frozen and #{is_compressed? ? "has" : "does not have"} a snapshot"}"
|
54
|
+
else
|
55
|
+
puts "#{@name} does not exist and #{is_compressed? ? "has" : "does not have"} a snapshot"
|
56
|
+
end
|
41
57
|
end
|
42
58
|
|
43
|
-
def
|
44
|
-
|
45
|
-
if unfrozen?
|
59
|
+
def unfreeze
|
60
|
+
if is_a_git_repo?
|
46
61
|
puts "#{@name} is already unfrozen"
|
47
|
-
elsif
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
62
|
+
elsif !exists?
|
63
|
+
install
|
64
|
+
puts "#{@name} unfrozen"
|
65
|
+
elsif is_not_a_git_repo?
|
66
|
+
if is_compressed?
|
67
|
+
Dir.chdir(temp_path) do
|
68
|
+
# Decompress git snapshot
|
69
|
+
`tar xzf #{@name}.git.tgz`
|
70
|
+
# Move back to repo
|
71
|
+
FileUtils.mv(".git", repo_path)
|
72
|
+
# Remove snapshot
|
73
|
+
FileUtils.rm_f("#{@name}.git.tgz")
|
74
|
+
end
|
75
|
+
# Reset repository to snapshot
|
76
|
+
Dir.chdir(repo_path) do
|
77
|
+
`git reset --hard`
|
78
|
+
end
|
79
|
+
else
|
80
|
+
# Clone fresh repo if no snapshot found
|
81
|
+
install
|
55
82
|
end
|
56
83
|
puts "#{@name} unfrozen"
|
57
|
-
else
|
58
|
-
install
|
59
84
|
end
|
60
|
-
true
|
61
85
|
end
|
62
86
|
|
63
|
-
def
|
87
|
+
def exists?
|
88
|
+
File.exist?(repo_path)
|
89
|
+
end
|
90
|
+
|
91
|
+
def is_a_git_repo?
|
64
92
|
File.exist?("#{repo_path}/.git")
|
65
93
|
end
|
66
94
|
|
67
|
-
def
|
68
|
-
|
95
|
+
def is_not_a_git_repo?
|
96
|
+
!is_a_git_repo?
|
69
97
|
end
|
70
|
-
|
71
|
-
def
|
72
|
-
!File.exist?("#{repo_path}/.git") &&
|
98
|
+
|
99
|
+
def is_compressed?
|
73
100
|
File.exists?("#{temp_path}/#{@name}.git.tgz")
|
74
101
|
end
|
75
102
|
|
76
|
-
def
|
77
|
-
|
78
|
-
!File.exists?("#{temp_path}/#{@name}.git.tgz")
|
103
|
+
def is_not_compressed?
|
104
|
+
!is_compressed?
|
79
105
|
end
|
80
106
|
|
81
107
|
private
|
@@ -86,10 +112,6 @@ module Externals
|
|
86
112
|
def repo_path
|
87
113
|
File.expand_path(checkout_path + '/' + @name)
|
88
114
|
end
|
89
|
-
|
90
|
-
def rel_repo_path
|
91
|
-
@rel_path + '/' + @name
|
92
|
-
end
|
93
115
|
|
94
116
|
def temp_path
|
95
117
|
@base_dir + '/tmp'
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Winton Welsh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-03-
|
12
|
+
date: 2008-03-12 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|