ext 1.1.3 → 2.0.0

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.
@@ -2,20 +2,11 @@ require File.join(File.dirname(__FILE__), '..', 'project')
2
2
 
3
3
  module Externals
4
4
  class SvnProject < Project
5
- def default_branch
6
- raise "There is no default_branch for SvnProject"
7
- end
8
-
9
- public
10
- def co *args
5
+ def co *_args
11
6
  # delete path if empty
12
- rmdir_ie path unless path == "."
7
+ rmdir_if_empty_ie path unless path == "."
13
8
 
14
- dest = path
15
- dest = '' if dest == '.'
16
- dest = "\"#{dest}\"" if dest && !dest.empty?
17
-
18
- if File.exist?(dest)
9
+ if path != "." && File.exist?(path)
19
10
  up
20
11
  else
21
12
  opts = resolve_opts "co"
@@ -27,10 +18,16 @@ module Externals
27
18
  url = [url, branch].join("/")
28
19
  end
29
20
 
21
+ dest = path
22
+ dest = '' if dest == '.'
23
+ dest = "\"#{dest}\"" if dest && !dest.empty?
24
+
30
25
  puts(svncocmd = "svn #{opts} co #{url} #{dest}")
31
26
  puts `#{svncocmd}`
32
27
  unless $? == 0
33
- raise
28
+ # :nocov:
29
+ raise "Failed to run #{svncocmd}"
30
+ # :nocov:
34
31
  end
35
32
 
36
33
  change_to_revision "co"
@@ -48,7 +45,7 @@ module Externals
48
45
  end
49
46
  end
50
47
 
51
- def ex *args
48
+ def ex *_args
52
49
  # delete path if empty
53
50
  rmdir_ie path unless path == "."
54
51
 
@@ -64,14 +61,17 @@ module Externals
64
61
  end
65
62
 
66
63
  if revision
64
+ # TODO: test (or delete) this code path!
65
+ # :nocov:
67
66
  url += "@#{revision}"
67
+ # :nocov:
68
68
  end
69
69
 
70
70
  puts(svncocmd = "svn #{scm_opts_ex} export #{url} #{dest}")
71
71
  puts `#{svncocmd}`
72
72
  end
73
73
 
74
- def switch branch_name, options = {}
74
+ def switch branch_name, _options = {}
75
75
  require_repository
76
76
 
77
77
  if current_branch != branch_name
@@ -79,15 +79,17 @@ module Externals
79
79
  url = [repository, branch_name].join("/")
80
80
  `svn #{scm_opts} switch #{url}`
81
81
  unless $? == 0
82
+ # :nocov:
82
83
  raise "Could not switch to #{url}"
84
+ # :nocov:
83
85
  end
84
86
  end
85
87
  end
86
88
  end
87
89
 
88
- def up *args
90
+ def up *_args
89
91
  # delete path if empty
90
- rmdir_if_empty_ie path
92
+ rmdir_if_empty_ie path unless path == "."
91
93
 
92
94
  if File.exist?(path)
93
95
  puts "updating #{path}:"
@@ -108,35 +110,41 @@ module Externals
108
110
  end
109
111
  end
110
112
 
111
- def st *args
113
+ def st *_args
114
+ # TODO: test (or delete) this code path!
115
+ # :nocov:
112
116
  puts "\nstatus for #{path}:"
113
117
  Dir.chdir path do
114
118
  puts `svn #{scm_opts_st} status`
115
119
  end
120
+ # :nocov:
116
121
  end
117
122
 
118
123
  def self.scm_path? path
124
+ # TODO: test (or delete) this code path!
125
+ # :nocov:
119
126
  return true if path =~ /^svn(\+ssh)?:/
120
127
 
121
128
  # Look for http(s)://svn.*/*
122
- if path =~ /^https?:\/\/([\w+\-]+)\.(?:[\w+\-]+\.)*[\w\-]+(?:\/|$)/
129
+ if path =~ /^https?:\/\/([\w+-]+)\.(?:[\w+-]+\.)*[\w-]+(?:\/|$)/
123
130
  return true if $1.downcase == "svn"
124
131
  end
125
132
 
126
133
  # Look for http(s)://*/*svn*/
127
- if path =~ /^https?:\/\/(?:[\w+\-]+\.?)+\/(\w+)/
134
+ if path =~ /^https?:\/\/(?:[\w+-]+\.?)+\/(\w+)/
128
135
  return true if $1.downcase.include? "svn"
129
136
  end
130
137
 
131
138
  false
139
+ # :nocov:
132
140
  end
133
141
 
134
142
  def self.fill_in_opts opts, main_options, sub_options, options = {}
135
143
  opts.on("--svn", "--subversion",
136
- Integer,
137
- *"same as '--scm svn' Uses subversion to
144
+ Integer,
145
+ *"same as '--scm svn' Uses subversion to
138
146
  checkout/export the main project".lines_by_width(options[:summary_width])
139
- ) {sub_options[:scm] = main_options[:scm] = 'svn'}
147
+ ) {sub_options[:scm] = main_options[:scm] = 'svn'}
140
148
  end
141
149
 
142
150
  def self.detected?
@@ -144,13 +152,16 @@ module Externals
144
152
  end
145
153
 
146
154
  #this is a test helper method
155
+ # TODO: can we move it to the test suite, then?
147
156
  def self.add_all
157
+ # :nocov:
148
158
  status = `svn st`
149
159
 
150
160
  status.split("\n").grep(/^\?/).each do |to_add|
151
- puts `svn add #{to_add.gsub(/^\?\s*/,"")}`
161
+ puts `svn add #{to_add.gsub(/^\?\s*/, "")}`
152
162
  raise unless $? == 0
153
163
  end
164
+ # :nocov:
154
165
  end
155
166
 
156
167
  def ignore_contains? path
@@ -162,12 +173,16 @@ module Externals
162
173
 
163
174
  branch = info_url.downcase.gsub(/\/+/, "/").gsub(repository.downcase.gsub(/\/+/, "/"), "")
164
175
  if branch == repository
176
+ # :nocov:
165
177
  raise "Could not determine branch from URL #{info_url}.
166
178
  Does not appear have a substring of #{repository}"
179
+ # :nocov:
167
180
  end
168
181
  if branch !~ /^\//
182
+ # :nocov:
169
183
  raise "Was expecting the branch and repository to be separated by '/'
170
184
  Please file an issue about this at http://github.com/azimux/externals"
185
+ # :nocov:
171
186
  end
172
187
  branch.gsub(/^\//, "")
173
188
  end
@@ -175,18 +190,24 @@ module Externals
175
190
  def self.extract_repository url, branch
176
191
  repository = url.gsub(branch, "")
177
192
  if url == repository
193
+ # :nocov:
178
194
  raise "Could not determine repository from URL #{info_url}.
179
195
  Does not appear to have the branch #{branch} as a substring"
196
+ # :nocov:
180
197
  end
181
198
  if repository !~ /\/$/
199
+ # :nocov:
182
200
  raise "Was expecting the branch and repository to be separated by '/'
183
201
  Please file an issue about this at http://github.com/azimux/externals"
202
+ # :nocov:
184
203
  end
204
+
185
205
  repository.gsub(/\/$/, "")
186
206
  end
187
207
 
188
208
  def require_repository
189
209
  if repository.nil? || repository.empty?
210
+ # :nocov:
190
211
  url = info_url
191
212
  info_url = "svn+ssh://server/path/repository" unless url
192
213
  puts "to use any branching features with a subversion project, the
@@ -202,7 +223,9 @@ You might need to change your .externals file to contain something like this:
202
223
  scm = svn
203
224
  repository = #{info_url}
204
225
  "
226
+
205
227
  raise "Cannot use subversion branching features without a repository in .externals file"
228
+ # :nocov:
206
229
  end
207
230
  end
208
231
 
@@ -227,14 +250,18 @@ repository = #{info_url}
227
250
  child = File.basename(path).strip
228
251
 
229
252
  ir = ignore_rows(path)
230
- rows = ir.select {|row| row.strip != child}
253
+ rows = ir.reject {|row| row.strip == child}
231
254
 
232
255
  if rows.size == ir.size
256
+ # :nocov:
233
257
  raise "row not found matching #{path} in svn propget svn:ignore"
258
+ # :nocov:
234
259
  end
235
260
 
236
261
  if ir.size - rows.size != 1
262
+ # :nocov:
237
263
  raise "More than one row found matching #{path} in svn propget svn:ignore"
264
+ # :nocov:
238
265
  end
239
266
 
240
267
  Dir.chdir(parent) do
@@ -243,7 +270,7 @@ repository = #{info_url}
243
270
  end
244
271
 
245
272
  def ignore_rows(path)
246
- rows = ignore_text(path).split(/\n/)
273
+ rows = ignore_text(path).split("\n")
247
274
 
248
275
  rows.delete_if {|row| row =~ /^\s*$/}
249
276
 
@@ -270,7 +297,9 @@ repository = #{info_url}
270
297
  if `svn #{scm_opts} info` =~ /^\s*URL:\s*([^\s]+)\s*$/
271
298
  $1
272
299
  else
300
+ # :nocov:
273
301
  raise "Could not get URL from svn info"
302
+ # :nocov:
274
303
  end
275
304
  end
276
305
 
@@ -279,6 +308,5 @@ repository = #{info_url}
279
308
  self.class.info_url scm_opts
280
309
  end
281
310
  end
282
-
283
311
  end
284
312
  end
data/version.rb ADDED
@@ -0,0 +1,4 @@
1
+ module Externals
2
+ VERSION = "2.0.0".freeze
3
+ MINIMUM_RUBY_VERSION = [">= 2.7.0", "< 3.4"].freeze
4
+ end
metadata CHANGED
@@ -1,43 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-10 00:00:00.000000000 Z
11
+ date: 2026-07-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |-
14
- Provides an SCM agnostic way to manage subprojects with a workflow similar
15
- to the scm:externals feature of subversion. It's particularly useful for rails
16
- projects that have some plugins managed by svn and some managed by git.
17
-
18
- For example, "ext install git://github.com/rails/rails.git" from within a rails
19
- application directory will realize that this belongs in the vendor/rails folder.
20
- It will also realize that this URL is a git repository and clone it into that
21
- folder.
22
-
23
- It will also add the vendor/rails folder to the ignore feature for the SCM of
24
- the main project. Let's say that the main project is being managed by
25
- subversion. In that case it adds "rails" to the svn:ignore property of the
26
- vendor folder. It also adds the URL to the .externals file so that when this
27
- project is checked out via "ext checkout" it knows where to fetch the
28
- subprojects.
29
-
30
- There are several other useful commands, such as init, touch_emptydirs, add_all,
31
- export, status. There's a tutorial at http://nopugs.com/ext-tutorial
32
-
33
- The reason I made this project is that I was frustrated by two things:
34
-
35
- 1. In my opinion, the workflow for svn:externals is far superior to
36
- git-submodule.
37
-
38
- 2. Even if git-submodule was as useful as svn:externals, I would still like a
39
- uniform way to fetch all of the subprojects regardless of the SCM used to manage
40
- the main project.
13
+ description:
41
14
  email: azimux@gmail.com
42
15
  executables:
43
16
  - ext
@@ -45,43 +18,28 @@ extensions: []
45
18
  extra_rdoc_files: []
46
19
  files:
47
20
  - CHANGELOG
48
- - MIT_LICENSE.txt
21
+ - LICENSE-MPL-2.0.txt
22
+ - LICENSE.txt
49
23
  - README
50
- - Rakefile
51
24
  - bin/ext
52
25
  - lib/externals/command.rb
53
26
  - lib/externals/configuration/configuration.rb
54
27
  - lib/externals/ext.rb
55
28
  - lib/externals/extensions/file_utils.rb
56
29
  - lib/externals/extensions/string.rb
57
- - lib/externals/extensions/symbol.rb
58
30
  - lib/externals/project.rb
59
- - lib/externals/project_types/rails.rb
60
31
  - lib/externals/scms/git_project.rb
61
32
  - lib/externals/scms/svn_project.rb
62
- - test/setup/empty_plugin.svn.gz
63
- - test/setup/foreign_key_migrations.svn.gz
64
- - test/setup/redhillonrails_core.svn.gz
65
- - test/test_checkout_git.rb
66
- - test/test_checkout_with_subprojects_git.rb
67
- - test/test_checkout_with_subprojects_svn.rb
68
- - test/test_file_utils_extensions.rb
69
- - test/test_freeze_to_revision.rb
70
- - test/test_git_project_extract_name.rb
71
- - test/test_help.rb
72
- - test/test_init_git.rb
73
- - test/test_out_of_date_git_subproject.rb
74
- - test/test_projects.rb
75
- - test/test_rails_detection.rb
76
- - test/test_string_extensions.rb
77
- - test/test_svn_branches.rb
78
- - test/test_touch_emptydirs.rb
79
- - test/test_version.rb
80
- homepage: http://nopugs.com/ext-tutorial
33
+ - version.rb
34
+ homepage: https://github.com/azimux/externals
81
35
  licenses:
82
- - MIT
83
- metadata: {}
84
- post_install_message:
36
+ - MPL-2.0
37
+ metadata:
38
+ homepage_uri: https://github.com/azimux/externals
39
+ source_code_uri: https://github.com/azimux/externals
40
+ changelog_uri: https://github.com/azimux/externals/blob/main/CHANGELOG.md
41
+ rubygems_mfa_required: 'true'
42
+ post_install_message:
85
43
  rdoc_options: []
86
44
  require_paths:
87
45
  - lib
@@ -89,36 +47,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
47
  requirements:
90
48
  - - ">="
91
49
  - !ruby/object:Gem::Version
92
- version: '0'
50
+ version: 2.7.0
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.4'
93
54
  required_rubygems_version: !ruby/object:Gem::Requirement
94
55
  requirements:
95
56
  - - ">="
96
57
  - !ruby/object:Gem::Version
97
58
  version: '0'
98
59
  requirements: []
99
- rubyforge_project: ext
100
- rubygems_version: 2.7.8
101
- signing_key:
60
+ rubygems_version: 3.5.22
61
+ signing_key:
102
62
  specification_version: 4
103
63
  summary: Provides an SCM agnostic way to manage subprojects with a workflow similar
104
- to the svn:externals feature of subversion. It's particularly useful for rails
105
- projects that have some plugins managed by svn and some managed by git.
106
- test_files:
107
- - test/test_checkout_git.rb
108
- - test/test_checkout_with_subprojects_git.rb
109
- - test/test_checkout_with_subprojects_svn.rb
110
- - test/test_file_utils_extensions.rb
111
- - test/test_freeze_to_revision.rb
112
- - test/test_git_project_extract_name.rb
113
- - test/test_help.rb
114
- - test/test_init_git.rb
115
- - test/test_out_of_date_git_subproject.rb
116
- - test/test_projects.rb
117
- - test/test_rails_detection.rb
118
- - test/test_string_extensions.rb
119
- - test/test_svn_branches.rb
120
- - test/test_touch_emptydirs.rb
121
- - test/test_version.rb
122
- - test/setup/empty_plugin.svn.gz
123
- - test/setup/foreign_key_migrations.svn.gz
124
- - test/setup/redhillonrails_core.svn.gz
64
+ to the svn:externals feature of subversion instead of that of git submodules.
65
+ test_files: []
data/MIT_LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2008-2009 Miles Georgi, Azimux.com, nopugs.com Consulting
2
-
3
- Permission is hereby granted, free of charge, to any person
4
- obtaining a copy of this software and associated documentation
5
- files (the "Software"), to deal in the Software without
6
- restriction, including without limitation the rights to use,
7
- copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- copies of the Software, and to permit persons to whom the
9
- Software is furnished to do so, subject to the following
10
- conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile DELETED
@@ -1,77 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rdoc/task'
4
- require 'rubygems/package_task'
5
- require 'find'
6
-
7
- root_dir = File.dirname(__FILE__)
8
-
9
- $LOAD_PATH << File.join(root_dir, 'lib')
10
-
11
- require File.join(root_dir, 'lib', 'externals', 'ext')
12
-
13
- Rake::TestTask.new('test') do |task|
14
- task.libs = [File.expand_path('lib'),File.expand_path('test/support')]
15
- task.pattern = './test/test_*.rb'
16
- #task.warning = true
17
- end
18
-
19
- gem_specification = Gem::Specification.new do |specification|
20
- specification.name = 'ext'
21
- specification.version = Externals::VERSION
22
- specification.platform = Gem::Platform::RUBY
23
- specification.rubyforge_project = 'ext'
24
-
25
- specification.summary =
26
- %{Provides an SCM agnostic way to manage subprojects with a workflow similar
27
- to the svn:externals feature of subversion. It's particularly useful for rails
28
- projects that have some plugins managed by svn and some managed by git.}
29
- specification.description =
30
- %{Provides an SCM agnostic way to manage subprojects with a workflow similar
31
- to the scm:externals feature of subversion. It's particularly useful for rails
32
- projects that have some plugins managed by svn and some managed by git.
33
-
34
- For example, "ext install git://github.com/rails/rails.git" from within a rails
35
- application directory will realize that this belongs in the vendor/rails folder.
36
- It will also realize that this URL is a git repository and clone it into that
37
- folder.
38
-
39
- It will also add the vendor/rails folder to the ignore feature for the SCM of
40
- the main project. Let's say that the main project is being managed by
41
- subversion. In that case it adds "rails" to the svn:ignore property of the
42
- vendor folder. It also adds the URL to the .externals file so that when this
43
- project is checked out via "ext checkout" it knows where to fetch the
44
- subprojects.
45
-
46
- There are several other useful commands, such as init, touch_emptydirs, add_all,
47
- export, status. There's a tutorial at http://nopugs.com/ext-tutorial
48
-
49
- The reason I made this project is that I was frustrated by two things:
50
-
51
- 1. In my opinion, the workflow for svn:externals is far superior to
52
- git-submodule.
53
-
54
- 2. Even if git-submodule was as useful as svn:externals, I would still like a
55
- uniform way to fetch all of the subprojects regardless of the SCM used to manage
56
- the main project.}
57
-
58
- specification.author = "Miles Georgi"
59
- specification.email = "azimux@gmail.com"
60
- specification.homepage = "http://nopugs.com/ext-tutorial"
61
-
62
- specification.test_files = FileList['test/test_*.rb', 'test/setup/*.gz']
63
-
64
- specification.bindir = "bin"
65
- specification.executables = ['ext']
66
- specification.default_executable = "ext"
67
-
68
- specification.licenses = ['MIT']
69
-
70
- specification.files = ['Rakefile', 'README', 'MIT_LICENSE.txt', 'CHANGELOG'] +
71
- FileList['lib/**/*.rb']
72
- #specification.require_path = 'lib'
73
- end
74
-
75
- Gem::PackageTask.new(gem_specification) do |package|
76
- package.need_zip = package.need_tar = false
77
- end
@@ -1,7 +0,0 @@
1
- unless Symbol.instance_methods.include?(:to_proc)
2
- class Symbol
3
- def to_proc
4
- proc { |*args| args[0].send(self, *args[1...args.size]) }
5
- end
6
- end
7
- end
@@ -1,35 +0,0 @@
1
- module Externals
2
- module RailsProjectType
3
- class DefaultPathCalculator
4
- def default_path name
5
- if name
6
- if name == 'rails'
7
- File.join("vendor","rails")
8
- else
9
- File.join("vendor","plugins", name)
10
- end
11
- else
12
- raise "couldn't figure out project name..."
13
- end
14
- end
15
- end
16
- end
17
-
18
- class RailsDetector
19
- def self.detected?
20
- application_path = File.join('config', 'application.rb')
21
- if File.exist?(application_path)
22
- open(application_path) do |f|
23
- f.read =~ /<\s*Rails::Application/
24
- end
25
- else
26
- boot_path = File.join('config', 'boot.rb')
27
- if File.exist?(boot_path)
28
- open(boot_path) do |f|
29
- f.read =~ /^\s*module\s+Rails/
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
Binary file
Binary file
@@ -1,32 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') if $0 == __FILE__
2
- require 'ext_test_case'
3
- require 'externals/ext'
4
- require 'basic_git_repository'
5
-
6
- module Externals
7
- module Test
8
- class TestCheckoutGit < ::Test::Unit::TestCase
9
- include ExtTestCase
10
-
11
- def test_checkout
12
- repository = BasicGitRepository.new
13
- repository.prepare
14
-
15
- assert File.exist?(repository.clean_dir)
16
-
17
- workdir = File.join(root_dir, 'test', "tmp", "workdir")
18
- mkdir_p workdir
19
-
20
- Dir.chdir workdir do
21
- if File.exist?(repository.name)
22
- rm_r repository.name
23
- end
24
-
25
- Ext.run "checkout", "--git", repository.clean_dir
26
-
27
- assert File.exist?(File.join(repository.name, "readme.txt"))
28
- end
29
- end
30
- end
31
- end
32
- end