squared 0.5.3 → 0.5.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.
@@ -113,56 +113,41 @@ module Squared
113
113
  def __repo__(**kwargs)
114
114
  kwargs.delete(:parallel) if env('REPO_SYNC', ignore: '0')
115
115
 
116
- namespace(name = task_name('repo')) do |repo|
116
+ namespace task_name('repo') do |ns|
117
+ path = ns.scope.path
117
118
  branch = env('REPO_MANIFEST') || Repo.read_manifest(root)
118
119
  target = branch || manifest
120
+ cmd = nil
119
121
  stage = nil
120
- failfast = true
121
- cmd = []
122
- newline = ARGV.index { |val| val.start_with?('repo:') }.to_i > 0
123
- parse_opts = lambda do |args|
124
- args.to_a.each do |val|
125
- case val
126
- when 'no-fail'
127
- failfast = false
128
- when 'force'
129
- cmd << '--force-checkout'
130
- when 'rebase'
131
- cmd << '--rebase'
132
- when 'detach'
133
- cmd << '--detach'
134
- when 'gc'
135
- cmd << '--auto-gc'
136
- when 'no-update'
137
- cmd << '--no-manifest-update'
138
- end
139
- end
140
- end
122
+ opts = %w[force rebase detach submodules fail no-update gc]
123
+ newline = ARGV.any?(/^repo:/)
141
124
  desc = lambda do |val, alt = nil|
142
125
  if (ver = branch || alt)
143
- val = val.sub('{0}', 'opts*=force,rebase,detach,gc,no-update,no-fail')
144
- task_desc(task_name('repo'), val, ver)
126
+ val = val.sub('{0}', "opts*=#{opts.join(',')}")
127
+ task_desc(path, val, ver)
145
128
  else
146
129
  task_desc 'inactive'
147
130
  end
148
131
  end
149
132
 
150
133
  desc.call('all[{0}]')
151
- task 'all', [:opts] do |_, args|
152
- parse_opts.call(args)
134
+ task 'all' do |_, args|
135
+ cmd ||= repo_opts args
153
136
  stage ||= 'all'
154
- repo['sync'].invoke
155
- next if env('REPO_DRYRUN', equals: '2')
137
+ ns['sync'].invoke
138
+ next if env('REPO_STAGE', equals: '1')
156
139
 
157
140
  @project.select do |_, proj|
158
141
  next unless proj.enabled?(proj.workspace.baseref)
159
142
 
160
143
  proj.depend(sync: true) if proj.depend?
161
- proj.build? unless env('REPO_DRYRUN', ignore: '0')
144
+ next if env('REPO_STAGE', equals: '2')
145
+
146
+ proj.build?
162
147
  end
163
148
  .each_value do |proj|
164
149
  proj.build(sync: true)
165
- next unless proj.dev? && proj.copy?
150
+ next unless proj.dev? && proj.copy? && !env('REPO_STAGE', equals: '3')
166
151
 
167
152
  if (ws = proj.workspace).task_defined?(target = task_join(proj.name, 'copy'))
168
153
  task_invoke(target, **ws.invokeargs)
@@ -172,40 +157,57 @@ module Squared
172
157
  end
173
158
  end
174
159
 
175
- desc.call("init[manifest?=#{target},{0}]", target)
176
- task 'init', [:manifest, :opts] do |_, args|
177
- parse_opts.call(args)
160
+ desc.call("init[manifest?=#{target},groups?,{0}]", target)
161
+ task 'init' do |_, args|
162
+ args = args.to_a
163
+ u = env('REPO_URL') || manifest_url
164
+ m = args.first && !opts.include?(args.first) ? args.shift : target
165
+ g = case (g = env('REPO_GROUPS'))
166
+ when '0', 'false'
167
+ nil
168
+ else
169
+ g || (args.first && !opts.include?(args.first) ? args.shift : nil)
170
+ end
171
+ cmd = repo_opts args
172
+ s = case (s = env('REPO_SUBMODULES'))
173
+ when '0', 'false'
174
+ false
175
+ else
176
+ s ? true : cmd.include?('--fetch-submodules')
177
+ end
178
178
  stage = 'init'
179
179
  puts if newline
180
- Common::System.shell("repo init -u #{env('REPO_URL') || manifest_url} -m #{args.manifest || target}.xml",
181
- chdir: root)
182
- repo['all'].invoke
180
+ args = ["-u #{u}", "-m #{m}.xml"]
181
+ args << "-g #{g}" if g
182
+ args << '--submodules' if s
183
+ Common::System.shell("#{repo_bin} init #{args.join(' ')}", chdir: root)
184
+ next if env('REPO_STAGE', equals: '0')
185
+
186
+ ns['all'].invoke
183
187
  end
184
188
 
185
189
  desc.call('sync[{0}]')
186
- task 'sync', [:opts] do |_, args|
187
- unless branch || stage == 'init'
188
- raise_error('repo not initialized', hint: task_name('repo:init'), kind: LoadError)
189
- end
190
- parse_opts.call(args)
190
+ task 'sync' do |t, args|
191
+ raise_error 'repo not initialized' unless branch || stage == 'init'
192
+ cmd ||= repo_opts args
191
193
  cmd << "-j#{ENV.fetch('REPO_JOBS', Rake::CpuCounter.count)}"
192
- cmd << '--fail-fast' if failfast
193
- puts if newline && stage != 'init'
194
+ puts unless !newline || stage == 'init'
194
195
  begin
195
- Common::System.shell("repo sync #{cmd.join(' ')}", chdir: root, exception: failfast)
196
+ Common::System.shell("#{repo_bin} sync #{cmd.join(' ')}", chdir: root,
197
+ exception: cmd.include?('--fail-fast'))
196
198
  rescue Errno::ENOENT => e
197
199
  emphasize(e, title: root)
198
200
  raise
199
201
  rescue StandardError => e
200
- emphasize(e, title: "rake stash #{task_name(task_join('repo', stage || 'sync'))}")
202
+ emphasize(e, title: "rake stash #{t.name}")
201
203
  raise
202
204
  end
203
205
  end
204
206
 
205
207
  series.sync.append(
206
- task_join(name, 'all'),
207
- task_join(name, 'init'),
208
- task_join(name, 'sync')
208
+ task_join(path, 'all'),
209
+ task_join(path, 'init'),
210
+ task_join(path, 'sync')
209
211
  )
210
212
  end
211
213
  end
@@ -221,6 +223,31 @@ module Squared
221
223
  )
222
224
  end
223
225
 
226
+ def repo_opts(args)
227
+ ret = []
228
+ args.to_a.each do |val|
229
+ case val
230
+ when 'force'
231
+ ret << '--force-checkout'
232
+ when 'rebase', 'detach'
233
+ ret << "--#{val}"
234
+ when 'submodules'
235
+ ret << '--fetch-submodules'
236
+ when 'fail'
237
+ ret << '--fail-fast'
238
+ when 'no-update'
239
+ ret << '--no-manifest-update'
240
+ when 'gc'
241
+ ret << '--auto-gc'
242
+ end
243
+ end
244
+ ret
245
+ end
246
+
247
+ def repo_bin
248
+ Common::System.shell_bin('repo')
249
+ end
250
+
224
251
  def repo?
225
252
  !manifest_url.nil? && (repo_install? || @repo_override == true)
226
253
  end
data/squared.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = %q{Rake task generator for managing multi-language workspaces.}
12
12
  spec.description = %q{Rake task generator for managing multi-language workspaces.}
13
- spec.homepage = "https://github.com/anpham6/squared"
13
+ spec.homepage = "https://github.com/anpham6/squared-ruby"
14
14
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
15
15
  spec.licenses = ["BSD-3-Clause"]
16
16
 
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.metadata["documentation_uri"] = "https://squared.readthedocs.io"
20
20
 
21
21
  spec.files = Dir["lib/**/*"] +
22
- %w[CHANGELOG.md LICENSE README.md README.ruby.md squared.gemspec]
22
+ %w[CHANGELOG.md LICENSE README.md squared.gemspec]
23
23
  spec.bindir = "exe"
24
24
  spec.executables = []
25
25
  spec.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -75,7 +75,6 @@ files:
75
75
  - CHANGELOG.md
76
76
  - LICENSE
77
77
  - README.md
78
- - README.ruby.md
79
78
  - lib/squared.rb
80
79
  - lib/squared/app.rb
81
80
  - lib/squared/common.rb
@@ -104,12 +103,12 @@ files:
104
103
  - lib/squared/workspace/support/base.rb
105
104
  - lib/squared/workspace/support/data.rb
106
105
  - squared.gemspec
107
- homepage: https://github.com/anpham6/squared
106
+ homepage: https://github.com/anpham6/squared-ruby
108
107
  licenses:
109
108
  - BSD-3-Clause
110
109
  metadata:
111
- homepage_uri: https://github.com/anpham6/squared
112
- source_code_uri: https://github.com/anpham6/squared
110
+ homepage_uri: https://github.com/anpham6/squared-ruby
111
+ source_code_uri: https://github.com/anpham6/squared-ruby
113
112
  documentation_uri: https://squared.readthedocs.io
114
113
  rdoc_options: []
115
114
  require_paths: