squared 0.5.3 → 0.5.4

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,35 +113,17 @@ 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
+ newline = ARGV.any?(/^repo:/)
141
123
  desc = lambda do |val, alt = nil|
142
124
  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)
125
+ val = val.sub('{0}', 'opts*=force,rebase,detach,fail,no-update,gc')
126
+ task_desc(path, val, ver)
145
127
  else
146
128
  task_desc 'inactive'
147
129
  end
@@ -149,20 +131,22 @@ module Squared
149
131
 
150
132
  desc.call('all[{0}]')
151
133
  task 'all', [:opts] do |_, args|
152
- parse_opts.call(args)
134
+ cmd ||= repo_opts args
153
135
  stage ||= 'all'
154
- repo['sync'].invoke
155
- next if env('REPO_DRYRUN', equals: '2')
136
+ ns['sync'].invoke
137
+ next if env('REPO_STAGE', equals: '1')
156
138
 
157
139
  @project.select do |_, proj|
158
140
  next unless proj.enabled?(proj.workspace.baseref)
159
141
 
160
142
  proj.depend(sync: true) if proj.depend?
161
- proj.build? unless env('REPO_DRYRUN', ignore: '0')
143
+ next if env('REPO_STAGE', equals: '2')
144
+
145
+ proj.build?
162
146
  end
163
147
  .each_value do |proj|
164
148
  proj.build(sync: true)
165
- next unless proj.dev? && proj.copy?
149
+ next unless proj.dev? && proj.copy? && !env('REPO_STAGE', equals: '3')
166
150
 
167
151
  if (ws = proj.workspace).task_defined?(target = task_join(proj.name, 'copy'))
168
152
  task_invoke(target, **ws.invokeargs)
@@ -174,38 +158,37 @@ module Squared
174
158
 
175
159
  desc.call("init[manifest?=#{target},{0}]", target)
176
160
  task 'init', [:manifest, :opts] do |_, args|
177
- parse_opts.call(args)
161
+ cmd = repo_opts args
178
162
  stage = 'init'
179
163
  puts if newline
180
164
  Common::System.shell("repo init -u #{env('REPO_URL') || manifest_url} -m #{args.manifest || target}.xml",
181
165
  chdir: root)
182
- repo['all'].invoke
166
+ next if env('REPO_STAGE', equals: '0')
167
+
168
+ ns['all'].invoke
183
169
  end
184
170
 
185
171
  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)
172
+ task 'sync', [:opts] do |t, args|
173
+ raise_error 'repo not initialized' unless branch || stage == 'init'
174
+ cmd ||= repo_opts args
191
175
  cmd << "-j#{ENV.fetch('REPO_JOBS', Rake::CpuCounter.count)}"
192
- cmd << '--fail-fast' if failfast
193
- puts if newline && stage != 'init'
176
+ puts unless !newline || stage == 'init'
194
177
  begin
195
- Common::System.shell("repo sync #{cmd.join(' ')}", chdir: root, exception: failfast)
178
+ Common::System.shell("repo sync #{cmd.join(' ')}", chdir: root, exception: cmd.include?('--fail-fast'))
196
179
  rescue Errno::ENOENT => e
197
180
  emphasize(e, title: root)
198
181
  raise
199
182
  rescue StandardError => e
200
- emphasize(e, title: "rake stash #{task_name(task_join('repo', stage || 'sync'))}")
183
+ emphasize(e, title: "rake stash #{t.name}")
201
184
  raise
202
185
  end
203
186
  end
204
187
 
205
188
  series.sync.append(
206
- task_join(name, 'all'),
207
- task_join(name, 'init'),
208
- task_join(name, 'sync')
189
+ task_join(path, 'all'),
190
+ task_join(path, 'init'),
191
+ task_join(path, 'sync')
209
192
  )
210
193
  end
211
194
  end
@@ -221,6 +204,27 @@ module Squared
221
204
  )
222
205
  end
223
206
 
207
+ def repo_opts(args)
208
+ ret = []
209
+ args.to_a.each do |val|
210
+ case val
211
+ when 'force'
212
+ ret << '--force-checkout'
213
+ when 'rebase'
214
+ ret << '--rebase'
215
+ when 'detach'
216
+ ret << '--detach'
217
+ when 'fail'
218
+ ret << '--fail-fast'
219
+ when 'no-update'
220
+ ret << '--no-manifest-update'
221
+ when 'gc'
222
+ ret << '--auto-gc'
223
+ end
224
+ end
225
+ ret
226
+ end
227
+
224
228
  def repo?
225
229
  !manifest_url.nil? && (repo_install? || @repo_override == true)
226
230
  end
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.6.9
128
+ rubygems_version: 3.6.7
129
129
  specification_version: 4
130
130
  summary: Rake task generator for managing multi-language workspaces.
131
131
  test_files: []