squared 0.4.20 → 0.4.21

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1b0859a60110d19550ba8436a184dbf5475d9103cc844d4bcab7850f2065dc5
4
- data.tar.gz: 887a31b94a66e59b0981f6dcbe64544e1f721b07cb5d82d9a71b8bbbc209820e
3
+ metadata.gz: 4d8a1b2cbf68268501ff6e6d0c93376a695f65d5d39f3e54d51fc3782869080a
4
+ data.tar.gz: d79358deea9e25c69c7c1e43730109b9609bb52949b367f457c972166da38485
5
5
  SHA512:
6
- metadata.gz: 5936f90594961c71af2f1420607ed9c739bd0f182a440aff4c2d474a8bcc9bbb3e0db1c2bfa6ba27052823414d2f6db981f4251a32c09769595b89a561ecfc84
7
- data.tar.gz: 19cc6e69dda54b8d0a3f2cb43606bfb23e25f1f20c071b8e47421156af30d5763162f4a5b14df5f8787a465e53bbabf18b0a9943e7a3c809c31a9825e885e32a
6
+ metadata.gz: 40f3aca8a6df314ce47bfceb7df8c4dffd00a8c05953d4e68ee104f6f33bd15ec8dfcf4d12bc23490d545982376cad0fb4aa17797d3340e120f88ef55907fcfa
7
+ data.tar.gz: 24833ff7f8fc10a50760959bf421371049256df809bcf9a2fe742a3d2faf4f8608cb560cefc8cae7c40eabfcc3dbf579de03f46c836f6057a2d74266329ce75f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.21] - 2025-10-01
4
+
5
+ ### Added
6
+
7
+ - Project base method variable_set was aliased to the name apply.
8
+
9
+ ### Changed
10
+
11
+ - Project base method run visibility was changed to public.
12
+ - OptionPartition method uniq! returns self or nil.
13
+
14
+ ### Fixed
15
+
16
+ - Docker attribute file did not search for nearest config.
17
+ - Project task run did not accept Proc or Method definitions.
18
+ - Gem command options were revalidated to 3.7.2.
19
+ - Bundler command options were revalidated to 2.7.2.
20
+ - Ruby class method bundle did not pass through commands.
21
+ - Ruby task ruby did not separate options and arguments.
22
+ - Pip commands uninstall and freeze did not filter options.
23
+ - Ruby command gem action update did not append packages.
24
+ - OptionPartition did not detect short options with a merged value.
25
+ - Gem commands option version did not use quotes.
26
+ - Git command pull action all used undefined delete_prefix! method.
27
+ - OptionPartition did not delete added values from extras.
28
+ - Python editable projects can override requirements detection.
29
+ - Project session method did delete short options with a merged value.
30
+ - Gem command install did not try to resolve local paths.
31
+ - Ruby commands did not always check for file target exists.
32
+
3
33
  ## [0.4.20] - 2025-09-14
4
34
 
5
35
  ### Changed
@@ -962,6 +992,7 @@
962
992
 
963
993
  - Changelog was created.
964
994
 
995
+ [0.4.21]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.21
965
996
  [0.4.20]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.20
966
997
  [0.4.19]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.19
967
998
  [0.4.18]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.18
data/README.md CHANGED
@@ -105,9 +105,9 @@ Workspace::Application
105
105
  revbuild(include: %w[src/ framework/ types/]) # Synchronous is recommended
106
106
  end
107
107
  .add("squared/sqd", exclude: :git, pass: [:node, "checkout", "bump"]) do # Skip initialize(:node) + squared:checkout:* + squared:bump:*
108
- variable_set :script, "build:sqd" # Override detection
109
- variable_set :depend, false
110
- variable_set :clean, ["build/sqd/"]
108
+ apply :script, "build:sqd" # Override detection
109
+ apply :depend, false #
110
+ apply :clean, ["build/sqd/"] # variable_set (alias)
111
111
  end
112
112
  .with(:docker, only: ["build", "compose"]) do
113
113
  .add("squared", "docker", file: "Dockerfile", context: ".", tag: "latest", registry: "localhost:5000", username: "squared",
@@ -303,7 +303,7 @@ Workspace::Application
303
303
  doc(windows? ? ".\make.bat html" : "make html") # rake android-docs:doc | rake doc:python
304
304
  add("android-docs", "android", venv: "/home/user/.venv") # rake android-docs:depend
305
305
  add("chrome-docs", "chrome", graph: "android", venv: %w[.venv --clear]) do # /workspaces/chrome-docs/.venv
306
- variable_set :dependindex, 1 # Use Poetry for dependencies (optional)
306
+ apply :dependindex, 1 # Use Poetry for dependencies (optional)
307
307
  end
308
308
  end
309
309
  .with(:node) do
@@ -495,22 +495,23 @@ Most project classes will inherit from `Git` which enables these tasks:
495
495
 
496
496
  | Task | Git | Command |
497
497
  | :--------- | :--------------- | :-------------------------------------------- |
498
- | branch | branch | create set delete move copy list edit current |
498
+ | branch | branch | create track delete move copy list current |
499
499
  | checkout | checkout | commit branch track detach path |
500
500
  | commit | commit | add all amend amend-orig fixup |
501
- | diff | diff | head cached branch files between contain |
501
+ | diff | diff | head branch files view between contain |
502
502
  | fetch | fetch | origin remote all |
503
503
  | files | ls-files | cached modified deleted others |
504
- | git | | add blame clean mv rm revert status |
504
+ | git | | add blame clean mv revert rm status |
505
+ | log | log | view between contain |
505
506
  | merge | merge | commit no-commit send |
506
507
  | pull | pull | origin remote all |
507
508
  | rebase | rebase | branch onto send |
508
509
  | refs | ls-remote --refs | heads tags remote |
509
- | reset | reset | commit index patch mode |
510
- | restore | restore | staged worktree |
511
- | rev | rev | commit output |
512
- | show | show | format oneline |
513
- | stash | stash | push pop apply branch drop clear list all |
510
+ | reset | reset | commit index patch mode undo |
511
+ | restore | restore | source staged worktree |
512
+ | rev | rev | commit build output |
513
+ | show | show | format oneline textconv |
514
+ | stash | stash | push pop apply branch drop clear list |
514
515
  | submodule | submodule | status update branch url sync |
515
516
  | switch | switch | branch create detach |
516
517
  | tag | tag | add sign delete list |
@@ -597,6 +598,9 @@ BUILD_${NAME}_VERSION=0.1.0 # publish + detection
597
598
  BANNER=0 # hide banner
598
599
  BANNER_${NAME}=0 #
599
600
 
601
+ VERBOSE=0 # console output level
602
+ VERBOSE_${NAME}=0 # 0,1,2,n
603
+
600
604
  REVBUILD_FORCE=1 # Rebuild all targets
601
605
  REVBUILD_FORCE_${NAME}=1 # Rebuild project
602
606
 
@@ -639,7 +643,7 @@ GIT_AUTOSTASH_${NAME}=0 # rebase (project only)
639
643
  | :--------- | :---------------- | :-------------------------------------------------------------------- |
640
644
  | branch | create | TRACK=0,1,s F|FORCE |
641
645
  | branch | move copy | F|FORCE |
642
- | branch | set delete | COUNT=n |
646
+ | branch | delete | COUNT=n |
643
647
  | branch | global | SYNC |
644
648
  | checkout | branch | DETACH TRACK=s COUNT=n |
645
649
  | checkout | detach | REFLOG=1 |
@@ -189,7 +189,7 @@ module Squared
189
189
  emphasize(args, title: title + (subject ? " #{subject}" : ''), sub: sub, pipe: -1)
190
190
  else
191
191
  msg = [log_title(level, color: color)]
192
- msg << (color ? sub_style(subject, styles: (@theme && @theme[:subject]) || :bold) : subject) if subject
192
+ msg << (color ? sub_style(subject.to_s, styles: (@theme && @theme[:subject]) || :bold) : subject) if subject
193
193
  msg << args.shift if msg.size == 1
194
194
  message(msg.join(' '), *args, hint: hint)
195
195
  end
@@ -223,12 +223,8 @@ module Squared
223
223
  def emphasize(val, title: nil, footer: nil, right: false, cols: nil, sub: nil, pipe: nil,
224
224
  border: @theme && @theme[:border])
225
225
  n = 0
226
- max = ->(v) { n = [n, v.max_by(&:size).size].max }
227
- set = lambda do |v|
228
- ret = as_a(v, :to_s)
229
- max.call(ret)
230
- ret
231
- end
226
+ max = ->(a) { n = [n, a.max_by(&:size).size].max }
227
+ set = ->(s) { Array(s).map(&:to_s).tap { |a| max.call(a) } }
232
228
  title &&= set.call(title)
233
229
  footer &&= set.call(footer)
234
230
  if val.is_a?(::Array)
@@ -213,7 +213,7 @@ module Squared
213
213
  ext[0] = mime
214
214
  elsif file
215
215
  keys.unshift(file)
216
- alt = basepath("#{main}.{#{ext.join(',')}}")
216
+ alt = basepath "#{main}.{#{ext.join(',')}}"
217
217
  file = Dir[alt].first
218
218
  else
219
219
  alt = main
@@ -346,8 +346,8 @@ module Squared
346
346
  basepath(file = main + @ext).to_s rescue file
347
347
  end
348
348
 
349
- def basepath(file)
350
- project ? project.basepath(file) : Pathname.new(file).realdirpath
349
+ def basepath(*args)
350
+ project ? project.basepath(*args) : Pathname.pwd.join(*args)
351
351
  end
352
352
  end
353
353
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.4.20'
4
+ VERSION = '0.4.21'
5
5
  end
@@ -629,7 +629,9 @@ module Squared
629
629
  end
630
630
 
631
631
  def home?
632
- !(proj = find(home)).nil? && proj.enabled?
632
+ return false unless (proj = find(home))
633
+
634
+ proj.enabled?
633
635
  end
634
636
 
635
637
  def windows?
@@ -9,6 +9,7 @@ module Squared
9
9
  module Workspace
10
10
  module Project
11
11
  class Base
12
+ include Comparable
12
13
  include Common::Format
13
14
  include System
14
15
  include Shell
@@ -16,7 +17,6 @@ module Squared
16
17
  include Utils
17
18
  include Support
18
19
  include Rake::DSL
19
- include ::Comparable
20
20
 
21
21
  VAR_SET = %i[parent global script index envname desc dependfile dependindex theme archive env dev prod graph
22
22
  pass only exclude].freeze
@@ -83,6 +83,7 @@ module Squared
83
83
  @name = name.to_s.freeze
84
84
  @project = @path.basename.to_s.freeze
85
85
  @group = group&.to_s.freeze
86
+ @envname = env_key(@name).freeze
86
87
  @depend = kwargs[:depend]
87
88
  @doc = kwargs[:doc]
88
89
  @lint = kwargs[:lint]
@@ -99,7 +100,6 @@ module Squared
99
100
  @children = []
100
101
  @events = hashobj.update({ first: first, last: last, error: error })
101
102
  @as = hashobj
102
- @envname = env_key(@name).freeze
103
103
  @desc = (@name.include?(':') ? @name.split(':').join(ARG[:SPACE]) : @name).freeze
104
104
  @parent = nil
105
105
  @global = false
@@ -196,7 +196,7 @@ module Squared
196
196
  file &&= @workspace.home.join(env('LOG_DIR', ''), file).realdirpath
197
197
  rescue StandardError => e
198
198
  file = nil
199
- warn log_message(Logger::WARN, e) if warning?
199
+ print_error e
200
200
  end
201
201
  log[:progname] ||= @name
202
202
  if (val = env('LOG_LEVEL', ignore: false))
@@ -288,7 +288,7 @@ module Squared
288
288
  end
289
289
 
290
290
  def verbose=(val)
291
- @verbose = case val
291
+ @verbose = case (val = env('VERBOSE', val))
292
292
  when NilClass
293
293
  workspace.verbose
294
294
  when String
@@ -363,7 +363,7 @@ module Squared
363
363
  else
364
364
  force = args.fetch(:force, false)
365
365
  end
366
- unpack(path + dir, uri: tag, digest: digest, ext: ext, force: force)
366
+ unpack(basepath(dir), uri: tag, digest: digest, ext: ext, force: force)
367
367
  end
368
368
  end
369
369
  end
@@ -411,7 +411,6 @@ module Squared
411
411
  kwargs[:group] = group unless kwargs.key?(:group)
412
412
  kwargs[:ref] = ref unless kwargs.key?(:ref)
413
413
  parent = self
414
- proj = nil
415
414
  name = case name
416
415
  when String, Symbol
417
416
  name.to_s
@@ -420,10 +419,9 @@ module Squared
420
419
  end
421
420
  workspace.add(path, name, **kwargs) do
422
421
  __send__ :parent_set, parent
423
- proj = self
422
+ @children << self
423
+ instance_eval(&blk) if block_given?
424
424
  end
425
- @children << proj
426
- proj.instance_eval(&blk) if block_given?
427
425
  self
428
426
  end
429
427
 
@@ -437,7 +435,7 @@ module Squared
437
435
 
438
436
  out = obj.link(self, *args, **kwargs, &blk) if obj.respond_to?(:link)
439
437
  if !out
440
- warn log_message(Logger::WARN, 'link not compatible', subject: obj.to_s, hint: name)
438
+ print_error('link not compatible', subject: obj, hint: name)
441
439
  elsif out.respond_to?(:build)
442
440
  out.build
443
441
  end
@@ -485,6 +483,10 @@ module Squared
485
483
  else
486
484
  cmd, opts, var, flags, extra = args
487
485
  end
486
+ if cmd.is_a?(Proc) || cmd.is_a?(Method)
487
+ run_b(cmd, sync: sync, from: from)
488
+ return
489
+ end
488
490
  if cmd
489
491
  cmd = as_get(cmd, from)
490
492
  opts = compose(opts, script: false) if opts && respond_to?(:compose)
@@ -528,7 +530,7 @@ module Squared
528
530
  on_error(:prereqs, e, exception: true)
529
531
  end
530
532
  end
531
- warn log_message(Logger::WARN, name, 'method not found', subject: 'prereqs', hint: meth)
533
+ print_error(name, 'method not found', subject: 'prereqs', hint: meth)
532
534
  end
533
535
  elsif proj.build?
534
536
  proj.build(sync: sync)
@@ -583,7 +585,7 @@ module Squared
583
585
  else
584
586
  if @clean.is_a?(Enumerable) && !series?(@clean)
585
587
  @clean.each do |val|
586
- entry = path + (val = val.to_s)
588
+ entry = basepath(val = val.to_s)
587
589
  if entry.directory? && val.match?(%r{[\\/]\z})
588
590
  log&.warn "rm -rf #{entry}"
589
591
  rm_rf(entry, verbose: verbose)
@@ -716,7 +718,7 @@ module Squared
716
718
  delete = true
717
719
  end
718
720
  if create
719
- warn log_message(Logger::WARN, 'force remove', subject: name, hint: target)
721
+ print_error('force remove', subject: name, hint: target)
720
722
  target.rmtree
721
723
  target.mkpath
722
724
  end
@@ -807,6 +809,56 @@ module Squared
807
809
  self
808
810
  end
809
811
 
812
+ def run(cmd = @session, var = nil, exception: self.exception, sync: true, from: nil, banner: true, chdir: path,
813
+ interactive: nil, hint: nil, **)
814
+ unless cmd
815
+ print_error('no command given', subject: project, hint: from || 'unknown', pass: true)
816
+ return
817
+ end
818
+ cmd = cmd.target if cmd.is_a?(OptionPartition)
819
+ if interactive && (!@session || !option('y'))
820
+ title, y = case interactive
821
+ when Array
822
+ interactive
823
+ when String
824
+ [interactive, 'N']
825
+ else
826
+ ['Run', 'Y']
827
+ end
828
+ yn = y == 'Y' ? 'Y/n' : 'y/N'
829
+ exit 1 unless confirm("#{title}? [#{sub_style(cmd.to_s, styles: theme[:inline])}] [#{yn}] ", y)
830
+ end
831
+ cmd = session_done cmd
832
+ log&.info cmd
833
+ on :first, from
834
+ begin
835
+ if cmd.match?(/\A[^:]+:[^:]/) && workspace.task_defined?(cmd)
836
+ log&.warn "ENV discarded: #{var}" if var
837
+ task_invoke(cmd, exception: exception, warning: warning?)
838
+ else
839
+ print_item format_banner(hint ? "#{cmd} (#{hint})" : cmd, banner: banner) if sync
840
+ if var != false && (pre = runenv)
841
+ case pre
842
+ when Hash
843
+ var = var.is_a?(Hash) ? pre.merge(var) : pre
844
+ when Enumerable
845
+ cmd = command(*pre.to_a, cmd)
846
+ else
847
+ cmd = command(pre, cmd)
848
+ end
849
+ end
850
+ args = var.is_a?(Hash) ? [var, cmd] : [cmd]
851
+ ret = shell(*args, chdir: chdir, exception: exception)
852
+ end
853
+ rescue StandardError => e
854
+ on_error(from, e, exception: true)
855
+ false
856
+ else
857
+ on :last, from
858
+ ret
859
+ end
860
+ end
861
+
810
862
  def variable_set(key, *args, **kwargs, &blk)
811
863
  if variables.include?(key) || blocks.include?(key)
812
864
  val = case args.size
@@ -856,6 +908,8 @@ module Squared
856
908
  self
857
909
  end
858
910
 
911
+ alias apply variable_set
912
+
859
913
  def enabled?(ref = nil, **)
860
914
  return false if ref && !ref?(ref)
861
915
 
@@ -966,7 +1020,7 @@ module Squared
966
1020
  path.parent.ascend.each do |dir|
967
1021
  target = dir.join(*args)
968
1022
  return target if target.exist?
969
- break if (ascend.is_a?(String) && dir.join(ascend).exist?) || workspace.root == dir || parent&.path == dir
1023
+ break if (ascend && dir.join(ascend).exist?) || workspace.root == dir || parent&.path == dir
970
1024
  end
971
1025
  ret
972
1026
  end
@@ -993,56 +1047,6 @@ module Squared
993
1047
  log_console(*args, pipe: kwargs[:pipe] || pipe)
994
1048
  end
995
1049
 
996
- def run(cmd = @session, var = nil, exception: self.exception, sync: true, from: nil, banner: true, chdir: path,
997
- interactive: nil, hint: nil, **)
998
- unless cmd
999
- warn log_message(Logger::WARN, 'no command given', subject: project, hint: from || 'unknown', pass: true)
1000
- return
1001
- end
1002
- cmd = cmd.target if cmd.is_a?(OptionPartition)
1003
- if interactive && (!@session || !option('y'))
1004
- title, y = case interactive
1005
- when Array
1006
- interactive
1007
- when String
1008
- [interactive, 'N']
1009
- else
1010
- ['Run', 'Y']
1011
- end
1012
- yn = y == 'Y' ? 'Y/n' : 'y/N'
1013
- exit 1 unless confirm("#{title}? [#{sub_style(cmd.to_s, styles: theme[:inline])}] [#{yn}] ", y)
1014
- end
1015
- cmd = session_done cmd
1016
- log&.info cmd
1017
- on :first, from
1018
- begin
1019
- if cmd.match?(/\A[^:]+:[^:]/) && workspace.task_defined?(cmd)
1020
- log&.warn "ENV discarded: #{var}" if var
1021
- task_invoke(cmd, exception: exception, warning: warning?)
1022
- else
1023
- print_item format_banner(hint ? "#{cmd} (#{hint})" : cmd, banner: banner) if sync
1024
- if var != false && (pre = runenv)
1025
- case pre
1026
- when Hash
1027
- var = var.is_a?(Hash) ? pre.merge(var) : pre
1028
- when Enumerable
1029
- cmd = command(*pre.to_a, cmd)
1030
- else
1031
- cmd = command(pre, cmd)
1032
- end
1033
- end
1034
- args = var.is_a?(Hash) ? [var, cmd] : [cmd]
1035
- ret = shell(*args, chdir: chdir, exception: exception)
1036
- end
1037
- rescue StandardError => e
1038
- on_error(from, e, exception: true)
1039
- false
1040
- else
1041
- on :last, from
1042
- ret
1043
- end
1044
- end
1045
-
1046
1050
  def run_s(*cmd, env: nil, sync: true, from: nil, banner: verbose != false, **kwargs)
1047
1051
  on :first, from
1048
1052
  begin
@@ -1241,15 +1245,7 @@ module Squared
1241
1245
  end
1242
1246
 
1243
1247
  def session_delete(*args, target: @session)
1244
- ret = []
1245
- args.each do |val|
1246
- pat = /\A#{Regexp.escape(shell_option(val))}(?: |=|\z)/
1247
- if (key = target.find { |opt| opt.match?(pat) })
1248
- target.delete(key)
1249
- ret << key
1250
- end
1251
- end
1252
- ret
1248
+ OptionPartition.delete(target, *args)
1253
1249
  end
1254
1250
 
1255
1251
  def session_output(*cmd, **kwargs)
@@ -1295,8 +1291,8 @@ module Squared
1295
1291
  puts 'Success'
1296
1292
  end
1297
1293
 
1298
- def print_error(err, loglevel: Logger::WARN, pass: false)
1299
- warn log_message(loglevel, err, pass: pass) if warning?
1294
+ def print_error(*args, loglevel: Logger::WARN, **kwargs)
1295
+ warn log_message(loglevel, *args, **kwargs) if warning?
1300
1296
  end
1301
1297
 
1302
1298
  def print_item(*val)
@@ -1467,7 +1463,7 @@ module Squared
1467
1463
  next if (key = key.to_s).start_with?('__')
1468
1464
 
1469
1465
  if val.nil? || extra || session_arg?(key, target: target)
1470
- session_delete(key, target: target)
1466
+ OptionPartition.delete_key(target, key)
1471
1467
  next if val.nil?
1472
1468
  end
1473
1469
  case val
@@ -1601,7 +1597,7 @@ module Squared
1601
1597
  raise_error("invalid JSON #{kind.name}", val, hint: hint) if kind && !ret.is_a?(kind)
1602
1598
  rescue StandardError => e
1603
1599
  log&.warn e
1604
- warn log_message(Logger::WARN, e, subject: name) if warning?
1600
+ print_error(e, subject: name)
1605
1601
  else
1606
1602
  ret
1607
1603
  end
@@ -1739,7 +1735,7 @@ module Squared
1739
1735
  raise_error 'pathspec not within worktree' unless pass || files.size == proj.size
1740
1736
  files = proj
1741
1737
  end
1742
- files.map { |val| val == '.' ? '.' : shell_quote(path + val) }
1738
+ files.map { |val| val == '.' ? '.' : shell_quote(basepath(val)) }
1743
1739
  end
1744
1740
 
1745
1741
  def matchmap(list, prefix = nil)
@@ -2006,7 +2002,7 @@ module Squared
2006
2002
 
2007
2003
  def dependfile_set(list)
2008
2004
  @dependindex = list.index { |file| basepath(file).exist? }.tap do |index|
2009
- @dependfile = @path + list[index || 0]
2005
+ @dependfile = basepath(list[index || 0])
2010
2006
  end
2011
2007
  end
2012
2008
 
@@ -6,7 +6,7 @@ module Squared
6
6
  class Docker < Base
7
7
  COMPOSEFILE = %w[compose.yaml compose.yml docker-compose.yaml docker-compose.yml].freeze
8
8
  BAKEFILE = %w[docker-bake.json docker-bake.hcl docker-bake.override.json docker-bake.override.hcl].freeze
9
- DIR_DOCKER = (COMPOSEFILE + BAKEFILE).freeze
9
+ DIR_DOCKER = (COMPOSEFILE + BAKEFILE + ['Dockerfile']).freeze
10
10
  OPT_DOCKER = {
11
11
  common: %w[tls tlsverify config=p c|context=b D|debug H|host=q l|log-level=b tlscacert=p tlscert=p
12
12
  tlskey=p].freeze,
@@ -91,7 +91,7 @@ module Squared
91
91
  def config?(val)
92
92
  return false unless (val = as_path(val))
93
93
 
94
- val.join('Dockerfile').exist? || DIR_DOCKER.any? { |file| val.join(file).exist? }
94
+ DIR_DOCKER.any? { |file| val.join(file).exist? }
95
95
  end
96
96
  end
97
97
 
@@ -312,7 +312,7 @@ module Squared
312
312
  append_context
313
313
  when :bake, :compose
314
314
  if (val = option(from == :bake ? 'target' : 'service', ignore: false))
315
- ret.merge(split_escape(val).map! { |s| shell_escape(s) })
315
+ ret.merge(split_escape(val).map! { |s| shell_quote(s) })
316
316
  end
317
317
  end
318
318
  ret
@@ -401,7 +401,7 @@ module Squared
401
401
  args << k
402
402
  next
403
403
  when 'source', 'src', 'destination', 'dst', 'target', 'volume-subpath', 'image-path'
404
- v = path + v
404
+ v = basepath v
405
405
  v = shell_quote(v, option: false, force: false) if q == ''
406
406
  end
407
407
  args << "#{k}=#{q + v + q}"
@@ -575,16 +575,15 @@ module Squared
575
575
  end
576
576
 
577
577
  def dockerfile(val = nil)
578
- if val == 'Dockerfile'
579
- @file = false
580
- elsif val
578
+ if val
581
579
  @file = if val.is_a?(Array)
582
580
  val = val.select { |file| basepath(file).exist? }
583
581
  val.size > 1 ? val : val.first
584
- else
585
- val || DIR_DOCKER.find { |file| basepath(file).exist? }
582
+ elsif val == true
583
+ DIR_DOCKER.find { |file| basepath(file).exist? }
584
+ elsif val != 'Dockerfile'
585
+ val
586
586
  end
587
- @file ||= false
588
587
  end
589
588
  basepath((@file.is_a?(Array) ? @file.first : @file) || 'Dockerfile')
590
589
  end
@@ -622,17 +621,17 @@ module Squared
622
621
  end
623
622
 
624
623
  def append_file(type, target: @session)
625
- return if ENV['COMPOSE_FILE'] && compose?(type)
624
+ return if !@file || (ENV['COMPOSE_FILE'] && compose?(type))
626
625
 
627
626
  unless @file.is_a?(Array)
628
627
  case type
629
628
  when 2, 4
630
629
  return
631
630
  when 3
632
- return unless COMPOSEFILE.map { |val| path + val }.select(&:exist?).size > 1
631
+ return unless COMPOSEFILE.map { |val| basepath(val) }.select(&:exist?).size > 1
633
632
  end
634
633
  end
635
- files = Array(@file).map { |val| quote_option('file', path + val) }
634
+ files = Array(@file).map { |val| quote_option('file', basepath(val)) }
636
635
  if target.is_a?(Set)
637
636
  opts = target.to_a.insert(2, *files)
638
637
  target.clear.merge(opts)
@@ -812,7 +811,7 @@ module Squared
812
811
  end
813
812
 
814
813
  def contextdir(val = nil)
815
- val && projectpath?(val) ? shell_quote(path + val) : '.'
814
+ val && projectpath?(val) ? shell_quote(basepath(val)) : '.'
816
815
  end
817
816
 
818
817
  def tagjoin(*args, char: '/')
@@ -992,7 +992,7 @@ module Squared
992
992
  cur = nil
993
993
  foreachref('heads', format: '%(if)%(HEAD)%(then)* %(end)%(refname:short)').each do |line|
994
994
  line.chomp!
995
- cur ||= line.delete_prefix!('* ')
995
+ cur ||= line.sub!(/\A\* /, '')
996
996
  heads << line if matchany?(line, reg)
997
997
  end
998
998
  raise_error('head not found', hint: 'for-each-ref') unless cur
@@ -1234,7 +1234,7 @@ module Squared
1234
1234
  start = epochtime
1235
1235
  build(@output, sync: sync, from: :'git:revbuild')
1236
1236
  rescue StandardError => e
1237
- warn log_message(Logger::WARN, e, pass: true) if warning?
1237
+ print_error(e, pass: true)
1238
1238
  else
1239
1239
  print_status(name, subject: 'revbuild', start: start, from: :completed)
1240
1240
  workspace.rev_write(name, { 'revision' => sha, 'files' => status_digest(*args, **kwargs) },
@@ -1597,9 +1597,7 @@ module Squared
1597
1597
  end
1598
1598
  on :last, from
1599
1599
  end
1600
- if ret == 0
1601
- warn log_message(Logger::WARN, name, 'no ref found', subject: 'branch', hint: 'head', pass: true)
1602
- end
1600
+ print_error(name, 'no ref found', subject: 'branch', hint: 'head', pass: true) if ret == 0
1603
1601
  return
1604
1602
  end
1605
1603
  return unless success?(source(stdout: stdout))
@@ -1747,8 +1745,8 @@ module Squared
1747
1745
  end)
1748
1746
  case flag
1749
1747
  when :blame
1750
- raise_error 'no file found' unless (n = op.index { |s| (path + s).file? })
1751
- op << '--' << shell_quote(path + op.delete_at(n))
1748
+ raise_error 'no file found' unless (n = op.index { |s| basepath(s).file? })
1749
+ op << '--' << shell_quote(basepath(op.delete_at(n)))
1752
1750
  op.clear
1753
1751
  when :revert
1754
1752
  if VAL_GIT[:rebase][:send].any? { |val| op.arg?(val) }
@@ -1951,7 +1949,7 @@ module Squared
1951
1949
  next if !glob.empty? && glob.none? { |val| File.fnmatch?(val, file, File::FNM_DOTMATCH) }
1952
1950
  next if !pass.empty? && pass.any? { |val| File.fnmatch?(val, file, File::FNM_DOTMATCH) }
1953
1951
 
1954
- ret[file] = algorithm.hexdigest(File.read(path + file))
1952
+ ret[file] = algorithm.hexdigest(File.read(basepath(file)))
1955
1953
  end
1956
1954
  ret
1957
1955
  end
@@ -1983,7 +1981,7 @@ module Squared
1983
1981
  when 'recurse-submodules'
1984
1982
  op.append?($1, $2, type: :basic)
1985
1983
  when 'refspec'
1986
- refspec << shell_escape($2, quote: true)
1984
+ refspec << shell_quote($2)
1987
1985
  end
1988
1986
  elsif op.arg?('multiple')
1989
1987
  op.found << opt
@@ -2001,12 +1999,12 @@ module Squared
2001
1999
  end
2002
2000
  op.delete('--all')
2003
2001
  elsif op.arg?('multiple')
2004
- op.swap.merge(op.map! { |opt| shell_escape(opt, quote: true) })
2002
+ op.add_quote(*op.found)
2005
2003
  return
2006
2004
  elsif option('all')
2007
2005
  op << '--all'
2008
2006
  end
2009
- op.clear(errors: true, subject: flag.to_s) if flag
2007
+ op.clear(errors: true, subject: flag) if flag
2010
2008
  end
2011
2009
 
2012
2010
  def append_commit(*val, target: @session, head: false)