ext 1.0.1 → 1.0.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/CHANGELOG +6 -0
- data/Rakefile +3 -3
- data/lib/externals/configuration/configuration.rb +1 -1
- data/lib/externals/ext.rb +7 -6
- data/lib/externals/scms/git_project.rb +42 -4
- data/test/test_checkout_with_subprojects_git.rb +89 -4
- metadata +4 -4
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
September 8, 2011 Version 1.0.2 released
|
|
2
|
+
- For git, fixed bug preventing "ext up" from changing the branches of subprojects as expected.
|
|
3
|
+
- For git, fixed bug preventing "ext checkout -b <branch_name>" from functioning as expected.
|
|
4
|
+
- Updating with revisions/branches should now do a fetch when using git to make sure
|
|
5
|
+
that new tags and branches are added.
|
|
6
|
+
|
|
1
7
|
July 19, 2011 Version 1.0.1 released
|
|
2
8
|
- Fixed a small bug preventing subprojects with a revision associated with them
|
|
3
9
|
from having their name displayed when updating.
|
data/Rakefile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'rake'
|
|
2
2
|
require 'rake/testtask'
|
|
3
|
-
require '
|
|
4
|
-
require '
|
|
3
|
+
require 'rdoc/task'
|
|
4
|
+
require 'rubygems/package_task'
|
|
5
5
|
require 'find'
|
|
6
6
|
|
|
7
7
|
root_dir = File.dirname(__FILE__)
|
|
@@ -143,6 +143,6 @@ the main project.}
|
|
|
143
143
|
#specification.require_path = 'lib'
|
|
144
144
|
end
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
Gem::PackageTask.new(gem_specification) do |package|
|
|
147
147
|
package.need_zip = package.need_tar = false
|
|
148
148
|
end
|
data/lib/externals/ext.rb
CHANGED
|
@@ -5,10 +5,7 @@ require 'externals/command'
|
|
|
5
5
|
require 'externals/extensions/symbol'
|
|
6
6
|
|
|
7
7
|
module Externals
|
|
8
|
-
|
|
9
|
-
OBSOLETE_EXTERNALS_FILE = 15
|
|
10
|
-
|
|
11
|
-
VERSION = '1.0.1'
|
|
8
|
+
VERSION = '1.0.2'
|
|
12
9
|
PROJECT_TYPES_DIRECTORY = File.join(File.dirname(__FILE__), '..', 'externals','project_types')
|
|
13
10
|
|
|
14
11
|
# Full commands operate on the main project as well as the externals
|
|
@@ -246,6 +243,7 @@ module Externals
|
|
|
246
243
|
p.name == name
|
|
247
244
|
end
|
|
248
245
|
end
|
|
246
|
+
alias :subproject :subproject_by_name_or_path
|
|
249
247
|
|
|
250
248
|
def subprojects
|
|
251
249
|
s = []
|
|
@@ -681,8 +679,11 @@ Please use the --type option to tell ext which to use."
|
|
|
681
679
|
(such as --git or --svn)"
|
|
682
680
|
end
|
|
683
681
|
|
|
684
|
-
main_project = self.class.project_class(scm).new(
|
|
685
|
-
:
|
|
682
|
+
main_project = self.class.project_class(scm).new(
|
|
683
|
+
:repository => repository,
|
|
684
|
+
:path => path,
|
|
685
|
+
:branch => options[:branch]
|
|
686
|
+
)
|
|
686
687
|
|
|
687
688
|
main_project.send(sym)
|
|
688
689
|
main_project
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', 'project')
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
module Externals
|
|
5
4
|
class GitProject < Project
|
|
6
5
|
def default_branch
|
|
@@ -32,18 +31,57 @@ module Externals
|
|
|
32
31
|
co_or_up "co"
|
|
33
32
|
end
|
|
34
33
|
|
|
34
|
+
private
|
|
35
|
+
# make sure you have already entered Dir.chdir(path) in your calling code!
|
|
36
|
+
def branch_exists branch_name
|
|
37
|
+
opts = resolve_opts
|
|
38
|
+
`git #{opts} branch -a` =~ /^\s*#{branch_name}\s*$/
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
public
|
|
35
42
|
def change_to_branch_revision command = ""
|
|
36
43
|
opts = resolve_opts(command)
|
|
37
44
|
|
|
38
45
|
if branch
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
cb = current_branch
|
|
47
|
+
|
|
48
|
+
# This allows the main project to be checked out to a directory
|
|
49
|
+
# that doesn't match it's name.
|
|
50
|
+
project_path = if path == "."
|
|
51
|
+
name
|
|
52
|
+
else
|
|
53
|
+
path
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
Dir.chdir project_path do
|
|
57
|
+
if cb != branch
|
|
58
|
+
# let's see if the branch exists in the remote repository
|
|
59
|
+
# and if not, fetch it.
|
|
60
|
+
if !branch_exists("origin/#{branch}")
|
|
61
|
+
puts `git #{opts} fetch`
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# if the local branch doens't exist, add --track -b
|
|
65
|
+
if branch_exists(branch)
|
|
66
|
+
puts `git #{opts} checkout #{branch}`
|
|
67
|
+
else
|
|
68
|
+
puts `git #{opts} checkout --track -b #{branch} origin/#{branch}`
|
|
69
|
+
end
|
|
70
|
+
unless $? == 0
|
|
71
|
+
raise "Could not checkout origin/#{branch}"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
41
74
|
end
|
|
42
75
|
end
|
|
43
76
|
|
|
44
77
|
if revision
|
|
45
78
|
Dir.chdir path do
|
|
79
|
+
puts `git #{opts} fetch`
|
|
80
|
+
puts `git #{opts} pull`
|
|
46
81
|
puts `git #{opts} checkout #{revision}`
|
|
82
|
+
unless $? == 0
|
|
83
|
+
raise "Could not checkout #{revision}"
|
|
84
|
+
end
|
|
47
85
|
end
|
|
48
86
|
end
|
|
49
87
|
end
|
|
@@ -70,7 +108,7 @@ module Externals
|
|
|
70
108
|
def up *args
|
|
71
109
|
if File.exists? path
|
|
72
110
|
puts "updating #{path}:"
|
|
73
|
-
if revision
|
|
111
|
+
if revision || branch
|
|
74
112
|
change_to_branch_revision "up"
|
|
75
113
|
else
|
|
76
114
|
Dir.chdir path do
|
|
@@ -6,7 +6,6 @@ module Externals
|
|
|
6
6
|
class TestCheckoutWithSubprojectsGit < TestCase
|
|
7
7
|
include ExtTestCase
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
def setup
|
|
11
10
|
destroy_rails_application
|
|
12
11
|
create_rails_application
|
|
@@ -31,9 +30,13 @@ module Externals
|
|
|
31
30
|
|
|
32
31
|
#install a couple svn managed subprojects
|
|
33
32
|
%w(foreign_key_migrations redhillonrails_core).each do |proj|
|
|
34
|
-
Ext.run "install", "--svn", 'file:///' +
|
|
33
|
+
Ext.run "install", "--svn", 'file:///' +
|
|
34
|
+
File.join(root_dir, 'test', 'cleanreps', proj)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
#install project with a branch
|
|
38
|
+
Ext.run "install", File.join(root_dir, 'test', 'cleanreps', 'engines.git'), "-b", "edge"
|
|
39
|
+
|
|
37
40
|
GitProject.add_all
|
|
38
41
|
`git commit -m "created empty rails app with some subprojects"`
|
|
39
42
|
end
|
|
@@ -70,9 +73,90 @@ module Externals
|
|
|
70
73
|
assert File.exists?('.git')
|
|
71
74
|
|
|
72
75
|
assert File.exists?('.gitignore')
|
|
73
|
-
mp = Ext.new.main_project
|
|
74
76
|
|
|
75
|
-
|
|
77
|
+
ext = Ext.new
|
|
78
|
+
main_project = ext.main_project
|
|
79
|
+
engines = ext.subproject("engines")
|
|
80
|
+
|
|
81
|
+
main_project.assert_e_dne_i_ni proc{|a|assert(a)},%w(foreign_key_migrations redhillonrails_core acts_as_list)
|
|
82
|
+
|
|
83
|
+
# let's test switching branches via altering .externals and running "ext up"
|
|
84
|
+
assert_equal "master", main_project.current_branch
|
|
85
|
+
assert_equal "edge", engines.current_branch
|
|
86
|
+
assert_equal "edge", ext.configuration["vendor/plugins/engines"]["branch"]
|
|
87
|
+
|
|
88
|
+
#let's create a branch for the main project called 'new_branch' and a
|
|
89
|
+
#branch for the engines subproject called 'new_branch' and make sure
|
|
90
|
+
#that checking one out and doing "ext up" correctly changes the branch
|
|
91
|
+
#of the subproject
|
|
92
|
+
|
|
93
|
+
`git push origin master:new_branch`
|
|
94
|
+
raise unless $? == 0
|
|
95
|
+
|
|
96
|
+
`git fetch origin`
|
|
97
|
+
raise unless $? == 0
|
|
98
|
+
|
|
99
|
+
`git checkout --track -b new_branch origin/new_branch`
|
|
100
|
+
raise unless $? == 0
|
|
101
|
+
|
|
102
|
+
assert_equal "new_branch", main_project.current_branch
|
|
103
|
+
assert_equal "edge", engines.current_branch
|
|
104
|
+
|
|
105
|
+
Dir.chdir File.join(%w(vendor plugins engines)) do
|
|
106
|
+
`git push origin master:new_branch`
|
|
107
|
+
raise unless $? == 0
|
|
108
|
+
end
|
|
109
|
+
assert_equal "new_branch", main_project.current_branch
|
|
110
|
+
|
|
111
|
+
#update .externals
|
|
112
|
+
ext.configuration["vendor/plugins/engines"]["branch"] = "new_branch"
|
|
113
|
+
ext.configuration.write
|
|
114
|
+
|
|
115
|
+
ext = Ext.new
|
|
116
|
+
assert_equal "new_branch", ext.configuration["vendor/plugins/engines"]["branch"]
|
|
117
|
+
|
|
118
|
+
`git add .externals`
|
|
119
|
+
raise unless $? == 0
|
|
120
|
+
`git commit -m "changed branch on engines subproject"`
|
|
121
|
+
raise unless $? == 0
|
|
122
|
+
`git push`
|
|
123
|
+
raise unless $? == 0
|
|
124
|
+
|
|
125
|
+
`git checkout master`
|
|
126
|
+
raise unless $? == 0
|
|
127
|
+
|
|
128
|
+
assert_equal "master", main_project.current_branch
|
|
129
|
+
assert_equal "edge", engines.current_branch
|
|
130
|
+
|
|
131
|
+
Ext.run "up"
|
|
132
|
+
assert_equal "master", main_project.current_branch
|
|
133
|
+
assert_equal "edge", engines.current_branch
|
|
134
|
+
|
|
135
|
+
`git checkout new_branch`
|
|
136
|
+
assert_equal "new_branch", main_project.current_branch
|
|
137
|
+
assert_equal "edge", engines.current_branch
|
|
138
|
+
|
|
139
|
+
Ext.run "up"
|
|
140
|
+
assert_equal "new_branch", main_project.current_branch
|
|
141
|
+
assert_equal "new_branch", engines.current_branch
|
|
142
|
+
|
|
143
|
+
`git checkout master`
|
|
144
|
+
assert_equal "master", main_project.current_branch
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
#now let's check it out again to test "ext checkout -b new_branch"
|
|
148
|
+
`rm -rf rails_app`
|
|
149
|
+
raise unless $? == 0
|
|
150
|
+
|
|
151
|
+
Ext.run "checkout", "--git", "-b", "new_branch", source
|
|
152
|
+
|
|
153
|
+
Dir.chdir 'rails_app' do
|
|
154
|
+
ext = Ext.new
|
|
155
|
+
main_project = ext.main_project
|
|
156
|
+
engines = ext.subproject("engines")
|
|
157
|
+
|
|
158
|
+
assert_equal "new_branch", main_project.current_branch
|
|
159
|
+
assert_equal "new_branch", engines.current_branch
|
|
76
160
|
end
|
|
77
161
|
end
|
|
78
162
|
end
|
|
@@ -115,5 +199,6 @@ module Externals
|
|
|
115
199
|
end
|
|
116
200
|
end
|
|
117
201
|
end
|
|
202
|
+
|
|
118
203
|
end
|
|
119
204
|
end
|
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: 19
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 1.0.
|
|
9
|
+
- 2
|
|
10
|
+
version: 1.0.2
|
|
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-
|
|
18
|
+
date: 2011-09-08 00:00:00 -07:00
|
|
19
19
|
default_executable: ext
|
|
20
20
|
dependencies: []
|
|
21
21
|
|