squared 0.6.14 → 0.6.16

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: bf000f3929e009426b937626a3935e366f952b7faccfe57b7217c2f6bac02975
4
- data.tar.gz: 8612731d94dda35b871c85dc08f8e35a54c061d40e0846861ca70696a65e7abc
3
+ metadata.gz: a26491045e0e9a54898e1d36dd86702354e6ae5c13fd26f81cb8a3f40a495782
4
+ data.tar.gz: 945d788953e1a6fc6fbd8630d68653fd19b1e4f70fb2ffce4645661ffe4ed00e
5
5
  SHA512:
6
- metadata.gz: eda3163e0814ff4b26022284f187ad5137d229cfdc847ee86979fc1a1ec770b640de4261af38cff5df41878bd691d6f180dfb13b9bbd801ac22fad904e77d087
7
- data.tar.gz: fe40717e98e88842f50c3c253ca2bc7df7164a4d95a90c89f4f3f87b359c389a77cd49f4a68786bb98575d56f5100d77483f4ba6410b20001af8d251d556a965
6
+ metadata.gz: 8cd5453e7e5a42d466eaf17b56775ac19b2d7e1c2e2a04d2d4daf68bc4ca0700cbed58037c70f0bd101e9e55f0667f2cee30e014714548cf6d05dbb1390bc9bb
7
+ data.tar.gz: 68bc4817d3f0ea3d99197e23dad1e21f94ad70dbc0c1afb96cbc4fab5e6bc9a7fcf85a8e6c80d90616367ea5cbe7db92cebdf95207c6a299d5ed2d68cf781edd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.16] - 2026-07-04
4
+
5
+ ### Added
6
+
7
+ - Git command pull action all supports filter pattern negation.
8
+
9
+ ## [0.5.25] - 2026-07-04
10
+
11
+ ### Fixed
12
+
13
+ - See `0.4.39`.
14
+
15
+ ## [0.4.39] - 2026-07-04
16
+
17
+ ### Changed
18
+
19
+ - Common global argument OUT with a file separator overrides PIPE.
20
+
21
+ ### Fixed
22
+
23
+ - Git output list results did not hide footer when banner was disabled.
24
+ - Project banners which were empty were being printed.
25
+
26
+ ## [0.6.15] - 2026-06-17
27
+
28
+ ### Fixed
29
+
30
+ - Project classes did not switch from stdout to stdin.
31
+
3
32
  ## [0.6.14] - 2026-06-14
4
33
 
5
34
  ### Added
@@ -1711,6 +1740,8 @@
1711
1740
 
1712
1741
  - Changelog was created.
1713
1742
 
1743
+ [0.6.16]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.16
1744
+ [0.6.15]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.15
1714
1745
  [0.6.14]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.14
1715
1746
  [0.6.13]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.13
1716
1747
  [0.6.12]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.12
@@ -1726,6 +1757,7 @@
1726
1757
  [0.6.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.2
1727
1758
  [0.6.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.1
1728
1759
  [0.6.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.6.0
1760
+ [0.5.25]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.25
1729
1761
  [0.5.24]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.24
1730
1762
  [0.5.23]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.23
1731
1763
  [0.5.22]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.22
@@ -1751,6 +1783,7 @@
1751
1783
  [0.5.2]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.2-ruby
1752
1784
  [0.5.1]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.1-ruby
1753
1785
  [0.5.0]: https://github.com/anpham6/squared-ruby/releases/tag/v0.5.0-ruby
1786
+ [0.4.39]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.39
1754
1787
  [0.4.38]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.38
1755
1788
  [0.4.37]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.37
1756
1789
  [0.4.36]: https://github.com/anpham6/squared-ruby/releases/tag/v0.4.36
@@ -173,11 +173,19 @@ module Squared
173
173
  end
174
174
 
175
175
  def env_pipe(key, default = 1, suffix: nil, strict: false, root: nil)
176
+ out = 1
176
177
  case key
177
178
  when ::String
178
179
  case (ret = env_value(key, suffix: suffix, strict: strict))
179
180
  when '0', '1', '2'
180
181
  return ret.to_i
182
+ else
183
+ out = default if default.is_a?(::Numeric)
184
+ if ret.include?(File::SEPARATOR)
185
+ default = ret
186
+ elsif key.include?(File::SEPARATOR)
187
+ default = key
188
+ end
181
189
  end
182
190
  when ::Numeric
183
191
  return key if key.between?(0, 2)
@@ -188,7 +196,7 @@ module Squared
188
196
  (root ? Pathname.new(root) + default : Pathname.new(default)).realdirpath
189
197
  rescue StandardError => e
190
198
  warn e
191
- 1
199
+ out
192
200
  end
193
201
  end
194
202
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.6.14'
4
+ VERSION = '0.6.16'
5
5
  end
@@ -116,7 +116,13 @@ module Squared
116
116
  @extensions = []
117
117
  @envname = env_key(@main).freeze
118
118
  self.exception = env_bool exception
119
- self.pipe = $DEBUG ? 2 : env_pipe(pipe, (ARG[:OUT] && env(ARG[:OUT])) || 1, root: @home)
119
+ self.pipe = if $DEBUG
120
+ 2
121
+ elsif (out = ARG[:OUT]) && out.include?(File::SEPARATOR)
122
+ env_pipe(out, pipe, root: home)
123
+ else
124
+ env_pipe(pipe, (out && env(out)) || 1, root: home)
125
+ end
120
126
  self.verbose = if $VERBOSE.nil?
121
127
  false
122
128
  elsif verbose.nil?
@@ -1551,7 +1551,7 @@ module Squared
1551
1551
  def print_item(*val, series: false)
1552
1552
  puts unless printfirst?
1553
1553
  printsucc unless series
1554
- puts val unless val.empty? || (val.size == 1 && !val.first)
1554
+ puts val unless val.empty? || (val.size == 1 && (!val.first || val.first.empty?))
1555
1555
  end
1556
1556
 
1557
1557
  def print_banner(*lines, client: false, styles: theme[:banner], border: borderstyle, **)
@@ -2053,13 +2053,29 @@ module Squared
2053
2053
  files.map { |val| val == '.' ? '.' : shell_quote(basepath(val)) }
2054
2054
  end
2055
2055
 
2056
- def matchmap(list, prefix = nil)
2057
- list.map do |val|
2058
- next val if val.is_a?(Regexp)
2059
-
2060
- val = ".*#{val}" if prefix && !val.sub!(/\A(\^|\\A)/, '')
2061
- Regexp.new("#{prefix}#{val == '*' ? '.+' : val}")
2056
+ def matchmap(list, prefix = nil, negate: false)
2057
+ ret = negate ? [[], []] : []
2058
+ list.each do |val|
2059
+ unless val.is_a?(Regexp)
2060
+ val = val.dup
2061
+ n = 1 if negate && val.delete_prefix!('!')
2062
+ if prefix
2063
+ a = nil
2064
+ val.sub!(/\A(\^|\\A)/) do |s|
2065
+ a = s
2066
+ nil
2067
+ end
2068
+ val = ".*#{val}" unless a
2069
+ end
2070
+ end
2071
+ pat = Regexp.new("#{a}#{prefix}#{val == '*' ? '.+' : val}")
2072
+ if negate
2073
+ ret[n || 0] << pat
2074
+ else
2075
+ ret << pat
2076
+ end
2062
2077
  end
2078
+ ret
2063
2079
  end
2064
2080
 
2065
2081
  def semver(val)
@@ -2509,7 +2525,7 @@ module Squared
2509
2525
  end
2510
2526
 
2511
2527
  def stdout?
2512
- !quiet? && !stdin?
2528
+ !silent? && !stdin?
2513
2529
  end
2514
2530
 
2515
2531
  def verbose?
@@ -267,7 +267,7 @@ module Squared
267
267
  end
268
268
  end
269
269
  else
270
- format_desc action, flag, "opts*,id/name#{flag == :update ? '+' : '*'}"
270
+ format_desc action, flag, "opts*,id/name#{flag == :update || flag == :inspect ? '+' : '*'}"
271
271
  task flag do |_, args|
272
272
  container flag, args.to_a
273
273
  end
@@ -501,7 +501,7 @@ module Squared
501
501
  end
502
502
  end
503
503
  append_command(flag, id || tagmain, op.extras)
504
- when :update
504
+ when :update, :inspect
505
505
  raise_error ArgumentError, 'missing container', hint: flag if op.empty?
506
506
  op.append(escape: true, strip: /^:/)
507
507
  when :commit
@@ -1010,14 +1010,14 @@ module Squared
1010
1010
  end
1011
1011
  op = OptionPartition.new(opts, OPT_GIT[:pull], cmd, project: self, no: OPT_GIT[:no][:pull])
1012
1012
  opts -= op.extras
1013
- reg = matchmap op
1013
+ reg, neg = matchmap(op, negate: true)
1014
1014
  session_done op.target
1015
1015
  heads = []
1016
1016
  cur = nil
1017
1017
  foreachref('heads', format: '%(if)%(HEAD)%(then)* %(end)%(refname:short)').each do |line|
1018
1018
  line.chomp!
1019
1019
  cur ||= line.delete_prefix!('* ')
1020
- heads << line if matchany?(line, reg)
1020
+ heads << line if matchany?(line, reg) && !matchany?(neg, line, empty: false)
1021
1021
  end
1022
1022
  raise_error 'head not found', hint: 'for-each-ref' unless cur
1023
1023
  opts << 'ff-only' if opts.empty? && !option('ff-only', equals: '0')
@@ -1186,7 +1186,7 @@ module Squared
1186
1186
  op.clear
1187
1187
  out, banner, from = source(io: true)
1188
1188
  print_item banner
1189
- list_result(write_lines(out), 'objects', from: from)
1189
+ list_result(write_lines(out), 'objects', banner: banner, from: from)
1190
1190
  return
1191
1191
  end
1192
1192
  else
@@ -1235,7 +1235,7 @@ module Squared
1235
1235
  end
1236
1236
  out, banner, from = source(io: true)
1237
1237
  ret = write_lines(out, banner: banner, sub: sub)
1238
- list_result(ret, 'files', action: 'modified', from: from)
1238
+ list_result(ret, 'files', action: 'modified', banner: banner, from: from)
1239
1239
  end
1240
1240
 
1241
1241
  def revbuild(flag = nil, opts = [], sync: nil, **kwargs)
@@ -1376,7 +1376,7 @@ module Squared
1376
1376
  out, banner, from = source(io: true)
1377
1377
  print_item banner
1378
1378
  ret = write_lines(out, grep: op.extras)
1379
- list_result(ret, 'tags', grep: op.extras, from: from)
1379
+ list_result(ret, 'tags', grep: op.extras, banner: banner, from: from)
1380
1380
  return
1381
1381
  end
1382
1382
  remote ||= option('remote')
@@ -1385,9 +1385,9 @@ module Squared
1385
1385
 
1386
1386
  def log!(flag, opts = [], range: [], index: [], grep: [])
1387
1387
  cmd, opts = git_session('log', opts: opts)
1388
- op = OptionPartition.new(opts, collect_hash(OPT_GIT[:log]), cmd, project: self,
1389
- no: collect_hash(OPT_GIT[:no][:log]),
1390
- first: matchpathspec)
1388
+ op = OptionPartition.new(opts, collect_hash(OPT_GIT[:log]), cmd,
1389
+ project: self, no: collect_hash(OPT_GIT[:no][:log]),
1390
+ first: matchpathspec)
1391
1391
  case flag
1392
1392
  when :between, :contain
1393
1393
  op.add_quote(range.join(flag == :between ? '..' : '...'))
@@ -1632,7 +1632,7 @@ module Squared
1632
1632
  opt_style(color(:green), /^(\*\s+)(\S+)(.*)$/, 2),
1633
1633
  opt_style(color(:red), %r{^(\s*)(remotes/\S+)(.*)$}, 2)
1634
1634
  ])
1635
- list_result(ret, 'branches', from: from)
1635
+ list_result(ret, 'branches', banner: banner, from: from)
1636
1636
  return
1637
1637
  else
1638
1638
  if (head = git_spawn('rev-parse --abbrev-ref HEAD').chomp).empty?
@@ -1641,7 +1641,7 @@ module Squared
1641
1641
  git_spawn 'fetch --all --prune --quiet' if option('sync')
1642
1642
  cmd << '-vv --no-abbrev --list'
1643
1643
  out, banner, from = source(io: true)
1644
- first = workspace.size > 1
1644
+ first = from_base?('branch')
1645
1645
  grep = first ? [/^\*\s+#{Regexp.escape(head)}\s/] : []
1646
1646
  ret = write_lines(out, grep: grep, banner: banner, first: first) do |line, index|
1647
1647
  next line if stdin?
@@ -1714,9 +1714,7 @@ module Squared
1714
1714
 
1715
1715
  def restore(flag, opts = [], commit: nil, files: nil)
1716
1716
  cmd, opts = git_session('restore', shell_option(flag, commit, escape: false, force: false), opts: opts)
1717
- op = OptionPartition.new(opts,
1718
- OPT_GIT[:restore] + OPT_GIT[:log][:diff_context],
1719
- cmd,
1717
+ op = OptionPartition.new(opts, OPT_GIT[:restore] + OPT_GIT[:log][:diff_context], cmd,
1720
1718
  project: self, no: OPT_GIT[:no][:restore], first: matchpathspec)
1721
1719
  append_pathspec(op.extras + (files || []), pass: false)
1722
1720
  source(sync: false, stderr: true)
@@ -1779,7 +1777,7 @@ module Squared
1779
1777
  out, banner, from = source(io: true)
1780
1778
  print_item banner
1781
1779
  ret = write_lines(out, grep: op.extras, prefix: "refs/#{flag}/")
1782
- list_result(ret, flag.to_s, grep: op.extras, from: from)
1780
+ list_result(ret, flag.to_s, grep: op.extras, banner: banner, from: from)
1783
1781
  end
1784
1782
 
1785
1783
  def ls_files(flag, opts = [])
@@ -1789,7 +1787,7 @@ module Squared
1789
1787
  out, banner, from = source(io: true)
1790
1788
  print_item banner
1791
1789
  ret = write_lines(out, grep: op.extras)
1792
- list_result(ret, 'files', grep: op.extras, from: from)
1790
+ list_result(ret, 'files', grep: op.extras, banner: banner, from: from)
1793
1791
  end
1794
1792
 
1795
1793
  def git(flag, opts = [])
@@ -1978,14 +1976,20 @@ module Squared
1978
1976
  ret += 1
1979
1977
  break if first
1980
1978
  end
1981
- print_item banner, out if banner && (ret > 0 || (!pass && !first))
1979
+ if banner && (ret > 0 || (!pass && !first))
1980
+ if banner.empty?
1981
+ print_item(*out)
1982
+ else
1983
+ print_item(banner, *out)
1984
+ end
1985
+ end
1982
1986
  ret
1983
1987
  end
1984
1988
 
1985
- def list_result(size, type, action: 'found', grep: [], from: nil)
1989
+ def list_result(size, type, action: 'found', grep: [], banner: nil, from: nil)
1986
1990
  if size == 0
1987
1991
  puts empty_status("No #{type} were #{action}", 'grep', grep.join(', '))
1988
- elsif stdout?
1992
+ elsif stdout? && (banner.nil? || (banner.is_a?(String) && !banner.empty?))
1989
1993
  styles = theme.fetch(:banner, []).reject { |s| s.to_s.end_with?('!') }
1990
1994
  styles << :bold if styles.size <= 1
1991
1995
  puts print_footer("#{size} #{size == 1 ? type.sub(/(?:(?<!l)e)?s\z/, '') : type}",
@@ -2198,9 +2202,9 @@ module Squared
2198
2202
  end
2199
2203
 
2200
2204
  def quiet?(*, target: @session, **)
2201
- return false unless target
2205
+ return silent? unless target
2202
2206
 
2203
- target.include?('--quiet') || (target.include?('-q') && target.first.stripext == 'git')
2207
+ silent? || target.include?('--quiet') || (target.include?('-q') && target.first.stripext == 'git')
2204
2208
  end
2205
2209
 
2206
2210
  def gitpath(*args)
@@ -598,7 +598,7 @@ module Squared
598
598
  else
599
599
  val.split(/\s+/).quote!.join(' ')
600
600
  end
601
- print_run cmd, quiet?
601
+ print_run cmd, silent?
602
602
  run(cmd, banner: false)
603
603
  end
604
604
  cmd << '--workspaces=false' if ws
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.14
4
+ version: 0.6.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham