squared 0.7.6 → 0.8.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +106 -10
- data/README.md +40 -36
- data/lib/squared/common/base.rb +0 -1
- data/lib/squared/common/format.rb +5 -14
- data/lib/squared/common/prompt.rb +25 -24
- data/lib/squared/common/shell.rb +24 -17
- data/lib/squared/common/system.rb +9 -19
- data/lib/squared/common/utils.rb +17 -13
- data/lib/squared/config.rb +3 -11
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +99 -29
- data/lib/squared/workspace/project/base.rb +95 -82
- data/lib/squared/workspace/project/docker.rb +46 -29
- data/lib/squared/workspace/project/git.rb +158 -64
- data/lib/squared/workspace/project/node.rb +255 -165
- data/lib/squared/workspace/project/python.rb +27 -28
- data/lib/squared/workspace/project/ruby.rb +100 -72
- data/lib/squared/workspace/project/support/class.rb +2 -2
- data/lib/squared/workspace/project/support/optionpartition.rb +9 -12
- data/lib/squared/workspace/project/support/utils.rb +10 -1
- data/lib/squared/workspace/repo.rb +9 -7
- data/lib/squared/workspace/series.rb +10 -2
- metadata +2 -2
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module Squared
|
|
4
4
|
module Workspace
|
|
5
|
+
GIT_PROTO = %r{\A(https?|ssh|git|file)://}i.freeze
|
|
6
|
+
private_constant :GIT_PROTO
|
|
7
|
+
|
|
5
8
|
module Git
|
|
6
9
|
GIT_REPO = Support.hashobj
|
|
7
|
-
|
|
8
|
-
private_constant :GIT_REPO, :GIT_PROTO
|
|
10
|
+
private_constant :GIT_REPO
|
|
9
11
|
|
|
10
12
|
attr_reader :revfile
|
|
11
13
|
|
|
@@ -187,6 +189,7 @@ module Squared
|
|
|
187
189
|
A|after-context=i B|before-context=i color=b C|context=i m|max-count=n max-depth=n
|
|
188
190
|
open-files-in-pager=b threads=n].freeze,
|
|
189
191
|
mv: %w[k f|force n|dry-run v|verbose].freeze,
|
|
192
|
+
remote: %w[f m=b t=b no-tags tags mirror=b].freeze,
|
|
190
193
|
revert: %w[e S=bm? n|no-commit reference cleanup=b gpg-sign=b? m|mainline=i s|signoff strategy=b
|
|
191
194
|
X|strategy-option=b].freeze,
|
|
192
195
|
rm: %w[r cached f|force n|dry-run ignore-unmatch pathspec-file-nul q|quiet sparse
|
|
@@ -233,6 +236,16 @@ module Squared
|
|
|
233
236
|
f|force-rebase ignore-date ignore-whitespace i|interactive keep-base m|merge no-ff q|quiet quit
|
|
234
237
|
reset-author-date root show-current-patch signoff v|verbose empty=b x|exec=q gpg-sign=b? onto=b
|
|
235
238
|
r|rebase-merges=b s|strategy=b X|strategy-option=b trailer=q whitespace=b].freeze,
|
|
239
|
+
remote: {
|
|
240
|
+
rename: %w[no-progress progress].freeze,
|
|
241
|
+
remove: [].freeze,
|
|
242
|
+
'set-head': %w[a|auto d|delete].freeze,
|
|
243
|
+
'set-branches': %w[add].freeze,
|
|
244
|
+
'get-url': %w[all push].freeze,
|
|
245
|
+
'set-url': %w[add delete push].freeze,
|
|
246
|
+
show: %w[n].freeze,
|
|
247
|
+
prune: %w[n dry-run].freeze
|
|
248
|
+
}.freeze,
|
|
236
249
|
reset: %w[N pathspec-file-nul q|quiet pathspec-from-file=p].freeze,
|
|
237
250
|
restore: %w[ignore-skip-worktree-bits ignore-unmerged m|merge ours p|patch pathspec-file-nul q|quiet S|staged
|
|
238
251
|
theirs W|worktree conflict=b pathspec-from-file=p s|source=b].freeze,
|
|
@@ -332,7 +345,7 @@ module Squared
|
|
|
332
345
|
end
|
|
333
346
|
|
|
334
347
|
subtasks({
|
|
335
|
-
'branch' => %i[create track delete move copy list current].freeze,
|
|
348
|
+
'branch' => %i[create track delete move copy list all current].freeze,
|
|
336
349
|
'checkout' => %i[commit branch track detach path].freeze,
|
|
337
350
|
'commit' => %i[add all amend amend-orig fixup].freeze,
|
|
338
351
|
'diff' => %i[head branch files view between contain].freeze,
|
|
@@ -345,12 +358,13 @@ module Squared
|
|
|
345
358
|
'pull' => %i[origin remote all].freeze,
|
|
346
359
|
'rebase' => %i[branch onto send].freeze,
|
|
347
360
|
'refs' => %i[heads tags remote].freeze,
|
|
361
|
+
'remote' => %i[add select].freeze,
|
|
348
362
|
'reset' => %i[commit index patch mode undo].freeze,
|
|
349
363
|
'restore' => %i[source staged worktree].freeze,
|
|
350
364
|
'rev' => %i[commit branch build output].freeze,
|
|
351
365
|
'show' => %i[format oneline textconv].freeze,
|
|
352
366
|
'sparse-checkout' => %i[add reapply list clean disable].freeze,
|
|
353
|
-
'stash' => %i[push pop apply
|
|
367
|
+
'stash' => %i[push pop apply drop command].freeze,
|
|
354
368
|
'submodule' => %i[status update branch url sync].freeze,
|
|
355
369
|
'switch' => %i[branch create detach].freeze,
|
|
356
370
|
'tag' => %i[add sign delete list].freeze
|
|
@@ -481,31 +495,37 @@ module Squared
|
|
|
481
495
|
when :add, :sign
|
|
482
496
|
format_desc action, flag, 'name,message?,commit?,remote?'
|
|
483
497
|
task flag, [:name, :message, :commit, :remote] do |_, args|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
498
|
+
if (name = args.name)
|
|
499
|
+
message = args.message
|
|
500
|
+
commit = commithead args.commit
|
|
501
|
+
remote = args.remote
|
|
502
|
+
if !remote && commit && !commit.start_with?('@') && !git_grep('remote', commit).empty?
|
|
503
|
+
remote = commit
|
|
504
|
+
commit = nil
|
|
505
|
+
end
|
|
506
|
+
else
|
|
507
|
+
commit, name, message = choice_commit(reflog: false, series: true,
|
|
508
|
+
values: [['Enter tag name', true], 'Enter message'])
|
|
509
|
+
remote = choice_remote
|
|
510
|
+
end
|
|
496
511
|
ret = tag(flag, refs: [name], message: message, commit: commit, remote: remote)
|
|
497
512
|
success?(ret, !remote)
|
|
498
513
|
end
|
|
499
514
|
end
|
|
500
515
|
when 'stash'
|
|
501
|
-
format_desc(action, flag, 'opts*',
|
|
516
|
+
format_desc(action, flag, 'opts*', before: ('clear|list|all|staged|worktree' if flag == :command),
|
|
517
|
+
after: case flag
|
|
502
518
|
when :push then 'pathspec*,:'
|
|
503
|
-
when :
|
|
504
|
-
when :clear, :list, :all then nil
|
|
519
|
+
when :command then nil
|
|
505
520
|
else 'stash?|:'
|
|
506
521
|
end)
|
|
507
522
|
task flag do |_, args|
|
|
508
|
-
|
|
523
|
+
args = args.to_a
|
|
524
|
+
if flag == :command
|
|
525
|
+
param_guard(action, flag, args: args)
|
|
526
|
+
flag = args.shift.to_sym
|
|
527
|
+
end
|
|
528
|
+
stash flag, args
|
|
509
529
|
end
|
|
510
530
|
when 'log', 'diff', 'range-diff'
|
|
511
531
|
case flag
|
|
@@ -531,7 +551,7 @@ module Squared
|
|
|
531
551
|
end
|
|
532
552
|
args = args.drop(index.size)
|
|
533
553
|
end
|
|
534
|
-
|
|
554
|
+
log_(flag, args, index: index)
|
|
535
555
|
end
|
|
536
556
|
next
|
|
537
557
|
end
|
|
@@ -549,7 +569,7 @@ module Squared
|
|
|
549
569
|
opts.concat(refs.shellsplit) if refs
|
|
550
570
|
end
|
|
551
571
|
if action == 'log'
|
|
552
|
-
|
|
572
|
+
log_(flag, opts, range: range)
|
|
553
573
|
else
|
|
554
574
|
diff(flag, opts, range: range, from: action.to_sym)
|
|
555
575
|
end
|
|
@@ -613,7 +633,7 @@ module Squared
|
|
|
613
633
|
end
|
|
614
634
|
end
|
|
615
635
|
param_guard(action, flag, args: grep)
|
|
616
|
-
|
|
636
|
+
log_(flag, opts, grep: grep)
|
|
617
637
|
end
|
|
618
638
|
end
|
|
619
639
|
when 'checkout'
|
|
@@ -730,12 +750,7 @@ module Squared
|
|
|
730
750
|
task flag do |_, args|
|
|
731
751
|
branch flag, args.to_a
|
|
732
752
|
end
|
|
733
|
-
when :
|
|
734
|
-
format_desc action, flag
|
|
735
|
-
task flag do
|
|
736
|
-
branch flag
|
|
737
|
-
end
|
|
738
|
-
else
|
|
753
|
+
when :move, :copy
|
|
739
754
|
format_desc action, flag, 'branch,oldbranch?'
|
|
740
755
|
task flag, [:branch, :oldbranch] do |_, args|
|
|
741
756
|
if (branch = args.branch)
|
|
@@ -746,6 +761,11 @@ module Squared
|
|
|
746
761
|
end
|
|
747
762
|
branch(flag, refs: [oldbranch, branch])
|
|
748
763
|
end
|
|
764
|
+
else
|
|
765
|
+
format_desc action, flag
|
|
766
|
+
task flag do
|
|
767
|
+
branch flag
|
|
768
|
+
end
|
|
749
769
|
end
|
|
750
770
|
when 'switch'
|
|
751
771
|
case flag
|
|
@@ -794,10 +814,10 @@ module Squared
|
|
|
794
814
|
end
|
|
795
815
|
success?(reset(flag, args, commit: commit))
|
|
796
816
|
end
|
|
797
|
-
when :index
|
|
798
|
-
format_desc
|
|
817
|
+
when :index
|
|
818
|
+
format_desc action, flag, 'opts*,pathspec*'
|
|
799
819
|
task flag do |_, args|
|
|
800
|
-
reset(flag,
|
|
820
|
+
reset(flag, args.to_a, refs: [])
|
|
801
821
|
end
|
|
802
822
|
when :mode
|
|
803
823
|
format_desc action, flag, 'mode,ref/:'
|
|
@@ -812,6 +832,11 @@ module Squared
|
|
|
812
832
|
ref = commithead args.ref
|
|
813
833
|
reset(flag, refs: args.extras, ref: !ref || ref == ':' ? choice_commit(reflog: false) : ref)
|
|
814
834
|
end
|
|
835
|
+
when :undo
|
|
836
|
+
format_desc action, flag
|
|
837
|
+
task flag do
|
|
838
|
+
reset flag
|
|
839
|
+
end
|
|
815
840
|
end
|
|
816
841
|
when 'show'
|
|
817
842
|
case flag
|
|
@@ -976,6 +1001,51 @@ module Squared
|
|
|
976
1001
|
task flag do |_, args|
|
|
977
1002
|
sparse_checkout flag, args.to_a
|
|
978
1003
|
end
|
|
1004
|
+
when 'remote'
|
|
1005
|
+
if flag == :add
|
|
1006
|
+
format_desc action, flag, 'name,url,opts*'
|
|
1007
|
+
task flag, [:name, :url] do |_, args|
|
|
1008
|
+
name = param_guard(action, flag, args: args, key: :name)
|
|
1009
|
+
url = param_guard(action, flag, args: args, key: :url)
|
|
1010
|
+
raise ArgumentError, message('invalid url', hint: url) unless url.match?(GIT_PROTO)
|
|
1011
|
+
|
|
1012
|
+
git(:remote, args.extras, extras: [name, url])
|
|
1013
|
+
end
|
|
1014
|
+
else
|
|
1015
|
+
format_desc action, flag, "#{OPT_GIT[:remote].keys.join('|')},opts*" if TASK_METADATA
|
|
1016
|
+
task flag, [:command] do |_, args|
|
|
1017
|
+
command = param_guard(action, flag, args: args, key: :command)
|
|
1018
|
+
cmd, opts = git_session('remote', opts: args.extras)
|
|
1019
|
+
param = case command
|
|
1020
|
+
when 'rename'
|
|
1021
|
+
'New name'
|
|
1022
|
+
when 'set-branches'
|
|
1023
|
+
'Branches'
|
|
1024
|
+
when 'set-head'
|
|
1025
|
+
'Branch' if opts.empty?
|
|
1026
|
+
when 'set-url'
|
|
1027
|
+
'URL'
|
|
1028
|
+
end
|
|
1029
|
+
remote, target = choice_remote(force: true, values: param ? [[param, true]] : [])
|
|
1030
|
+
cmd << '-v' if has_value!(opts, 'v', 'verbose') && command == 'show'
|
|
1031
|
+
cmd << command << remote
|
|
1032
|
+
op = OptionPartition.new(opts, OPT_GIT[:remote].fetch(command.to_sym, []), cmd,
|
|
1033
|
+
project: self, strict: strict?)
|
|
1034
|
+
case command
|
|
1035
|
+
when 'remove'
|
|
1036
|
+
exit 1 unless confirm_basic('Remove?', remote, 'N')
|
|
1037
|
+
when 'get-url', 'show', 'prune'
|
|
1038
|
+
status = false
|
|
1039
|
+
else
|
|
1040
|
+
raise ArgumentError, message('unrecognized command', command, hint: action) unless param
|
|
1041
|
+
raise ArgumentError, message('missing target', command, hint: action) unless target
|
|
1042
|
+
|
|
1043
|
+
op << target
|
|
1044
|
+
end
|
|
1045
|
+
op.clear
|
|
1046
|
+
success?(source(banner: !quiet?), status)
|
|
1047
|
+
end
|
|
1048
|
+
end
|
|
979
1049
|
when 'git'
|
|
980
1050
|
before = case flag
|
|
981
1051
|
when :blame
|
|
@@ -1056,7 +1126,8 @@ module Squared
|
|
|
1056
1126
|
cur ||= line.delete_prefix!('* ')
|
|
1057
1127
|
heads << line if matchany?(reg, line)
|
|
1058
1128
|
end
|
|
1059
|
-
|
|
1129
|
+
raise message('head not found', hint: 'for-each-ref') unless cur
|
|
1130
|
+
|
|
1060
1131
|
opts << 'ff-only' if opts.empty? && option('ff-only', notequals: '0')
|
|
1061
1132
|
(heads.dup << cur).each_with_index do |branch, i|
|
|
1062
1133
|
next unless (i < heads.size && cur != branch) || i == heads.size
|
|
@@ -1169,7 +1240,7 @@ module Squared
|
|
|
1169
1240
|
option('no-tags') { opts[:'no-tags'] = true }
|
|
1170
1241
|
opts.delete(:'recurse-submodules') || opts.delete(:'no-recurse-submodules') if append_submodules(from: :clone)
|
|
1171
1242
|
append_hash opts
|
|
1172
|
-
cmd << '--quiet' if option('quiet')
|
|
1243
|
+
cmd << '--quiet' if quiet? || option('quiet')
|
|
1173
1244
|
append_value(data[0], path, delim: true)
|
|
1174
1245
|
source(sync: sync, banner: sync && !quiet?, multiple: !sync || quiet?)
|
|
1175
1246
|
end
|
|
@@ -1219,18 +1290,17 @@ module Squared
|
|
|
1219
1290
|
else
|
|
1220
1291
|
op << out
|
|
1221
1292
|
end
|
|
1222
|
-
elsif !op.empty?
|
|
1223
|
-
op.add_first(prefix: ':')
|
|
1224
1293
|
elsif flag == :branch
|
|
1225
|
-
|
|
1294
|
+
op.add_first(prefix: ':', expect: 'no branch name')
|
|
1226
1295
|
end
|
|
1227
|
-
op.
|
|
1296
|
+
op.add_first
|
|
1297
|
+
.clear
|
|
1228
1298
|
when :clear
|
|
1229
1299
|
n = sub_style file.read.lines.size, theme[:inline]
|
|
1230
1300
|
s = sub_style name, theme[:active]
|
|
1231
1301
|
source(stdout: true) if confirm("Remove #{n} stash entries from #{s}?", 'N')
|
|
1232
1302
|
return
|
|
1233
|
-
|
|
1303
|
+
else
|
|
1234
1304
|
op.clear
|
|
1235
1305
|
out, banner, from = source(io: true)
|
|
1236
1306
|
print_item banner
|
|
@@ -1321,6 +1391,7 @@ module Squared
|
|
|
1321
1391
|
|
|
1322
1392
|
sync = kwargs.fetch(:sync) { invoked_sync?('revbuild', flag) }
|
|
1323
1393
|
kwargs = kwargs.key?(:include) || kwargs.key?(:exclude) ? kw.call : @revbuild || { pass: true }
|
|
1394
|
+
from = symjoin 'git', 'revbuild'
|
|
1324
1395
|
case flag
|
|
1325
1396
|
when :build
|
|
1326
1397
|
op = OptionPartition.new(opts, VAL_GIT[:revbuild].map { |key| "#{key}=b?" }, project: self, strict: strict?)
|
|
@@ -1333,7 +1404,7 @@ module Squared
|
|
|
1333
1404
|
.compact
|
|
1334
1405
|
OptionPartition.uniq!(args)
|
|
1335
1406
|
end
|
|
1336
|
-
run_p(*Array(kwargs[:before]), sync: sync, from:
|
|
1407
|
+
run_p(*Array(kwargs[:before]), sync: sync, from: symjoin(from, 'before')) if kwargs[:before]
|
|
1337
1408
|
force = if (force = env('REVBUILD_FORCE', strict: true))
|
|
1338
1409
|
force != '0' && force != 'false'
|
|
1339
1410
|
elsif (force = ENV['GIT_FORCE'] || ENV['REVBUILD_FORCE'])
|
|
@@ -1348,7 +1419,7 @@ module Squared
|
|
|
1348
1419
|
end
|
|
1349
1420
|
end
|
|
1350
1421
|
start = time_epoch
|
|
1351
|
-
ret = build(*@output, sync: sync, from:
|
|
1422
|
+
ret = build(*@output, sync: sync, from: from)
|
|
1352
1423
|
rescue => e
|
|
1353
1424
|
print_error(e, pass: true)
|
|
1354
1425
|
else
|
|
@@ -1356,7 +1427,7 @@ module Squared
|
|
|
1356
1427
|
print_status('revbuild', subject: name, start: start, loglevel: Logger::WARN, from: :failed)
|
|
1357
1428
|
workspace.rev_timeutc name, 'build'
|
|
1358
1429
|
else
|
|
1359
|
-
run_p(*Array(kwargs[:after]), sync: sync, from:
|
|
1430
|
+
run_p(*Array(kwargs[:after]), sync: sync, from: symjoin(from, 'after')) if kwargs[:after] && ret != false
|
|
1360
1431
|
print_status('revbuild', subject: name, start: start)
|
|
1361
1432
|
workspace.rev_write(name, { 'revision' => sha, 'files' => status_digest(*args, **kwargs) },
|
|
1362
1433
|
sync: sync, utc: 'build')
|
|
@@ -1463,7 +1534,7 @@ module Squared
|
|
|
1463
1534
|
ret
|
|
1464
1535
|
end
|
|
1465
1536
|
|
|
1466
|
-
def
|
|
1537
|
+
def log_(flag, opts = [], range: [], index: [], grep: [])
|
|
1467
1538
|
cmd, opts = git_session('log', opts: opts)
|
|
1468
1539
|
op = OptionPartition.new(opts, collect_hash(OPT_GIT[:log]), cmd, project: self, strict: strict?,
|
|
1469
1540
|
no: collect_hash(OPT_GIT[:no][:log]),
|
|
@@ -1512,7 +1583,8 @@ module Squared
|
|
|
1512
1583
|
op.add_quote(branch) if branch
|
|
1513
1584
|
if !index.empty?
|
|
1514
1585
|
if op.arg?('cached')
|
|
1515
|
-
|
|
1586
|
+
raise message('single commit only', index.join(', '), hint: flag) unless index.size == 1
|
|
1587
|
+
|
|
1516
1588
|
op << index.first
|
|
1517
1589
|
else
|
|
1518
1590
|
op.merge(index)
|
|
@@ -1575,9 +1647,9 @@ module Squared
|
|
|
1575
1647
|
next if line.empty?
|
|
1576
1648
|
|
|
1577
1649
|
branch, origin, hint = line.split('...')
|
|
1578
|
-
if hint && !hint.match?(/^\[(\D+0,\D+0)\]$/)
|
|
1579
|
-
|
|
1580
|
-
|
|
1650
|
+
raise message('work tree is not usable', hint: hint[1..-2]) if hint && !hint.match?(/^\[(\D+0,\D+0)\]$/)
|
|
1651
|
+
|
|
1652
|
+
if (!origin || origin.empty?) && !dryrun?
|
|
1581
1653
|
return nil if pass
|
|
1582
1654
|
|
|
1583
1655
|
unless (origin = option('upstream', prefix: 'git', ignore: false))
|
|
@@ -1610,7 +1682,7 @@ module Squared
|
|
|
1610
1682
|
elsif flag == :'amend-orig' || option('edit', equals: '0')
|
|
1611
1683
|
co << '--no-edit'
|
|
1612
1684
|
end
|
|
1613
|
-
pu << '--force-with-lease' if amend
|
|
1685
|
+
pu << (option('f', 'force') ? '--force' : '--force-with-lease') if amend
|
|
1614
1686
|
pu.merge(repotrack(origin, branch))
|
|
1615
1687
|
adding = git_spawn 'diff --name-only --no-color'
|
|
1616
1688
|
source op
|
|
@@ -1680,7 +1752,8 @@ module Squared
|
|
|
1680
1752
|
cmd << shell_quote(target)
|
|
1681
1753
|
cmd << shell_quote(ref) if ref
|
|
1682
1754
|
when :track
|
|
1683
|
-
|
|
1755
|
+
raise message('invalid upstream', hint: ref) unless ref.include?('/')
|
|
1756
|
+
|
|
1684
1757
|
if ref.delete_prefix!('^')
|
|
1685
1758
|
cmd << '--unset-upstream' << shell_quote(ref)
|
|
1686
1759
|
remote = false
|
|
@@ -1691,7 +1764,7 @@ module Squared
|
|
|
1691
1764
|
end
|
|
1692
1765
|
when :delete
|
|
1693
1766
|
remote&.each { |val| source git_output('push --delete', *val.split('/', 2).quote!) }
|
|
1694
|
-
force, list = refs.partition { |val| val.start_with?(
|
|
1767
|
+
force, list = refs.partition { |val| val.start_with?(/[~^]/) }
|
|
1695
1768
|
force.each do |val|
|
|
1696
1769
|
r = '-r' if val.delete!('~')
|
|
1697
1770
|
source git_output('branch', val.delete!('^') ? '-D' : '-d', r, shell_quote(val))
|
|
@@ -1738,15 +1811,15 @@ module Squared
|
|
|
1738
1811
|
data = line.sub(/^\*?\s+/, '').split(/\s+/, 3)
|
|
1739
1812
|
a = sub_style(data[0], theme[:inline], styles: (:underline if !first && line.start_with?('*')))
|
|
1740
1813
|
b = commitstyle data[1]
|
|
1741
|
-
|
|
1742
|
-
if (r1 =
|
|
1814
|
+
md = /\A(?:\[((?~\]\s))\]\s)?(.+)\z/m.match(data[2])
|
|
1815
|
+
if (r1 = md[1]) && r1 =~ /^(.+):(?: ([a-z]+) (\d+),)? ([a-z]+) (\d+)$/
|
|
1743
1816
|
write = ->(s1, s2) { "#{s1.capitalize.rjust(7)}: #{sub_style(s2, theme[:warn])}" }
|
|
1744
1817
|
r1 = $1
|
|
1745
1818
|
r2 = $2 && write.call($2, $3)
|
|
1746
1819
|
r3 = write.call($4, $5)
|
|
1747
1820
|
end
|
|
1748
1821
|
r1 = nil if r1 == "origin/#{data[0]}"
|
|
1749
|
-
["#{"\n" unless index == 0} Branch: #{a.subhint(r1)}", r2, r3, " Commit: #{b}", "Message: #{
|
|
1822
|
+
["#{"\n" unless index == 0} Branch: #{a.subhint(r1)}", r2, r3, " Commit: #{b}", "Message: #{md[2]}"]
|
|
1750
1823
|
.compact
|
|
1751
1824
|
.join("\n")
|
|
1752
1825
|
end
|
|
@@ -1902,9 +1975,9 @@ module Squared
|
|
|
1902
1975
|
list_result(ret, 'files', grep: op.extras, from: from)
|
|
1903
1976
|
end
|
|
1904
1977
|
|
|
1905
|
-
def git(flag, opts = [])
|
|
1978
|
+
def git(flag, opts = [], extras: [])
|
|
1906
1979
|
cmd, opts = git_session(flag, opts: opts)
|
|
1907
|
-
list = OPT_GIT[:git].fetch(flag, []) + OPT_GIT.fetch(flag, [])
|
|
1980
|
+
list = OPT_GIT[:git].fetch(flag, []) + OPT_GIT.fetch(flag, []).yield_self { |a| a.is_a?(Array) ? a : [] }
|
|
1908
1981
|
case flag
|
|
1909
1982
|
when :add
|
|
1910
1983
|
list.concat(OPT_GIT[:log][:diff_context])
|
|
@@ -1953,6 +2026,12 @@ module Squared
|
|
|
1953
2026
|
end
|
|
1954
2027
|
end
|
|
1955
2028
|
return source(git_session('status -s'), banner: false) unless append_pathspec(op.extras)
|
|
2029
|
+
when :remote
|
|
2030
|
+
op.unshift(*extras)
|
|
2031
|
+
op.adjoin('add')
|
|
2032
|
+
.add_first(expect: 'missing name')
|
|
2033
|
+
.add_first(expect: 'missing URL', quote: true)
|
|
2034
|
+
.clear
|
|
1956
2035
|
when :mv
|
|
1957
2036
|
refs = projectmap op.extras
|
|
1958
2037
|
raise 'no source/destination' unless refs.size > 1
|
|
@@ -1981,7 +2060,7 @@ module Squared
|
|
|
1981
2060
|
when :revert, :mv, :rm
|
|
1982
2061
|
source(sync: false, stderr: true)
|
|
1983
2062
|
else
|
|
1984
|
-
success?(source,
|
|
2063
|
+
success?(source, %i[remote sparse-checkout].include?(flag) || (flag == :add && !op.arg?('verbose')))
|
|
1985
2064
|
end
|
|
1986
2065
|
end
|
|
1987
2066
|
|
|
@@ -1993,7 +2072,7 @@ module Squared
|
|
|
1993
2072
|
build? && !!workspace.revfile
|
|
1994
2073
|
end
|
|
1995
2074
|
|
|
1996
|
-
def enabled?(
|
|
2075
|
+
def enabled?(**kwargs)
|
|
1997
2076
|
super || (kwargs[:base] == false && !!clone?)
|
|
1998
2077
|
end
|
|
1999
2078
|
|
|
@@ -2001,6 +2080,10 @@ module Squared
|
|
|
2001
2080
|
|
|
2002
2081
|
def source(cmd = @session, exception: true, io: false, sync: true, stdout: false, stderr: false, banner: true,
|
|
2003
2082
|
multiple: false, hint: nil, from: nil, timeout: nil, send: :system, **kwargs)
|
|
2083
|
+
unless cmd
|
|
2084
|
+
print_error('no git session started', subject: project, hint: from, pass: true)
|
|
2085
|
+
return
|
|
2086
|
+
end
|
|
2004
2087
|
cmd = cmd.target if cmd.is_a?(OptionPartition)
|
|
2005
2088
|
if io && banner == false
|
|
2006
2089
|
from = nil
|
|
@@ -2070,7 +2153,7 @@ module Squared
|
|
|
2070
2153
|
elsif stdout?
|
|
2071
2154
|
styles = theme.fetch(:banner, []).reject { |val| val.to_s.end_with?('!') }
|
|
2072
2155
|
styles << :bold if styles.size <= 1
|
|
2073
|
-
puts print_footer("#{size} #{size == 1 ? type.sub(/(
|
|
2156
|
+
puts print_footer("#{size} #{size == 1 ? type.sub(/((?<!l)e)?s\z/, '') : type}",
|
|
2074
2157
|
sub: opt_style(styles, /^(\d+)(.+)$/))
|
|
2075
2158
|
end
|
|
2076
2159
|
on :last, from
|
|
@@ -2159,7 +2242,7 @@ module Squared
|
|
|
2159
2242
|
end
|
|
2160
2243
|
op << '--verbose' if (flag || from == :fetch) && stdout? && !op.arg?('quiet')
|
|
2161
2244
|
if remote
|
|
2162
|
-
op.append(remote
|
|
2245
|
+
op.append(remote)
|
|
2163
2246
|
if (val = option('refspec', target: target, strict: true))
|
|
2164
2247
|
op.append(split_escape(val))
|
|
2165
2248
|
else
|
|
@@ -2277,14 +2360,24 @@ module Squared
|
|
|
2277
2360
|
stdout: stdout, banner: banner, **kwargs)
|
|
2278
2361
|
end
|
|
2279
2362
|
|
|
2280
|
-
def
|
|
2363
|
+
def git_grep(cmd, *grep, equals: true, **kwargs)
|
|
2364
|
+
ret = []
|
|
2365
|
+
git_spawn(cmd, **kwargs).lines(chomp: true).each do |line|
|
|
2366
|
+
if grep.any? { |val| val.is_a?(Regexp) ? val.match?(line) : equals ? line == val : line.include?(val) }
|
|
2367
|
+
ret << line
|
|
2368
|
+
end
|
|
2369
|
+
end
|
|
2370
|
+
ret
|
|
2371
|
+
end
|
|
2372
|
+
|
|
2373
|
+
def dryrun?(target: @session, prefix: target&.first, **)
|
|
2281
2374
|
Array(target).include?('--dry-run') || !option('dry-run', target: target, prefix: prefix).nil?
|
|
2282
2375
|
end
|
|
2283
2376
|
|
|
2284
|
-
def quiet?(
|
|
2285
|
-
return
|
|
2377
|
+
def quiet?(target: @session, **)
|
|
2378
|
+
return silent? unless target
|
|
2286
2379
|
|
|
2287
|
-
target.include?('--quiet') || (target.include?('-q') && target.first.stripext == 'git')
|
|
2380
|
+
silent? || target.include?('--quiet') || (target.include?('-q') && target.first.stripext == 'git')
|
|
2288
2381
|
end
|
|
2289
2382
|
|
|
2290
2383
|
def gitpath(*args)
|
|
@@ -2293,7 +2386,8 @@ module Squared
|
|
|
2293
2386
|
|
|
2294
2387
|
def repotrack(origin, branch, quote: true)
|
|
2295
2388
|
n = origin&.index('/')
|
|
2296
|
-
|
|
2389
|
+
raise message("missing #{origin ? 'branch' : 'remote'} name", hint: origin) unless n && branch
|
|
2390
|
+
|
|
2297
2391
|
branch = "#{branch}:#{origin[n.succ..-1]}" unless origin.end_with?("/#{branch}")
|
|
2298
2392
|
ret = [origin[0..n.pred], branch]
|
|
2299
2393
|
ret.quote! if quote
|