ext 1.0.4 → 1.0.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/CHANGELOG +4 -0
- data/bin/ext +0 -0
- data/lib/externals/ext.rb +1 -1
- data/lib/externals/extensions/file_utils.rb +20 -5
- data/lib/externals/scms/git_project.rb +63 -38
- data/lib/externals/test/modules_svn_branches_repository.rb +1 -1
- data/lib/externals/test/simple_git_with_sub.rb +62 -0
- data/lib/externals/test/svn_repository_helper.rb +2 -2
- data/test/test_checkout_with_subprojects_git.rb +3 -1
- data/test/test_out_of_date_git_subproject.rb +83 -0
- data/test/test_svn_branches.rb +1 -1
- metadata +44 -41
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
October 19, 2011 Version 1.0.5 released
|
2
|
+
- Fixed a small bug preventing subprojects managed under git to update if they
|
3
|
+
have a branch set in .externals.
|
4
|
+
|
1
5
|
October 9, 2011 Version 1.0.4 released
|
2
6
|
- Dependency on programs such as rm, rmdir, cp, etc, removed. Now only
|
3
7
|
dependent on the actual SCM executables (and gzip to run the tests.)
|
data/bin/ext
CHANGED
File without changes
|
data/lib/externals/ext.rb
CHANGED
@@ -9,7 +9,7 @@ Dir.entries(File.join(File.dirname(__FILE__), 'extensions')).each do |extension|
|
|
9
9
|
end
|
10
10
|
|
11
11
|
module Externals
|
12
|
-
VERSION = '1.0.
|
12
|
+
VERSION = '1.0.5'
|
13
13
|
PROJECT_TYPES_DIRECTORY = File.join(File.dirname(__FILE__), '..', 'externals','project_types')
|
14
14
|
|
15
15
|
# Full commands operate on the main project as well as the externals
|
@@ -24,16 +24,31 @@ FileUtils.class_eval do
|
|
24
24
|
alias rm_rf_old rm_rf
|
25
25
|
#going to try to give a delay after calling rm if necessary...
|
26
26
|
def rm_rf *args
|
27
|
-
rm_rf_old *args
|
28
27
|
tries = 0
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
|
29
|
+
rm = proc do
|
30
|
+
rm_rf_old *args
|
31
|
+
|
32
|
+
while File.exists?(args[0]) && tries < 10
|
33
|
+
sleep 1
|
34
|
+
tries += 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
rm.call
|
39
|
+
if tries >= 10
|
40
|
+
puts "WARNING: deleted #{args[0]} didn't work, trying again"
|
41
|
+
tries = 0
|
42
|
+
rm.call
|
43
|
+
|
44
|
+
if tries >= 10
|
45
|
+
raise "Could not delete #{args[0]}"
|
46
|
+
end
|
32
47
|
end
|
33
48
|
end
|
34
49
|
|
35
50
|
def dir_empty? path
|
36
|
-
File.directory?(path) &&
|
51
|
+
File.directory?(path) &&
|
37
52
|
File.exists?(path) &&
|
38
53
|
!Dir.entries(path).detect{|entry| !["..","."].include?(entry)}
|
39
54
|
end
|
@@ -7,7 +7,7 @@ module Externals
|
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
|
-
def
|
10
|
+
def do_clone command, extra_opts = ""
|
11
11
|
opts = resolve_opts(command)
|
12
12
|
|
13
13
|
puts "path is #{path} repository is #{repository}"
|
@@ -19,18 +19,16 @@ module Externals
|
|
19
19
|
dest = '' if dest == '.'
|
20
20
|
dest = "\"#{dest}\"" if dest && !dest.empty?
|
21
21
|
|
22
|
-
puts(gitclonecmd = "git #{opts} clone \"#{repository}\" #{dest}")
|
22
|
+
puts(gitclonecmd = "git #{opts} clone #{extra_opts} \"#{repository}\" #{dest}")
|
23
23
|
puts `#{gitclonecmd}`
|
24
24
|
unless $? == 0
|
25
25
|
raise "git clone of #{repository} failed."
|
26
26
|
end
|
27
|
-
|
28
|
-
change_to_branch_revision(command)
|
29
27
|
end
|
30
28
|
|
31
29
|
public
|
32
30
|
def co *args
|
33
|
-
|
31
|
+
do_up "co"
|
34
32
|
end
|
35
33
|
|
36
34
|
private
|
@@ -40,27 +38,37 @@ module Externals
|
|
40
38
|
`git #{opts} branch -a` =~ /^\s*#{branch_name}\s*$/
|
41
39
|
end
|
42
40
|
|
41
|
+
# make sure you have already entered Dir.chdir(path) in your calling code!
|
42
|
+
|
43
43
|
public
|
44
|
+
# this method fetches/pulls/changes branches/changes revisions/changes the oil in your geo metro/brings world peace
|
44
45
|
def change_to_branch_revision command = ""
|
45
46
|
opts = resolve_opts(command)
|
46
47
|
|
48
|
+
pulled = false
|
49
|
+
|
50
|
+
project_path = if path == "."
|
51
|
+
name || "."
|
52
|
+
else
|
53
|
+
path
|
54
|
+
end
|
55
|
+
|
56
|
+
Dir.chdir project_path do
|
57
|
+
do_fetch command
|
58
|
+
end
|
59
|
+
|
60
|
+
|
47
61
|
if branch
|
48
62
|
cb = current_branch
|
49
63
|
|
50
64
|
# This allows the main project to be checked out to a directory
|
51
65
|
# that doesn't match it's name.
|
52
|
-
project_path = if path == "."
|
53
|
-
name
|
54
|
-
else
|
55
|
-
path
|
56
|
-
end
|
57
|
-
|
58
66
|
Dir.chdir project_path do
|
59
67
|
if cb != branch
|
60
68
|
# let's see if the branch exists in the remote repository
|
61
69
|
# and if not, fetch it.
|
62
70
|
if !branch_exists("origin/#{branch}")
|
63
|
-
|
71
|
+
do_fetch command
|
64
72
|
end
|
65
73
|
|
66
74
|
# if the local branch doens't exist, add --track -b
|
@@ -74,17 +82,29 @@ module Externals
|
|
74
82
|
end
|
75
83
|
end
|
76
84
|
end
|
85
|
+
|
86
|
+
# on the right branch, let's pull
|
87
|
+
Dir.chdir project_path do
|
88
|
+
`git #{opts} pull`
|
89
|
+
raise unless $? == 0
|
90
|
+
pulled = true
|
91
|
+
end
|
77
92
|
end
|
78
93
|
|
79
94
|
if revision
|
80
|
-
Dir.chdir
|
81
|
-
puts `git #{opts} fetch`
|
82
|
-
puts `git #{opts} pull`
|
95
|
+
Dir.chdir project_path do
|
83
96
|
puts `git #{opts} checkout #{revision}`
|
84
97
|
unless $? == 0
|
85
98
|
raise "Could not checkout #{revision}"
|
86
99
|
end
|
87
100
|
end
|
101
|
+
else
|
102
|
+
unless pulled
|
103
|
+
Dir.chdir project_path do
|
104
|
+
`git #{opts} pull`
|
105
|
+
raise unless $? == 0
|
106
|
+
end
|
107
|
+
end
|
88
108
|
end
|
89
109
|
end
|
90
110
|
|
@@ -116,38 +136,43 @@ module Externals
|
|
116
136
|
end
|
117
137
|
|
118
138
|
def ex *args
|
119
|
-
|
120
|
-
rmdir_ie path
|
121
|
-
end
|
122
|
-
|
123
|
-
dest = path
|
124
|
-
|
125
|
-
dest = '' if dest == '.'
|
126
|
-
|
127
|
-
dest = "\"#{dest}\"" if dest && !dest.empty?
|
128
|
-
|
129
|
-
puts(gitclonecmd = "git #{scm_opts_ex} clone --depth 1 \"#{repository}\" #{dest}")
|
130
|
-
|
131
|
-
puts `#{gitclonecmd}`
|
139
|
+
do_clone "ex", "--depth 1"
|
132
140
|
|
133
141
|
change_to_branch_revision "ex"
|
134
142
|
end
|
135
143
|
|
136
144
|
def up *args
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
145
|
+
do_up "up"
|
146
|
+
end
|
147
|
+
|
148
|
+
private
|
149
|
+
def do_fetch command
|
150
|
+
opts = resolve_opts(command)
|
151
|
+
`git #{opts} fetch`
|
152
|
+
raise unless $? == 0
|
153
|
+
end
|
154
|
+
|
155
|
+
def do_up command
|
156
|
+
opts = resolve_opts(command)
|
157
|
+
|
158
|
+
project_path = if path == "."
|
159
|
+
name || "." # if no name is specified then we are expected to already be in the right path.
|
160
|
+
# this is a little confusing and should be cleaned up.
|
161
|
+
# When we are doing a checkout, the name is set manually in Ext.checkout.
|
162
|
+
# we are then in the parent directory.
|
163
|
+
# When we are doing an update, the main project has no name.
|
164
|
+
# we are then in the correct directory.
|
146
165
|
else
|
147
|
-
|
166
|
+
path
|
148
167
|
end
|
168
|
+
|
169
|
+
if !File.exists? project_path
|
170
|
+
do_clone command
|
171
|
+
end
|
172
|
+
change_to_branch_revision command
|
149
173
|
end
|
150
174
|
|
175
|
+
public
|
151
176
|
def st *args
|
152
177
|
puts "\nstatus for #{path}:"
|
153
178
|
Dir.chdir path do
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'externals/test/repository'
|
2
|
+
require 'externals/test/basic_git_repository'
|
3
|
+
|
4
|
+
module Externals
|
5
|
+
module Test
|
6
|
+
class SimpleGitWithSub < Repository
|
7
|
+
def initialize
|
8
|
+
super "simple_wth_sub", File.join("git", "5")
|
9
|
+
dependents.merge!(
|
10
|
+
:basic => BasicGitRepository.new
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_here
|
15
|
+
mkdir name
|
16
|
+
|
17
|
+
Dir.chdir("#{name}") do
|
18
|
+
`git init`
|
19
|
+
raise unless $? == 0
|
20
|
+
|
21
|
+
open 'simple_readme.txt', 'w' do |f|
|
22
|
+
f.write "simple_readme.txt Line 1
|
23
|
+
Line 2
|
24
|
+
Line 3
|
25
|
+
"
|
26
|
+
end
|
27
|
+
|
28
|
+
`git add .`
|
29
|
+
raise unless $? == 0
|
30
|
+
`git commit -m "added simple_readme.txt"`
|
31
|
+
raise unless $? == 0
|
32
|
+
|
33
|
+
open 'simple_readme.txt', 'a' do |f|
|
34
|
+
f.write "line 4"
|
35
|
+
end
|
36
|
+
|
37
|
+
`git add .`
|
38
|
+
raise unless $? == 0
|
39
|
+
`git commit -m "added a line to simple_readme.txt"`
|
40
|
+
raise unless $? == 0
|
41
|
+
|
42
|
+
# initialize externals
|
43
|
+
Ext.run "init"
|
44
|
+
|
45
|
+
mkdir "subs"
|
46
|
+
|
47
|
+
Ext.run "touch_emptydirs"
|
48
|
+
|
49
|
+
# adding a branch here exposes a bug
|
50
|
+
Ext.run "install", "-g", "-b", "master",
|
51
|
+
dependents[:basic].clean_dir, "subs/#{dependents[:basic].name}"
|
52
|
+
|
53
|
+
`git add .`
|
54
|
+
raise unless $? == 0
|
55
|
+
`git commit -m "added basic subproject under subs"`
|
56
|
+
raise unless $? == 0
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -107,7 +107,9 @@ module Externals
|
|
107
107
|
|
108
108
|
#now let's check it out again to test "ext checkout -b new_branch"
|
109
109
|
rm_rf "rails_app"
|
110
|
-
|
110
|
+
if File.exists?("rails_app")
|
111
|
+
raise
|
112
|
+
end
|
111
113
|
|
112
114
|
Ext.run "checkout", "--git", "-b", "new_branch", source
|
113
115
|
|
@@ -0,0 +1,83 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
|
2
|
+
require 'externals/test_case'
|
3
|
+
require 'externals/ext'
|
4
|
+
require 'externals/test/simple_git_with_sub'
|
5
|
+
|
6
|
+
module Externals
|
7
|
+
module Test
|
8
|
+
class TestOutOfDateGitSubproject < TestCase
|
9
|
+
include ExtTestCase
|
10
|
+
|
11
|
+
def test_out_of_date_sub
|
12
|
+
repository = SimpleGitWithSub.new
|
13
|
+
repository.prepare
|
14
|
+
|
15
|
+
assert File.exists?(File.join(repository.clean_dir, ".git"))
|
16
|
+
|
17
|
+
workdir = File.join(root_dir, 'test', "tmp", "workdir")
|
18
|
+
mkdir_p workdir
|
19
|
+
|
20
|
+
Dir.chdir workdir do
|
21
|
+
if File.exists?(repository.name)
|
22
|
+
rm_r repository.name
|
23
|
+
end
|
24
|
+
|
25
|
+
Ext.run "checkout", "--git", repository.clean_dir
|
26
|
+
|
27
|
+
assert !File.exists?(File.join(repository.name, "readme.txt"))
|
28
|
+
assert File.exists?(File.join(repository.name, "simple_readme.txt"))
|
29
|
+
assert !File.exists?(File.join(
|
30
|
+
repository.name, "subs", repository.dependents[:basic].name, "simple_readme.txt")
|
31
|
+
)
|
32
|
+
assert File.exists?(File.join(
|
33
|
+
repository.name, "subs", repository.dependents[:basic].name, "readme.txt")
|
34
|
+
)
|
35
|
+
|
36
|
+
readme = File.read(File.join(
|
37
|
+
repository.name, "subs", repository.dependents[:basic].name, "readme.txt"))
|
38
|
+
|
39
|
+
assert readme =~ /Line 4/i
|
40
|
+
assert readme !~ /Line 5/i
|
41
|
+
|
42
|
+
# let's update the subproject and make sure that ext update works.
|
43
|
+
|
44
|
+
tmp = "tmp_update_sub"
|
45
|
+
rm_rf tmp
|
46
|
+
mkdir tmp
|
47
|
+
Dir.chdir tmp do
|
48
|
+
`git clone #{repository.dependents[:basic].clean_dir}`
|
49
|
+
raise unless $? == 0
|
50
|
+
|
51
|
+
repository.dependents[:basic].mark_dirty
|
52
|
+
|
53
|
+
Dir.chdir repository.dependents[:basic].name do
|
54
|
+
open 'readme.txt', 'a' do |f|
|
55
|
+
f.write "line 5"
|
56
|
+
end
|
57
|
+
|
58
|
+
`git add .`
|
59
|
+
raise unless $? == 0
|
60
|
+
`git commit -m "added line 5 to readme.txt"`
|
61
|
+
raise unless $? == 0
|
62
|
+
`git push`
|
63
|
+
raise unless $? == 0
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
rm_rf tmp
|
68
|
+
|
69
|
+
Dir.chdir repository.name do
|
70
|
+
Ext.run "update"
|
71
|
+
|
72
|
+
readme = File.read(File.join(
|
73
|
+
"subs", repository.dependents[:basic].name, "readme.txt"))
|
74
|
+
|
75
|
+
assert readme =~ /Line 4/i
|
76
|
+
assert readme =~ /Line 5/i
|
77
|
+
assert readme !~ /Line 6/i
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/test/test_svn_branches.rb
CHANGED
@@ -68,7 +68,7 @@ module Externals
|
|
68
68
|
|
69
69
|
assert_equal "current", modules.current_branch
|
70
70
|
assert_equal "current", ext.configuration["modules"]["branch"]
|
71
|
-
|
71
|
+
|
72
72
|
assert !File.exists?(File.join(%w(vendor plugins ssl_requirement)))
|
73
73
|
assert !File.exists?(File.join(%w(vendor plugins empty_plugin)))
|
74
74
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Miles Georgi
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-10-
|
18
|
+
date: 2011-10-19 00:00:00 -07:00
|
19
19
|
default_executable: ext
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -59,47 +59,49 @@ files:
|
|
59
59
|
- README
|
60
60
|
- MIT_LICENSE.txt
|
61
61
|
- CHANGELOG
|
62
|
-
- lib/externals/
|
62
|
+
- lib/externals/command.rb
|
63
63
|
- lib/externals/configuration/configuration.rb
|
64
|
-
- lib/externals/
|
65
|
-
- lib/externals/
|
64
|
+
- lib/externals/ext.rb
|
65
|
+
- lib/externals/extensions/file_utils.rb
|
66
|
+
- lib/externals/extensions/string.rb
|
67
|
+
- lib/externals/extensions/symbol.rb
|
68
|
+
- lib/externals/project.rb
|
69
|
+
- lib/externals/project_types/rails.rb
|
70
|
+
- lib/externals/scms/git_project.rb
|
71
|
+
- lib/externals/scms/svn_project.rb
|
66
72
|
- lib/externals/test/basic_git_repository.rb
|
67
|
-
- lib/externals/test/modules_svn_repository.rb
|
68
73
|
- lib/externals/test/engines.rb
|
69
|
-
- lib/externals/test/rails_app_svn_repository.rb
|
70
74
|
- lib/externals/test/engines_with_branch1.rb
|
71
|
-
- lib/externals/test/rails_app_unmanaged.rb
|
72
|
-
- lib/externals/test/repository.rb
|
73
|
-
- lib/externals/test/rails_app_git_branches.rb
|
74
|
-
- lib/externals/test/modules_svn_branches_repository.rb
|
75
75
|
- lib/externals/test/fake_rails_repository.rb
|
76
|
-
- lib/externals/test/svn_repository_helper.rb
|
77
|
-
- lib/externals/test/svn_repository_from_dump.rb
|
78
76
|
- lib/externals/test/git_repository_from_internet.rb
|
77
|
+
- lib/externals/test/modules_svn_branches_repository.rb
|
78
|
+
- lib/externals/test/modules_svn_repository.rb
|
79
|
+
- lib/externals/test/rails_app_git_branches.rb
|
79
80
|
- lib/externals/test/rails_app_git_repository.rb
|
80
|
-
- lib/externals/
|
81
|
-
- lib/externals/
|
82
|
-
- lib/externals/
|
83
|
-
- lib/externals/
|
84
|
-
- lib/externals/
|
85
|
-
- lib/externals/
|
86
|
-
- lib/externals/
|
87
|
-
- lib/externals/
|
88
|
-
- test/
|
81
|
+
- lib/externals/test/rails_app_svn_branches.rb
|
82
|
+
- lib/externals/test/rails_app_svn_repository.rb
|
83
|
+
- lib/externals/test/rails_app_unmanaged.rb
|
84
|
+
- lib/externals/test/repository.rb
|
85
|
+
- lib/externals/test/simple_git_with_sub.rb
|
86
|
+
- lib/externals/test/svn_repository_from_dump.rb
|
87
|
+
- lib/externals/test/svn_repository_helper.rb
|
88
|
+
- lib/externals/test_case.rb
|
89
|
+
- test/test_checkout_git.rb
|
89
90
|
- test/test_checkout_with_subprojects_git.rb
|
90
|
-
- test/test_touch_emptydirs.rb
|
91
|
-
- test/test_version.rb
|
92
|
-
- test/test_git_project_extract_name.rb
|
93
|
-
- test/test_freeze_to_revision.rb
|
94
91
|
- test/test_checkout_with_subprojects_svn.rb
|
95
|
-
- test/test_checkout_git.rb
|
96
|
-
- test/test_rails_detection.rb
|
97
|
-
- test/test_init_git.rb
|
98
92
|
- test/test_file_utils_extensions.rb
|
93
|
+
- test/test_freeze_to_revision.rb
|
94
|
+
- test/test_git_project_extract_name.rb
|
95
|
+
- test/test_init_git.rb
|
96
|
+
- test/test_out_of_date_git_subproject.rb
|
99
97
|
- test/test_projects.rb
|
98
|
+
- test/test_rails_detection.rb
|
100
99
|
- test/test_string_extensions.rb
|
101
|
-
- test/
|
100
|
+
- test/test_svn_branches.rb
|
101
|
+
- test/test_touch_emptydirs.rb
|
102
|
+
- test/test_version.rb
|
102
103
|
- test/setup/empty_plugin.svn.gz
|
104
|
+
- test/setup/foreign_key_migrations.svn.gz
|
103
105
|
- test/setup/redhillonrails_core.svn.gz
|
104
106
|
- bin/ext
|
105
107
|
has_rdoc: true
|
@@ -137,19 +139,20 @@ signing_key:
|
|
137
139
|
specification_version: 3
|
138
140
|
summary: Provides an SCM agnostic way to manage subprojects with a workflow similar to the svn:externals feature of subversion. It's particularly useful for rails projects that have some plugins managed by svn and some managed by git.
|
139
141
|
test_files:
|
140
|
-
- test/
|
142
|
+
- test/test_checkout_git.rb
|
141
143
|
- test/test_checkout_with_subprojects_git.rb
|
142
|
-
- test/test_touch_emptydirs.rb
|
143
|
-
- test/test_version.rb
|
144
|
-
- test/test_git_project_extract_name.rb
|
145
|
-
- test/test_freeze_to_revision.rb
|
146
144
|
- test/test_checkout_with_subprojects_svn.rb
|
147
|
-
- test/test_checkout_git.rb
|
148
|
-
- test/test_rails_detection.rb
|
149
|
-
- test/test_init_git.rb
|
150
145
|
- test/test_file_utils_extensions.rb
|
146
|
+
- test/test_freeze_to_revision.rb
|
147
|
+
- test/test_git_project_extract_name.rb
|
148
|
+
- test/test_init_git.rb
|
149
|
+
- test/test_out_of_date_git_subproject.rb
|
151
150
|
- test/test_projects.rb
|
151
|
+
- test/test_rails_detection.rb
|
152
152
|
- test/test_string_extensions.rb
|
153
|
-
- test/
|
153
|
+
- test/test_svn_branches.rb
|
154
|
+
- test/test_touch_emptydirs.rb
|
155
|
+
- test/test_version.rb
|
154
156
|
- test/setup/empty_plugin.svn.gz
|
157
|
+
- test/setup/foreign_key_migrations.svn.gz
|
155
158
|
- test/setup/redhillonrails_core.svn.gz
|