squared 0.5.4 → 0.5.6

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.
@@ -74,7 +74,7 @@ module Squared
74
74
  @revdoc = JSON.parse(@revfile.read) if @revfile.exist?
75
75
  rescue StandardError => e
76
76
  @revfile = nil
77
- warn log_message(Logger::WARN, e, pass: true) if @warning
77
+ warn log_message(Logger::WARN, e, pass: true)
78
78
  self
79
79
  else
80
80
  @revdoc = {} unless @revdoc.is_a?(Hash)
@@ -304,9 +304,9 @@ module Squared
304
304
  include Rake::DSL
305
305
 
306
306
  def populate(ws, **)
307
- return if ws.series.exclude?(:pull, true)
307
+ return if ws.series.exclude?(:pull, true) || ws.size == 1
308
308
 
309
- namespace(ws.task_name('git')) do |ns|
309
+ namespace ws.task_name('git') do |ns|
310
310
  ws.format_desc(all = ws.task_join(ns.scope.path, 'all'), 'stash|rebase|autostash?,depend?')
311
311
  task 'all' do |_, args|
312
312
  args = args.to_a
@@ -358,7 +358,7 @@ module Squared
358
358
  'restore' => %i[source staged worktree].freeze,
359
359
  'rev' => %i[commit build output].freeze,
360
360
  'show' => %i[format oneline textconv].freeze,
361
- 'stash' => %i[push pop apply branch drop clear list].freeze,
361
+ 'stash' => %i[push pop apply branch drop clear list all].freeze,
362
362
  'submodule' => %i[status update branch url sync].freeze,
363
363
  'switch' => %i[branch create detach].freeze,
364
364
  'tag' => %i[add sign delete list].freeze
@@ -503,10 +503,11 @@ module Squared
503
503
  end
504
504
  when 'stash'
505
505
  format_desc(action, flag, 'opts*', after: case flag
506
- when :push then 'pathspec*'
506
+ when :push then 'pathspec*,:'
507
507
  when :branch then 'name,stash?|:'
508
- when :clear, :list then nil
509
- else 'stash?|:' end)
508
+ when :clear, :list, :all then nil
509
+ else 'stash?|:'
510
+ end)
510
511
  task flag do |_, args|
511
512
  stash flag, args.to_a
512
513
  end
@@ -626,12 +627,12 @@ module Squared
626
627
  format_desc action, flag, 'ref,opts*'
627
628
  task flag, [:commit] do |_, args|
628
629
  commit = commithead args.commit
629
- if commit
630
- args = args.extras
631
- else
632
- commit, opts = choice_commit(values: ['Options'])
633
- args = OptionPartition.strip(opts)
634
- end
630
+ args = if commit
631
+ args.extras
632
+ else
633
+ commit, opts = choice_commit(values: ['Options'])
634
+ OptionPartition.strip(opts)
635
+ end
635
636
  checkout(flag, args, commit: commit)
636
637
  end
637
638
  when :detach
@@ -755,7 +756,8 @@ module Squared
755
756
  when 'h', 'hard' then ['hard']
756
757
  when 's', 'soft' then ['soft']
757
758
  when 'n', 'N' then ['mixed', 'N']
758
- else ['mixed'] end)
759
+ else ['mixed']
760
+ end)
759
761
  end
760
762
  print_success if success?(reset(flag, args, commit: commit))
761
763
  end
@@ -804,28 +806,28 @@ module Squared
804
806
  when :branch
805
807
  format_desc action, flag, 'upstream,branch?=HEAD,opts*'
806
808
  task flag, [:upstream] do |_, args|
807
- if (upstream = args.upstream)
808
- args = args.extras
809
- else
810
- upstream, opts = choice_refs('Choose upstream branch', values: ['Options'])
811
- args = OptionPartition.strip(opts)
812
- end
809
+ args = if (upstream = args.upstream)
810
+ args.extras
811
+ else
812
+ upstream, opts = choice_refs('Choose upstream branch', values: ['Options'])
813
+ OptionPartition.strip(opts)
814
+ end
813
815
  rebase(flag, args, upstream: upstream)
814
816
  end
815
817
  when :onto
816
818
  format_desc action, flag, 'ref,upstream,branch?=HEAD'
817
819
  task flag, [:commit, :upstream, :branch] do |_, args|
818
820
  commit = commithead args.commit
819
- if commit
820
- upstream = param_guard(action, flag, args: args, key: :upstream)
821
- branch = args.branch
822
- args = []
823
- else
824
- commit = choice_refs 'Choose "onto" branch'
825
- target, opts = choice_commit(multiple: 2, values: ['Options'], reflog: false)
826
- branch, upstream = target
827
- args = OptionPartition.strip(opts)
828
- end
821
+ args = if commit
822
+ upstream = param_guard(action, flag, args: args, key: :upstream)
823
+ branch = args.branch
824
+ []
825
+ else
826
+ commit = choice_refs 'Choose "onto" branch'
827
+ target, opts = choice_commit(multiple: 2, values: ['Options'], reflog: false)
828
+ branch, upstream = target
829
+ OptionPartition.strip(opts)
830
+ end
829
831
  rebase(flag, args, commit: commit, upstream: upstream, branch: branch)
830
832
  end
831
833
  when :commit, :'no-commit'
@@ -889,13 +891,13 @@ module Squared
889
891
  format_desc action, flag, 'ref,opts*,pathspec*'
890
892
  task flag, [:commit] do |_, args|
891
893
  commit = commithead args.commit
892
- if commit
893
- args = args.extras
894
- else
895
- commit, opts, files = choice_commit(values: ['Options', ['Pathspec', true]])
896
- args = OptionPartition.strip(opts)
897
- files = files&.shellsplit
898
- end
894
+ args = if commit
895
+ args.extras
896
+ else
897
+ commit, opts, files = choice_commit(values: ['Options', ['Pathspec', true]])
898
+ files = files&.shellsplit
899
+ OptionPartition.strip(opts)
900
+ end
899
901
  restore(flag, args, commit: commit, files: files)
900
902
  end
901
903
  when :staged, :worktree
@@ -921,7 +923,8 @@ module Squared
921
923
  before = case flag
922
924
  when :blame then 'file'
923
925
  when :mv then 'source+,destination'
924
- when :revert then 'commit+' end
926
+ when :revert then 'commit+'
927
+ end
925
928
  format_desc(action, flag, 'opts*', before: before, after: case flag
926
929
  when :add
927
930
  'pathspec*,pattern*'
@@ -956,43 +959,9 @@ module Squared
956
959
  def pull(flag = nil, opts = [], sync: invoked_sync?('pull', flag), remote: nil, hint: nil)
957
960
  cmd, opts = git_session('pull', opts: opts)
958
961
  cmd << '--autostash' if option('autostash')
959
- case flag
960
- when :rebase
962
+ if flag == :rebase
961
963
  cmd << '--rebase'
962
- when :all
963
- unless git_spawn('status -s -z --untracked-files=all').empty?
964
- if confirm('Stash local changes?', 'Y')
965
- git_spawn 'stash push --keep-index --quiet'
966
- elsif !(force = confirm('Force checkout?', 'N'))
967
- return
968
- end
969
- end
970
- op = OptionPartition.new(opts, OPT_GIT[:pull], cmd, project: self, no: OPT_GIT[:no][:pull])
971
- reg = if op.empty?
972
- []
973
- else
974
- opts = opts.reject { |val| op.extras.include?(val) }
975
- matchmap op
976
- end
977
- session_done op.target
978
- heads = []
979
- cur = nil
980
- foreachref('heads', format: '%(if)%(HEAD)%(then)* %(end)%(refname:short)').each do |line|
981
- line.chomp!
982
- cur ||= line.delete_prefix!('* ')
983
- heads << line if matchany?(line, reg)
984
- end
985
- raise_error('head not found', hint: 'for-each-ref') unless cur
986
- opts << 'ff-only' if opts.empty? && !option('ff-only', equals: '0')
987
- (heads.dup << cur).each_with_index do |branch, index|
988
- next unless (index < heads.size && cur != branch) || index == heads.size
989
-
990
- git_spawn 'switch --quiet', force && '--force', shell_quote(branch)
991
- pull(nil, opts, sync: false, hint: branch) if heads.include?(branch)
992
- end
993
- return
994
964
  else
995
- cmd << '--autostash' if flag == :autostash
996
965
  option('rebase', ignore: false) do |val|
997
966
  cmd << case val
998
967
  when '0', 'false'
@@ -1001,10 +970,47 @@ module Squared
1001
970
  VAL_GIT[:rebase][:value].include?(val) ? basic_option('rebase', val) : '--rebase'
1002
971
  end
1003
972
  end
973
+ case flag
974
+ when :all
975
+ unless git_spawn('status -s -z --untracked-files=all').empty?
976
+ if confirm('Stash local changes?', 'Y')
977
+ git_spawn 'stash push --keep-index --quiet'
978
+ elsif !(force = confirm('Force checkout?', 'N'))
979
+ return
980
+ end
981
+ printsucc
982
+ end
983
+ op = OptionPartition.new(opts, OPT_GIT[:pull], cmd, project: self, no: OPT_GIT[:no][:pull])
984
+ reg = if op.empty?
985
+ []
986
+ else
987
+ opts = op.uniq(opts)
988
+ matchmap op
989
+ end
990
+ session_done op.target
991
+ heads = []
992
+ cur = nil
993
+ foreachref('heads', format: '%(if)%(HEAD)%(then)* %(end)%(refname:short)').each do |line|
994
+ line.chomp!
995
+ cur ||= line.delete_prefix!('* ')
996
+ heads << line if matchany?(line, reg)
997
+ end
998
+ raise_error('head not found', hint: 'for-each-ref') unless cur
999
+ opts << 'ff-only' if opts.empty? && !option('ff-only', equals: '0')
1000
+ (heads.dup << cur).each_with_index do |branch, index|
1001
+ next unless (index < heads.size && cur != branch) || index == heads.size
1002
+
1003
+ git_spawn 'switch --quiet', force && '--force', shell_quote(branch)
1004
+ pull(nil, opts, sync: false, hint: branch) if heads.include?(branch)
1005
+ end
1006
+ return
1007
+ when :autostash
1008
+ cmd << '--autostash'
1009
+ end
1004
1010
  end
1005
1011
  append_pull(opts, OPT_GIT[:pull] + OPT_GIT[:fetch][:pull],
1006
1012
  no: OPT_GIT[:no][:pull] + OPT_GIT[:no][:fetch][:pull], remote: remote, flag: flag, from: :pull)
1007
- source(sync: sync, sub: if verbose
1013
+ source(sync: sync, sub: if stdout?
1008
1014
  [
1009
1015
  { pat: /^(.+)(\|\s+\d+\s+)([^-]*)(-+)(.*)$/, styles: color(:red), index: 4 },
1010
1016
  { pat: /^(.+)(\|\s+\d+\s+)(\++)(.*)$/, styles: color(:green), index: 3 }
@@ -1033,6 +1039,10 @@ module Squared
1033
1039
  cmd << upstream
1034
1040
  append_head branch
1035
1041
  else
1042
+ unless gitpath('REBASE_HEAD').exist?
1043
+ puts log_message(Logger::INFO, name, 'no rebase in progress', hint: command) if stdout?
1044
+ return
1045
+ end
1036
1046
  return unless VAL_GIT[:rebase][:send].include?(command)
1037
1047
 
1038
1048
  cmd << "--#{command}"
@@ -1086,6 +1096,10 @@ module Squared
1086
1096
 
1087
1097
  def stash(flag = nil, opts = [], sync: invoked_sync?('stash', flag))
1088
1098
  if flag
1099
+ if flag == :all
1100
+ opts << 'include-untracked'
1101
+ flag = :push
1102
+ end
1089
1103
  cmd, opts = git_session('stash', flag, opts: opts)
1090
1104
  list = OPT_GIT[:stash][:common] + OPT_GIT[:stash].fetch(flag, [])
1091
1105
  if flag == :list
@@ -1095,6 +1109,7 @@ module Squared
1095
1109
  op = OptionPartition.new(opts, list, cmd, project: self, no: no, first: flag == :push ? matchpathspec : nil)
1096
1110
  case flag
1097
1111
  when :push
1112
+ op.append?('message', readline('Enter message', force: true), force: true) if op.remove(':')
1098
1113
  append_pathspec op.extras
1099
1114
  when :pop, :apply, :drop, :branch
1100
1115
  if op.remove(':')
@@ -1158,7 +1173,7 @@ module Squared
1158
1173
  end
1159
1174
  append_pathspec
1160
1175
  end
1161
- if verbose
1176
+ if stdout?
1162
1177
  r = color(:red)
1163
1178
  g = color(:green)
1164
1179
  sub = if session_arg?('short')
@@ -1211,7 +1226,7 @@ module Squared
1211
1226
  if (cur = workspace.rev_entry(name)) && cur['revision'] == sha && !env('REVBUILD_FORCE')
1212
1227
  files = status_digest(*args, **kwargs)
1213
1228
  if cur['files'].size == files.size && cur['files'].find { |key, val| files[key] != val }.nil?
1214
- if verbose
1229
+ if stdout?
1215
1230
  if (since = workspace.rev_timesince(name, 'build'))
1216
1231
  puts log_message(Logger::INFO, name, 'no changes', subject: 'revbuild', hint: "#{since} ago")
1217
1232
  else
@@ -1276,7 +1291,6 @@ module Squared
1276
1291
  append_option('track', equals: true)
1277
1292
  cmd << (create ? quote_option(create, branch) : branch) << commit
1278
1293
  when :track
1279
-
1280
1294
  cmd << quote_option(branch.delete_prefix!('^') ? 'B' : 'b', branch) if branch
1281
1295
  cmd << '--track' << shell_quote(origin)
1282
1296
  when :detach
@@ -1360,15 +1374,14 @@ module Squared
1360
1374
  op << '--no-index'
1361
1375
  append_pathspec(refs, parent: true)
1362
1376
  else
1377
+ op << '--merge-base' if option('merge-base')
1363
1378
  case flag
1364
1379
  when :view
1365
- op << '--merge-base' if option('merge-base')
1366
1380
  op.merge(range)
1367
1381
  when :between, :contain
1368
1382
  op.delete('--merge-base')
1369
1383
  op.add_quote(range.join(flag == :between ? '..' : '...'))
1370
1384
  else
1371
- op << '--merge-base' if option('merge-base')
1372
1385
  op.add_quote(branch) if branch
1373
1386
  if !index.empty?
1374
1387
  if op.arg?('cached')
@@ -1415,7 +1428,6 @@ module Squared
1415
1428
  cmd, opts = git_session('add', opts: opts)
1416
1429
  op = OptionPartition.new(opts, OPT_GIT[:add], cmd, project: self, first: matchpathspec)
1417
1430
  op << '--verbose' if verbose
1418
- dryrun = dryrun?
1419
1431
  format = '%(if)%(HEAD)%(then)%(refname:short)...%(upstream:short)...%(upstream:track)%(end)'
1420
1432
  git_spawn 'fetch --no-tags --quiet'
1421
1433
  foreachref('heads', format: format).each do |line|
@@ -1424,16 +1436,16 @@ module Squared
1424
1436
  branch, origin, hint = line.split('...')
1425
1437
  if hint && !hint.match?(/^\[(\D+0,\D+0)\]$/)
1426
1438
  raise_error('work tree is not usable', hint: hint[1..-2])
1427
- elsif origin.empty?
1439
+ elsif !origin || origin.empty?
1428
1440
  return nil if pass
1429
- break if dryrun
1441
+ break if dryrun?
1430
1442
 
1431
1443
  unless (origin = option('upstream', prefix: 'git', ignore: false))
1432
1444
  if (origin = choice_refs('Choose an upstream', 'remotes', attempts: 1, force: false))
1433
1445
  git_spawn 'branch', quote_option('set-upstream-to', origin)
1434
- else
1435
- origin = readline('Enter an upstream', force: true)
1446
+ break
1436
1447
  end
1448
+ origin = readline('Enter an upstream', force: true)
1437
1449
  end
1438
1450
  raise_error('missing remote name', hint: origin) unless origin.include?('/')
1439
1451
  upstream = true
@@ -1447,7 +1459,7 @@ module Squared
1447
1459
  end
1448
1460
  co = git_session('commit', options: false)
1449
1461
  pu = git_output 'push', upstream && '--set-upstream'
1450
- if dryrun
1462
+ if dryrun?
1451
1463
  op.delete('--dry-run')
1452
1464
  co << '--dry-run'
1453
1465
  pu << '--dry-run'
@@ -1462,12 +1474,19 @@ module Squared
1462
1474
  pu.merge(repotrack(origin, branch))
1463
1475
  puts if pass
1464
1476
  source op
1465
- source co
1466
- source pu
1477
+ if amend || !git_spawn('diff --cached --name-only --no-color').empty? || dryrun?
1478
+ source co
1479
+ source pu
1480
+ elsif banner?
1481
+ puts 'Nothing to commit'
1482
+ elsif stdout?
1483
+ puts log_message(Logger::INFO, name, 'nothing to commit', hint: flag)
1484
+ end
1467
1485
  end
1468
1486
 
1469
1487
  def merge(flag, opts = [], command: nil, branch: nil)
1470
1488
  cmd, opts = git_session('merge', opts: opts)
1489
+ display = false
1471
1490
  case flag
1472
1491
  when :commit, :'no-commit'
1473
1492
  op = OptionPartition.new(opts, OPT_GIT[:merge], cmd, project: self, no: OPT_GIT[:no][:merge])
@@ -1480,11 +1499,16 @@ module Squared
1480
1499
  append_commit(*op.extras)
1481
1500
  end
1482
1501
  else
1502
+ unless gitpath('MERGE_HEAD').exist?
1503
+ puts log_message(Logger::INFO, name, 'no merge in progress', hint: command) if stdout?
1504
+ return
1505
+ end
1483
1506
  return unless VAL_GIT[:merge][:send].include?(command)
1484
1507
 
1485
1508
  cmd << "--#{command}"
1509
+ display = command == 'abort'
1486
1510
  end
1487
- source
1511
+ print_success if success?(source, display)
1488
1512
  end
1489
1513
 
1490
1514
  def branch(flag = nil, opts = [], refs: [], ref: nil, target: nil, remote: nil)
@@ -1521,10 +1545,8 @@ module Squared
1521
1545
  end
1522
1546
  force, list = refs.partition { |val| val.start_with?(/[~^]/) }
1523
1547
  force.each do |val|
1524
- dr = val[0, 2]
1525
- d = dr.include?('^') ? '-D' : '-d'
1526
- r = '-r' if dr.include?('~')
1527
- source git_output('branch', d, r, shell_quote(val.sub(/^[~^]+/, '')))
1548
+ r = '-r' if val.delete!('~')
1549
+ source git_output('branch', val.delete!('^') ? '-D' : '-d', r, shell_quote(val))
1528
1550
  end
1529
1551
  return if list.empty?
1530
1552
 
@@ -1532,8 +1554,9 @@ module Squared
1532
1554
  append_value list
1533
1555
  remote = nil
1534
1556
  when :move, :copy
1535
- flag = "-#{flag.to_s[0]}"
1536
- cmd << (option('force', 'f') ? flag.upcase : flag)
1557
+ s = "-#{flag.to_s[0]}"
1558
+ s.upcase! if option('force', 'f')
1559
+ cmd << s
1537
1560
  refs.compact.each { |val| cmd << shell_quote(val) }
1538
1561
  stdout = true
1539
1562
  when :current
@@ -1553,12 +1576,12 @@ module Squared
1553
1576
  list_result(ret, 'branches', from: from)
1554
1577
  return
1555
1578
  else
1556
- head = git_spawn('rev-parse --abbrev-ref HEAD').chomp
1557
- if head.empty?
1579
+ if (head = git_spawn('rev-parse --abbrev-ref HEAD').chomp).empty?
1558
1580
  ret = 0
1559
1581
  else
1560
1582
  git_spawn 'fetch --all --prune --quiet' if option('sync')
1561
- out, banner, from = source(cmd << '-vv --no-abbrev --list', io: true)
1583
+ cmd << '-vv --no-abbrev --list'
1584
+ out, banner, from = source(io: true)
1562
1585
  ret = write_lines(out, grep: [/^\*\s+#{Regexp.escape(head)}\s/], banner: banner, first: true) do |line|
1563
1586
  next line if stdin?
1564
1587
 
@@ -1624,10 +1647,13 @@ module Squared
1624
1647
  op = OptionPartition.new(opts, OPT_GIT[:submodule].fetch(flag, []), cmd, project: self)
1625
1648
  case flag
1626
1649
  when :branch, :url
1650
+ op.adjoin("set-#{flag}")
1627
1651
  op << '--'
1628
1652
  op.add_path(path) if path
1629
1653
  op.add_quote(url) if url
1630
1654
  else
1655
+ op.adjoin(flag)
1656
+ op << '--recursive' if option('recursive', 'r')
1631
1657
  op.splice(path: true)
1632
1658
  end
1633
1659
  source
@@ -1652,19 +1678,15 @@ module Squared
1652
1678
  source(banner: false)
1653
1679
  return
1654
1680
  when :oneline
1655
- format = 'oneline'
1681
+ format = flag.to_s
1656
1682
  end
1657
- if format
1658
- case (val = format.downcase)
1659
- when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
1660
- cmd << basic_option('format', val)
1661
- else
1662
- if format.start_with?(/t?format:/) || format.include?('%')
1663
- cmd << quote_option('pretty', format)
1664
- else
1665
- opts << format
1666
- end
1667
- end
1683
+ case format
1684
+ when 'oneline', 'short', 'medium', 'full', 'fuller', 'reference', 'email', 'raw'
1685
+ cmd << basic_option('format', format)
1686
+ when /(?:^t?format:|%)/
1687
+ cmd << quote_option('pretty', format)
1688
+ else
1689
+ opts << format if format
1668
1690
  end
1669
1691
  op = OptionPartition.new(opts, OPT_GIT[:show] + OPT_GIT[:diff][:show] + OPT_GIT[:log][:diff], cmd,
1670
1692
  project: self,
@@ -1721,7 +1743,8 @@ module Squared
1721
1743
  project: self, no: OPT_GIT[:no][flag], first: case flag
1722
1744
  when :blame, :revert
1723
1745
  nil
1724
- else matchpathspec end)
1746
+ else matchpathspec
1747
+ end)
1725
1748
  case flag
1726
1749
  when :blame
1727
1750
  raise_error 'no file found' unless (n = op.index { |s| (path + s).file? })
@@ -1756,8 +1779,7 @@ module Squared
1756
1779
  end
1757
1780
  return source(git_session('status -s'), banner: false) unless append_pathspec(op.extras)
1758
1781
 
1759
- verbose = flag == :add && !op.arg?('verbose')
1760
- print_success if success?(source) && verbose
1782
+ print_success if success?(source, flag == :add && !op.arg?('verbose'))
1761
1783
  return
1762
1784
  when :mv
1763
1785
  refs = projectmap op.extras
@@ -1784,7 +1806,7 @@ module Squared
1784
1806
  private
1785
1807
 
1786
1808
  def source(cmd = @session, exception: true, io: false, sync: true, stdout: false, stderr: false, banner: true,
1787
- multiple: false, hint: nil, from: nil, **kwargs)
1809
+ multiple: false, hint: nil, from: nil, send: :system, **kwargs)
1788
1810
  cmd = cmd.target if cmd.is_a?(OptionPartition)
1789
1811
  if io && banner == false
1790
1812
  from = nil
@@ -1792,10 +1814,10 @@ module Squared
1792
1814
  else
1793
1815
  banner = nil if banner && (multiple || !banner?)
1794
1816
  if cmd.respond_to?(:done)
1795
- if from.nil? && (from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z\-]*\z/) })
1817
+ if from.nil? && (from = cmd.drop(1).find { |val| val.match?(/\A[a-z]{1,2}[a-z-]*\z/) })
1796
1818
  from = :"git:#{from}"
1797
1819
  end
1798
- banner &&= cmd.temp { |val| val.start_with?('--work-tree') || val.start_with?('--git-dir') }
1820
+ banner &&= cmd.temp { |val| val.start_with?(/--(?:work-tree|git-dir)/) }
1799
1821
  end
1800
1822
  from = nil if from == false
1801
1823
  end
@@ -1824,7 +1846,7 @@ module Squared
1824
1846
  end
1825
1847
  elsif !kwargs[:sub] && (sync || (!exception && !stderr))
1826
1848
  print_item banner unless multiple
1827
- ret = shell(cmd, exception: exception)
1849
+ ret = shell(cmd, name: send, exception: exception)
1828
1850
  else
1829
1851
  require 'open3'
1830
1852
  if stderr
@@ -1882,7 +1904,7 @@ module Squared
1882
1904
  def list_result(size, type, grep: [], action: 'found', from: nil)
1883
1905
  if size == 0
1884
1906
  puts empty_status("No #{type} were #{action}", 'grep', grep.join(', '))
1885
- elsif verbose
1907
+ elsif stdout?
1886
1908
  styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
1887
1909
  styles << :bold if styles.size <= 1
1888
1910
  puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
@@ -1957,11 +1979,9 @@ module Squared
1957
1979
  when 'rebase'
1958
1980
  op << basic_option($1, $2) if VAL_GIT[:rebase][:value].include?($2)
1959
1981
  when 'shallow-since'
1960
- next unless (val = Date.parse($2))
1961
-
1962
- op << quote_option($1, val.strftime('%F %T'))
1982
+ op.append?($1) { Date.parse($2)&.strftime('%F %T') }
1963
1983
  when 'recurse-submodules'
1964
- op << basic_option($1, $2) unless op.arg?('recurse-submodules')
1984
+ op.append?($1, $2, type: :basic)
1965
1985
  when 'refspec'
1966
1986
  refspec << shell_escape($2, quote: true)
1967
1987
  end
@@ -1971,7 +1991,7 @@ module Squared
1971
1991
  op.errors << opt
1972
1992
  end
1973
1993
  end
1974
- op << '--verbose' if (flag || from == :fetch) && verbose && !op.arg?('quiet')
1994
+ op << '--verbose' if (flag || from == :fetch) && stdout? && !op.arg?('quiet')
1975
1995
  if remote
1976
1996
  op.append(remote, delim: true)
1977
1997
  if (val = option('refspec', target: target, strict: true))
@@ -1984,7 +2004,7 @@ module Squared
1984
2004
  op.swap.merge(op.map! { |opt| shell_escape(opt, quote: true) })
1985
2005
  return
1986
2006
  elsif option('all')
1987
- cmd << '--all'
2007
+ op << '--all'
1988
2008
  end
1989
2009
  op.clear(errors: true, subject: flag.to_s) if flag
1990
2010
  end
@@ -2072,8 +2092,17 @@ module Squared
2072
2092
  git_session(*cmd, main: false, options: false, **kwargs)
2073
2093
  end
2074
2094
 
2075
- def git_spawn(*cmd, stdout: true)
2076
- source(cmd.first.is_a?(Set) ? cmd.first : git_output(*cmd), io: true, banner: false, stdout: stdout)
2095
+ def git_spawn(*cmd, exception: true, io: true, sync: true, stdout: true, banner: false, **kwargs)
2096
+ kwargs[:send] = if sync
2097
+ :system
2098
+ else
2099
+ exception = false
2100
+ io = false
2101
+ stdout = false
2102
+ :spawn
2103
+ end
2104
+ source(cmd.first.is_a?(Set) ? cmd.first : git_output(*cmd), exception: exception, io: io, sync: sync,
2105
+ stdout: stdout, banner: banner, **kwargs)
2077
2106
  end
2078
2107
 
2079
2108
  def dryrun?(*, target: @session, **)
@@ -2088,8 +2117,8 @@ module Squared
2088
2117
  target.include?('--quiet') || (target.include?('-q') && stripext(target.first) == 'git')
2089
2118
  end
2090
2119
 
2091
- def gitpath
2092
- path + '.git'
2120
+ def gitpath(*args)
2121
+ path.join('.git', *args)
2093
2122
  end
2094
2123
 
2095
2124
  def repotrack(origin, branch, quote: true)