squared 0.8.3 → 0.8.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +112 -6
- data/README.md +8 -9
- data/lib/squared/common/base.rb +1 -0
- data/lib/squared/common/format.rb +2 -1
- data/lib/squared/common/host.rb +39 -0
- data/lib/squared/common/prompt.rb +4 -3
- data/lib/squared/common/shell.rb +13 -12
- data/lib/squared/common/utils.rb +7 -4
- data/lib/squared/common.rb +1 -0
- data/lib/squared/version.rb +1 -1
- data/lib/squared/workspace/application.rb +5 -27
- data/lib/squared/workspace/project/base.rb +41 -17
- data/lib/squared/workspace/project/docker.rb +215 -147
- data/lib/squared/workspace/project/git.rb +125 -113
- data/lib/squared/workspace/project/node.rb +69 -36
- data/lib/squared/workspace/project/python.rb +13 -9
- data/lib/squared/workspace/project/ruby.rb +13 -12
- data/lib/squared/workspace/project/support/optionpartition.rb +108 -53
- data/lib/squared/workspace/repo.rb +3 -2
- data/lib/squared/workspace/series.rb +2 -2
- metadata +3 -2
|
@@ -158,10 +158,10 @@ module Squared
|
|
|
158
158
|
no-replace-objects noglob-pathspecs paginate attr-source=b config-env=q exec-path=p
|
|
159
159
|
namespace=p].freeze,
|
|
160
160
|
add: %w[A e|edit f|force ignore-errors ignore-missing i|interactive n|dry-run p|patch pathspec-file-nul
|
|
161
|
-
refresh renormalize sparse u|update v|verbose chmod=b pathspec-from-file=p].freeze,
|
|
162
|
-
branch: %w[a|all create-reflog i|ignore-case omit-empty q|quiet r|remotes v|verbose=+ abbrev=i color=b
|
|
163
|
-
column=b contains=b format=q merged=b no-contains=b no-merged=b
|
|
164
|
-
sort=q t|track=b].freeze,
|
|
161
|
+
refresh renormalize resolved sparse u|update v|verbose chmod=b pathspec-from-file=p].freeze,
|
|
162
|
+
branch: %w[a|all create-reflog dry-run i|ignore-case omit-empty q|quiet r|remotes v|verbose=+ abbrev=i color=b
|
|
163
|
+
column=b contains=b delete-merged=q forked=q format=q merged=b no-contains=b no-merged=b
|
|
164
|
+
points-at=b u|set-upstream-to=b sort=q t|track=b].freeze,
|
|
165
165
|
checkout: %w[l d|detach f|force ignore-other-worktrees ignore-skip-worktree-bits m|merge p|patch
|
|
166
166
|
pathspec-file-nul q|quiet ours theirs conflict=b orphan=b pathspec-from-file=p t|track=b].freeze,
|
|
167
167
|
clone: %w[also-filter-submodules bare dissociate l|local mirror no-hardlinks n|no-checkout no-tags o|origin=b
|
|
@@ -214,8 +214,9 @@ module Squared
|
|
|
214
214
|
i|regexp-ignore-case remove-empty reverse right-only simplify-by-decoration simplify-merges
|
|
215
215
|
single-worktree show-pulls source sparse stdin topo-order g|walk-reflogs after=q ancestry-path=b?
|
|
216
216
|
author=q before=q branches=q? committer=q decorate=b decorate-refs=q decorate-refs-exclude=q
|
|
217
|
-
exclude=q exclude-hidden=b glob=q grep=q grep-reflog=q n|max-count=i max-
|
|
218
|
-
no-walk=b? remotes=q? since=q since-as-filter=q skip=i tags=q?
|
|
217
|
+
exclude=q exclude-hidden=b glob=q grep=q grep-reflog=q n|max-count=i max-count-oldest=i
|
|
218
|
+
max-parents=i min-parents=i no-walk=b? remotes=q? since=q since-as-filter=q skip=i tags=q?
|
|
219
|
+
until=q].freeze,
|
|
219
220
|
format: %w[t children combined-all-paths dd oneline left-right no-diff-merges parents relative-date
|
|
220
221
|
show-notes-by-default show-signature date=q diff-merges=b encoding=b expand-tabs=i format=q
|
|
221
222
|
notes=b pretty=q? show-linear-break=q?].freeze,
|
|
@@ -225,7 +226,7 @@ module Squared
|
|
|
225
226
|
graph ita-invisible-in-index minimal name-only name-status no-color-moved-ws no-prefix no-renames
|
|
226
227
|
numstat patch-with-raw patch-with-stat patience pickaxe-all pickaxe-regex raw shortstat summary
|
|
227
228
|
a|text abbrev=i? anchored=q break-rewrites=b? color=b color-moved=b color-moved-ws=b color-words=q?
|
|
228
|
-
diff-algorithm=b diff-filter=
|
|
229
|
+
diff-algorithm=b diff-filter=q? X|dirstat=b? dirstat-by-file=b? dst-prefix=q find-copies=i?
|
|
229
230
|
find-object=b find-renames=b? ignore-matching-lines=q ignore-submodules=b? line-prefix=q
|
|
230
231
|
max-depth=n output=p output-indicator-context=q output-indicator-new=q output-indicator-old=q
|
|
231
232
|
relative=p rotate-to=p skip-to=p src-prefix=q stat=b? stat-count=i stat-width=i stat-name-width=i
|
|
@@ -280,7 +281,7 @@ module Squared
|
|
|
280
281
|
push: %w[a|all u|include-untracked k|keep-index no-keep-index no-include-untracked pathspec-file-nul p|patch
|
|
281
282
|
S|staged m|message=q pathspec-from-file=p].freeze,
|
|
282
283
|
pop: %w[index].freeze,
|
|
283
|
-
apply: %w[index].freeze
|
|
284
|
+
apply: %w[index label-base=b label-ours=b label-theirs=b].freeze
|
|
284
285
|
}.freeze,
|
|
285
286
|
status: %w[z u=bm? b|branch long s|short show-stash v|verbose=+ column=b find-renames=i? ignore-submodules=b?
|
|
286
287
|
ignored=b? porcelain=b? untracked-files=b?].freeze,
|
|
@@ -413,7 +414,8 @@ module Squared
|
|
|
413
414
|
if flag == :remote
|
|
414
415
|
format_desc action, flag, 'remote?,opts*'
|
|
415
416
|
task flag, [:remote] do |_, args|
|
|
416
|
-
|
|
417
|
+
remote = args.remote
|
|
418
|
+
args = if remote && !git_grep('remote', remote).empty?
|
|
417
419
|
args.extras
|
|
418
420
|
else
|
|
419
421
|
remote = choice_remote
|
|
@@ -449,19 +451,21 @@ module Squared
|
|
|
449
451
|
task flag, [:commit] do |_, args|
|
|
450
452
|
ref = args.commit
|
|
451
453
|
if !ref || ref == ':'
|
|
452
|
-
ref = choice_commit('@{u}..',
|
|
454
|
+
ref = choice_commit(range: '@{u}..',
|
|
455
|
+
empty: log_message('No pending commits', hint: remotetrack))
|
|
453
456
|
end
|
|
454
457
|
push(flag, args.extras, ref: ref)
|
|
455
458
|
end
|
|
456
459
|
else
|
|
457
460
|
format_desc(action, flag, 'origin?,opts*', after: ('refs*' unless flag == :all))
|
|
458
|
-
task flag do |_, args|
|
|
459
|
-
|
|
460
|
-
if
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
461
|
+
task flag, [:origin] do |_, args|
|
|
462
|
+
origin = args.origin
|
|
463
|
+
args = if origin && !git_grep('remote', origin).empty?
|
|
464
|
+
args.extras
|
|
465
|
+
else
|
|
466
|
+
origin = nil
|
|
467
|
+
args.to_a
|
|
468
|
+
end
|
|
465
469
|
push(flag, args, origin: origin)
|
|
466
470
|
end
|
|
467
471
|
end
|
|
@@ -555,7 +559,8 @@ module Squared
|
|
|
555
559
|
when :add, :sign
|
|
556
560
|
format_desc action, flag, 'name,message?,commit?,remote?'
|
|
557
561
|
task flag, [:name, :message, :commit, :remote] do |_, args|
|
|
558
|
-
|
|
562
|
+
name = args.name
|
|
563
|
+
if name
|
|
559
564
|
message = args.message
|
|
560
565
|
commit = commithead args.commit
|
|
561
566
|
remote = args.remote
|
|
@@ -594,9 +599,10 @@ module Squared
|
|
|
594
599
|
format_desc action, flag, '(^)commit*|:,opts*,pathspec*'
|
|
595
600
|
task flag do |_, args|
|
|
596
601
|
args = args.to_a
|
|
597
|
-
if args
|
|
598
|
-
|
|
599
|
-
|
|
602
|
+
if choice!(args, empty: true)
|
|
603
|
+
index = choice_commit('Choose revision range', multiple: true, series: true)
|
|
604
|
+
exclude = choice_commit('With exclusions', multiple: true, force: false)
|
|
605
|
+
index.concat(exclude.map { |val| "^#{val}" }) if exclude
|
|
600
606
|
else
|
|
601
607
|
index = args.each_with_object([]) do |val, out|
|
|
602
608
|
if matchhead(val)
|
|
@@ -613,33 +619,32 @@ module Squared
|
|
|
613
619
|
end
|
|
614
620
|
log_(flag, args, index: index)
|
|
615
621
|
end
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
622
|
+
else
|
|
623
|
+
format_desc action, flag, 'commit1,commit2,opts*,pathspec*'
|
|
624
|
+
task flag, [:commit1, :commit2] do |_, args|
|
|
625
|
+
commit1 = commithead args.commit1
|
|
626
|
+
if commit1
|
|
627
|
+
range = [commit1, commithead(param_guard(action, flag, args: args, key: :commit2))]
|
|
628
|
+
opts = args.extras
|
|
629
|
+
else
|
|
630
|
+
range, opts, refs = choice_commit(multiple: flag == :view ? true : 2,
|
|
631
|
+
values: %w[Options Pathspec])
|
|
632
|
+
range.reverse!
|
|
633
|
+
opts = OptionPartition.strip(opts)
|
|
634
|
+
opts.concat(refs.shellsplit) if refs
|
|
635
|
+
end
|
|
636
|
+
if action == 'log'
|
|
637
|
+
log_(flag, opts, range: range)
|
|
638
|
+
else
|
|
639
|
+
diff(flag, opts, range: range, from: action.to_sym)
|
|
640
|
+
end
|
|
635
641
|
end
|
|
636
642
|
end
|
|
637
643
|
when :head
|
|
638
644
|
format_desc action, flag, 'commit*|:,opts*,pathspec*'
|
|
639
645
|
task flag do |_, args|
|
|
640
646
|
args = args.to_a
|
|
641
|
-
if args
|
|
642
|
-
args.shift
|
|
647
|
+
if choice!(args, empty: true)
|
|
643
648
|
index = choice_commit(multiple: true)
|
|
644
649
|
else
|
|
645
650
|
index = args.each_with_object([]) do |val, out|
|
|
@@ -681,10 +686,10 @@ module Squared
|
|
|
681
686
|
when 'i', 'E', 'F', 'P'
|
|
682
687
|
opts << last
|
|
683
688
|
else
|
|
684
|
-
if last =~ /^
|
|
689
|
+
if last =~ /^f(?:-ormat)?=(.+)$/
|
|
685
690
|
opts.shift
|
|
686
691
|
opts << "format=#{$1}"
|
|
687
|
-
elsif last =~ /^
|
|
692
|
+
elsif last =~ /^max(?:-count)?=(\d+)$/
|
|
688
693
|
opts << "max-count=#{$1}"
|
|
689
694
|
else
|
|
690
695
|
grep << last
|
|
@@ -699,9 +704,10 @@ module Squared
|
|
|
699
704
|
when 'checkout'
|
|
700
705
|
case flag
|
|
701
706
|
when :branch
|
|
702
|
-
format_desc action, flag, '
|
|
703
|
-
task flag, [:
|
|
704
|
-
|
|
707
|
+
format_desc action, flag, 'branch,create?=[bB],commit?,d/etach?'
|
|
708
|
+
task flag, [:branch, :create, :commit, :detach] do |_, args|
|
|
709
|
+
branch = args.branch
|
|
710
|
+
if branch
|
|
705
711
|
create = args.create
|
|
706
712
|
detach = if args.commit == 'd'
|
|
707
713
|
commit = nil
|
|
@@ -725,9 +731,10 @@ module Squared
|
|
|
725
731
|
checkout(flag, branch: branch, create: create, commit: commit, detach: detach)
|
|
726
732
|
end
|
|
727
733
|
when :track
|
|
728
|
-
format_desc action, flag, '
|
|
729
|
-
task flag, [:
|
|
730
|
-
|
|
734
|
+
format_desc action, flag, 'remote,(^)name?'
|
|
735
|
+
task flag, [:remote, :name] do |_, args|
|
|
736
|
+
origin = args.remote
|
|
737
|
+
if origin
|
|
731
738
|
branch = args.name
|
|
732
739
|
else
|
|
733
740
|
origin, branch = choice_refs('Choose a remote', 'remotes', values: 'Enter branch name')
|
|
@@ -778,7 +785,8 @@ module Squared
|
|
|
778
785
|
when :track
|
|
779
786
|
format_desc action, flag, '(^~)upstream?,name?'
|
|
780
787
|
task flag, [:upstream, :name] do |_, args|
|
|
781
|
-
|
|
788
|
+
ref = args.upstream
|
|
789
|
+
if ref
|
|
782
790
|
target = args.name
|
|
783
791
|
remote = true if ref.delete_prefix!('~')
|
|
784
792
|
else
|
|
@@ -791,12 +799,12 @@ module Squared
|
|
|
791
799
|
format_desc action, flag, '[^~]name*,:?'
|
|
792
800
|
task flag do |_, args|
|
|
793
801
|
refs = args.to_a
|
|
794
|
-
if refs.empty? || (
|
|
802
|
+
if refs.empty? || (ia = refs.last == ':')
|
|
795
803
|
accept = ['Delete?']
|
|
796
|
-
accept << accept_b('Force?') unless
|
|
797
|
-
remote = choice_refs('Choose a branch',
|
|
798
|
-
|
|
799
|
-
if
|
|
804
|
+
accept << accept_b('Force?') unless ia
|
|
805
|
+
remote = choice_refs('Choose a branch', ia ? 'remotes' : 'heads', multiple: true,
|
|
806
|
+
accept: accept)
|
|
807
|
+
if ia
|
|
800
808
|
refs.pop
|
|
801
809
|
else
|
|
802
810
|
refs = remote.first
|
|
@@ -814,7 +822,8 @@ module Squared
|
|
|
814
822
|
when :move, :copy
|
|
815
823
|
format_desc action, flag, 'branch,oldbranch?'
|
|
816
824
|
task flag, [:branch, :oldbranch] do |_, args|
|
|
817
|
-
|
|
825
|
+
branch = args.branch
|
|
826
|
+
if branch
|
|
818
827
|
oldbranch = args.oldbranch
|
|
819
828
|
else
|
|
820
829
|
oldbranch, branch = choice_refs("Choose a branch to #{flag}",
|
|
@@ -831,18 +840,19 @@ module Squared
|
|
|
831
840
|
when 'clone'
|
|
832
841
|
format_desc(action, flag, flag == :tag ? 'dir,tag/:' : 'dir,branch/:', after: 'opts*')
|
|
833
842
|
task flag, [:dir, :ref] do |_, args|
|
|
834
|
-
dir =
|
|
835
|
-
|
|
843
|
+
dir = param_guard(action, flag, args: args, key: :dir)
|
|
844
|
+
ref = args.ref
|
|
845
|
+
if !ref || ref == ':'
|
|
836
846
|
ref = flag == :tag ? choice_refs('Choose a tag', 'tags') : choice_refs('Choose a branch')
|
|
837
847
|
end
|
|
838
|
-
clone(flag, args.extras, dir: dir, ref: ref)
|
|
848
|
+
clone(flag, args.extras, dir: emptypath(dir, create: false), ref: ref)
|
|
839
849
|
end
|
|
840
850
|
when 'switch'
|
|
841
851
|
case flag
|
|
842
852
|
when :create
|
|
843
|
-
format_desc action, flag, '(^)
|
|
844
|
-
task flag, [:
|
|
845
|
-
branch = param_guard(action, flag, args: args, key: :
|
|
853
|
+
format_desc action, flag, '(^)branch,commit?|:'
|
|
854
|
+
task flag, [:branch, :commit] do |_, args|
|
|
855
|
+
branch = param_guard(action, flag, args: args, key: :branch)
|
|
846
856
|
commit = commithead args.commit
|
|
847
857
|
commit, track = choice_commit(force: false, values: 'Track? [Y/n]') if commit == ':'
|
|
848
858
|
switch(flag, branch: branch, commit: commit, track: track)
|
|
@@ -855,15 +865,11 @@ module Squared
|
|
|
855
865
|
switch(flag, commit: commit)
|
|
856
866
|
end
|
|
857
867
|
when :branch
|
|
858
|
-
format_desc action, flag, '
|
|
859
|
-
task flag, [:
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
else
|
|
864
|
-
[]
|
|
865
|
-
end
|
|
866
|
-
switch(flag, args, branch: branch || choice_refs('Choose a branch'))
|
|
868
|
+
format_desc action, flag, 'branch/:,opts*'
|
|
869
|
+
task flag, [:branch] do |_, args|
|
|
870
|
+
branch = args.branch
|
|
871
|
+
branch = nil if branch == ':'
|
|
872
|
+
switch(flag, args.extras, branch: branch || choice_refs('Choose a branch'))
|
|
867
873
|
end
|
|
868
874
|
end
|
|
869
875
|
when 'reset'
|
|
@@ -872,17 +878,16 @@ module Squared
|
|
|
872
878
|
format_desc action, flag, 'commit?|:,opts*'
|
|
873
879
|
task flag, [:commit] do |_, args|
|
|
874
880
|
commit = commithead args.commit
|
|
875
|
-
args =
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
end
|
|
881
|
+
args = args.extras
|
|
882
|
+
if !commit || commit == ':'
|
|
883
|
+
commit, mode = choice_commit(values: ['Mode [mixed|soft|hard|N]'])
|
|
884
|
+
args.concat(case mode&.downcase
|
|
885
|
+
when 'h', 'hard' then ['hard']
|
|
886
|
+
when 's', 'soft' then ['soft']
|
|
887
|
+
when 'n', 'N' then %w[mixed N]
|
|
888
|
+
else ['mixed']
|
|
889
|
+
end)
|
|
890
|
+
end
|
|
886
891
|
success?(reset(flag, args, commit: commit))
|
|
887
892
|
end
|
|
888
893
|
when :index
|
|
@@ -931,9 +936,11 @@ module Squared
|
|
|
931
936
|
when 'rebase', 'merge'
|
|
932
937
|
case flag
|
|
933
938
|
when :branch
|
|
934
|
-
format_desc action, flag, 'upstream
|
|
939
|
+
format_desc action, flag, 'upstream?|:,opts*'
|
|
935
940
|
task flag, [:upstream] do |_, args|
|
|
936
|
-
|
|
941
|
+
upstream = args.upstream
|
|
942
|
+
args = if upstream
|
|
943
|
+
upstream = choice_refs 'Choose upstream branch' if upstream == ':'
|
|
937
944
|
args.extras
|
|
938
945
|
else
|
|
939
946
|
upstream, opts = choice_refs('Choose upstream branch', values: 'Options')
|
|
@@ -961,8 +968,9 @@ module Squared
|
|
|
961
968
|
when :commit, :'no-commit'
|
|
962
969
|
format_desc action, flag, 'branch|:,ours|theirs?,opts*'
|
|
963
970
|
task flag, [:branch] do |_, args|
|
|
964
|
-
|
|
965
|
-
|
|
971
|
+
branch = args.branch
|
|
972
|
+
current = git_spawn('branch --show-current').chomp
|
|
973
|
+
if branch
|
|
966
974
|
branch = choice_refs('Choose a branch', accept: "#{action.capitalize}?") if branch == ':'
|
|
967
975
|
opts = args.extras
|
|
968
976
|
if has_value!(opts, 'ours')
|
|
@@ -975,9 +983,11 @@ module Squared
|
|
|
975
983
|
accept: "Merge with #{current}?")
|
|
976
984
|
opts = OptionPartition.strip(opts)
|
|
977
985
|
end
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
986
|
+
if current == branch
|
|
987
|
+
puts log_message('nothing to merge', subject: name, hint: branch)
|
|
988
|
+
else
|
|
989
|
+
merge(flag, opts, branch: branch)
|
|
990
|
+
end
|
|
981
991
|
end
|
|
982
992
|
when :send
|
|
983
993
|
format_desc(action, flag, VAL_GIT[action.to_sym][:send], arg: nil)
|
|
@@ -994,7 +1004,7 @@ module Squared
|
|
|
994
1004
|
task flag, [:ref, :size] do |_, args|
|
|
995
1005
|
ref = commithead args.ref
|
|
996
1006
|
size = args.size
|
|
997
|
-
if !size && ref.to_i.between?(
|
|
1007
|
+
if !size && ref.to_i.between?(4, 40)
|
|
998
1008
|
size = ref
|
|
999
1009
|
ref = nil
|
|
1000
1010
|
end
|
|
@@ -1023,7 +1033,8 @@ module Squared
|
|
|
1023
1033
|
if flag == :remote
|
|
1024
1034
|
format_desc action, flag, 'remote?|:,opts*,pattern*'
|
|
1025
1035
|
task flag, [:remote] do |_, args|
|
|
1026
|
-
|
|
1036
|
+
remote = args.remote
|
|
1037
|
+
args = if remote && (remote == ':' || !git_grep('remote', remote).empty?)
|
|
1027
1038
|
remote = choice_remote(force: true) if remote == ':'
|
|
1028
1039
|
args.extras
|
|
1029
1040
|
else
|
|
@@ -1501,7 +1512,7 @@ module Squared
|
|
|
1501
1512
|
else
|
|
1502
1513
|
args = parse_env('GIT_OPTIONS')
|
|
1503
1514
|
.grep(/\A--#{Regexp.union(*VAL_GIT[:revbuild])}/)
|
|
1504
|
-
.concat(VAL_GIT[:revbuild].map { |key| option(key, prefix: 'git') { |val| basic_option
|
|
1515
|
+
.concat(VAL_GIT[:revbuild].map { |key| option(key, prefix: 'git') { |val| basic_option key, val } })
|
|
1505
1516
|
.compact
|
|
1506
1517
|
OptionPartition.uniq!(args)
|
|
1507
1518
|
end
|
|
@@ -1522,7 +1533,7 @@ module Squared
|
|
|
1522
1533
|
start = time_epoch
|
|
1523
1534
|
ret = build(*@output, sync: sync, from: from)
|
|
1524
1535
|
rescue => e
|
|
1525
|
-
print_error(e, pass: true)
|
|
1536
|
+
print_error(e, subject: name, pass: true)
|
|
1526
1537
|
else
|
|
1527
1538
|
if ret == false && !kwargs[:pass]
|
|
1528
1539
|
print_status('revbuild', subject: name, start: start, loglevel: Logger::WARN, from: :failed)
|
|
@@ -1568,7 +1579,7 @@ module Squared
|
|
|
1568
1579
|
unless force
|
|
1569
1580
|
i = -1
|
|
1570
1581
|
op.each do |val|
|
|
1571
|
-
if !val.include?(':') && repofetch(origin, branch: val, sync: (i += 1)
|
|
1582
|
+
if !val.include?(':') && repofetch(origin, branch: val, sync: (i += 1) == 0).first.nil?
|
|
1572
1583
|
op.errors << val
|
|
1573
1584
|
else
|
|
1574
1585
|
op.found << val
|
|
@@ -1624,7 +1635,7 @@ module Squared
|
|
|
1624
1635
|
append_option 'f', 'force', 'merge'
|
|
1625
1636
|
case flag
|
|
1626
1637
|
when :branch
|
|
1627
|
-
cmd << '--detach' if detach == 'd' || option('detach')
|
|
1638
|
+
cmd << '--detach' if detach == 'd' || option('d', 'detach')
|
|
1628
1639
|
append_option('track', equals: true)
|
|
1629
1640
|
cmd << (create ? quote_option(create, branch) : branch) << commit
|
|
1630
1641
|
when :track
|
|
@@ -1652,7 +1663,7 @@ module Squared
|
|
|
1652
1663
|
cmd, opts = git_session('tag', opts: opts)
|
|
1653
1664
|
case flag
|
|
1654
1665
|
when :add, :sign
|
|
1655
|
-
if flag == :sign
|
|
1666
|
+
if flag == :sign
|
|
1656
1667
|
cmd << '--sign'
|
|
1657
1668
|
elsif !session_arg?('s', 'sign', 'u', 'local-user')
|
|
1658
1669
|
cmd << '--annotate'
|
|
@@ -1812,8 +1823,10 @@ module Squared
|
|
|
1812
1823
|
return if pass
|
|
1813
1824
|
|
|
1814
1825
|
upstream = true
|
|
1815
|
-
|
|
1816
|
-
|
|
1826
|
+
origin = option('origin', 'upstream', prefix: 'git', ignore: false)
|
|
1827
|
+
unless origin
|
|
1828
|
+
origin = choice_refs('Choose an upstream', 'remotes', attempts: 1, force: false)
|
|
1829
|
+
if origin
|
|
1817
1830
|
git_spawn 'branch', quote_option('set-upstream-to', origin)
|
|
1818
1831
|
upstream = false
|
|
1819
1832
|
else
|
|
@@ -1963,7 +1976,7 @@ module Squared
|
|
|
1963
1976
|
out, banner, from = source(io: true)
|
|
1964
1977
|
first = from_base?('branch')
|
|
1965
1978
|
grep = first ? [/^\*\s+#{Regexp.escape(head)}\s/] : []
|
|
1966
|
-
ret = write_lines(out, grep: grep, banner: banner, first: first) do |line,
|
|
1979
|
+
ret = write_lines(out, grep: grep, banner: banner, first: first) do |line, i|
|
|
1967
1980
|
next line if stdin?
|
|
1968
1981
|
|
|
1969
1982
|
data = line.sub(/^\*?\s+/, '').split(/\s+/, 3)
|
|
@@ -1977,13 +1990,13 @@ module Squared
|
|
|
1977
1990
|
r3 = write.call($4, $5)
|
|
1978
1991
|
end
|
|
1979
1992
|
r1 = nil if r1 == "origin/#{data[0]}"
|
|
1980
|
-
["#{"\n" unless
|
|
1993
|
+
["#{"\n" unless i == 0} Branch: #{a.subhint(r1)}", r2, r3, " Commit: #{b}", "Message: #{md[2]}"]
|
|
1981
1994
|
.compact
|
|
1982
1995
|
.join("\n")
|
|
1983
1996
|
end
|
|
1984
1997
|
on :last, from
|
|
1985
1998
|
end
|
|
1986
|
-
print_error(
|
|
1999
|
+
print_error('no ref found', subject: name, hint: 'branch: head', pass: true) if ret == 0
|
|
1987
2000
|
return
|
|
1988
2001
|
end
|
|
1989
2002
|
return unless success?(source(stdout: stdout), !ref && flag == :create) && !ref && remote && target
|
|
@@ -2047,7 +2060,7 @@ module Squared
|
|
|
2047
2060
|
cmd << '--textconv'
|
|
2048
2061
|
append_value(files.flat_map { |val| Dir[val] }
|
|
2049
2062
|
.select { |val| projectpath?(val) }
|
|
2050
|
-
.map { |val|
|
|
2063
|
+
.map { |val| "HEAD:#{val}" })
|
|
2051
2064
|
source(banner: false)
|
|
2052
2065
|
return
|
|
2053
2066
|
when :oneline
|
|
@@ -2061,11 +2074,11 @@ module Squared
|
|
|
2061
2074
|
else
|
|
2062
2075
|
opts << format if format
|
|
2063
2076
|
end
|
|
2064
|
-
list = OPT_GIT[:show] + OPT_GIT[:diff][:show] + OPT_GIT[:log]
|
|
2077
|
+
list = OPT_GIT[:show] + OPT_GIT[:diff][:show] + collect_hash(OPT_GIT[:log], pass: [:base])
|
|
2065
2078
|
op = OptionPartition.new(opts, list, cmd,
|
|
2066
2079
|
project: self, strict: strict?,
|
|
2067
2080
|
no: OPT_GIT[:no][:show] + collect_hash(OPT_GIT[:no][:log], pass: [:base]))
|
|
2068
|
-
op.append
|
|
2081
|
+
op.append
|
|
2069
2082
|
source(exception: false, banner: flag != :oneline)
|
|
2070
2083
|
end
|
|
2071
2084
|
|
|
@@ -2073,7 +2086,7 @@ module Squared
|
|
|
2073
2086
|
cmd, opts = git_session('rev-parse', opts: opts)
|
|
2074
2087
|
case flag
|
|
2075
2088
|
when :commit
|
|
2076
|
-
cmd << (size.to_i
|
|
2089
|
+
cmd << (size.to_i == 0 ? '--verify' : basic_option('short', [size.to_i, 5].max))
|
|
2077
2090
|
append_commit(ref, head: true)
|
|
2078
2091
|
when :branch
|
|
2079
2092
|
cmd << '--abbrev-ref' << '--symbolic-full-name' << shell_quote(case ref
|
|
@@ -2141,8 +2154,7 @@ module Squared
|
|
|
2141
2154
|
when :'sparse-checkout'
|
|
2142
2155
|
cmd << 'set'
|
|
2143
2156
|
end
|
|
2144
|
-
op = OptionPartition.new(opts, list, cmd, project: self, strict: strict?,
|
|
2145
|
-
no: OPT_GIT[:no][flag], single: /\A\d+\z/,
|
|
2157
|
+
op = OptionPartition.new(opts, list, cmd, project: self, strict: strict?, no: OPT_GIT[:no][flag],
|
|
2146
2158
|
first: case flag
|
|
2147
2159
|
when :blame, :revert, :'sparse-checkout' then nil
|
|
2148
2160
|
else matchpathspec
|
|
@@ -2291,7 +2303,7 @@ module Squared
|
|
|
2291
2303
|
run_e(cmd, stderr: stderr, banner: banner, **kwargs)
|
|
2292
2304
|
end
|
|
2293
2305
|
rescue Timeout::Error => e
|
|
2294
|
-
print_error(Logger::ERROR,
|
|
2306
|
+
print_error(Logger::ERROR, e, subject: name, hint: cmd)
|
|
2295
2307
|
exit 1 unless exception?(Logger::DEBUG, Logger::INFO)
|
|
2296
2308
|
rescue => e
|
|
2297
2309
|
on_error(e, pass: true)
|
|
@@ -2329,12 +2341,12 @@ module Squared
|
|
|
2329
2341
|
choice_index(msg, foreachref(type, *args, format: format), trim: trim, **kwargs)
|
|
2330
2342
|
end
|
|
2331
2343
|
|
|
2332
|
-
def choice_commit(
|
|
2344
|
+
def choice_commit(msg = 'Choose a commit', range: nil, count: true, reflog: true, force: true, **kwargs)
|
|
2333
2345
|
kwargs[:attempts] ||= 1 unless force
|
|
2334
2346
|
cmd = git_output(reflog && env('GIT_REFLOG') ? 'reflog' : 'log', range)
|
|
2335
2347
|
cmd << quote_option('format', "#{commitstyle('%h')} %s")
|
|
2336
2348
|
cmd << basic_option('max-count', env('GIT_COUNT', ARG[:CHOICE])) if count
|
|
2337
|
-
ret = choice_index(
|
|
2349
|
+
ret = choice_index(msg, git_spawn(cmd, stdout: false), column: /^(\S+)/, force: force, **kwargs)
|
|
2338
2350
|
case ret
|
|
2339
2351
|
when Array
|
|
2340
2352
|
ret.map { |val| val&.stripstyle }
|
|
@@ -2480,7 +2492,7 @@ module Squared
|
|
|
2480
2492
|
def foreachref(path, *args, format: nil, chomp: true)
|
|
2481
2493
|
format &&= quote_option('format', format)
|
|
2482
2494
|
ret = git_spawn('for-each-ref', format, *args.concat(Array(path).map { |val| "refs/#{val}" }),
|
|
2483
|
-
stdout:
|
|
2495
|
+
stdout: windows?)
|
|
2484
2496
|
if ret.is_a?(String)
|
|
2485
2497
|
ret.lines(chomp: chomp)
|
|
2486
2498
|
elsif chomp
|
|
@@ -2565,7 +2577,7 @@ module Squared
|
|
|
2565
2577
|
end
|
|
2566
2578
|
|
|
2567
2579
|
def remotetrack
|
|
2568
|
-
git_spawn('rev-parse --abbrev-ref @{u}').split('/'
|
|
2580
|
+
git_spawn('rev-parse --abbrev-ref @{u}').split('/').first
|
|
2569
2581
|
end
|
|
2570
2582
|
|
|
2571
2583
|
def commithash(val)
|