squared 0.2.9 → 0.2.10

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: da84184d479e255a0a9916bfa33d081259b3965fb61ab40f32f7417fad7751b5
4
- data.tar.gz: 9dceba3df95cf08e724c13f0ab63c7ba607f7253e2cefe5f5ebab78858c58c78
3
+ metadata.gz: b8b2e8a394034cfe323c5997a02b1e7c3f9ea0e2c9df925a87801fc8b9a61061
4
+ data.tar.gz: c30e2dcd5d3cea0526eea68f47ae8740949a4eb3b32ff1e76f9a15fc5e115f85
5
5
  SHA512:
6
- metadata.gz: bed08c89a0f41d484b8d18d951abbd1386b1138365ab0f9add293ec81865303c3e6861ec6cb8a6326e3e91c1b2692fad6ceb64b11410c5f4df8015f3da1226d7
7
- data.tar.gz: fc545d2ecb6a324d3a1d4869d73223d5122b15517268e248d5cbda19be39e4ddcfb5fb07627d090c9010334e7747f7121c8e6b8dbce7c2ca08f44131263a6681
6
+ metadata.gz: 4ec98cbf7dd9a4f0c63d316650fd3163cc0ec78934c30f638bbc531c31c8bfec075c8911c28a3af1b5f74ae1b5cdb92721f5f17e4e0973e3a7ecdbd326664a0b
7
+ data.tar.gz: 4b4f4270e87a1a427c30ed8c2f1fadeea9aad227592bd2268117f303919c27ec14adb596fb7668f611bbad20000376cf936050537f202533613ba333330b48c5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.10] - 2025-04-27
4
+
5
+ ### Fixed
6
+
7
+ - Project run and script tasks did not fire first and last callbacks.
8
+ - Git command clone did not read booleans for recurse-submodules.
9
+
10
+ ## [0.1.7] - 2025-04-27
11
+
12
+ ### Fixed
13
+
14
+ - Project directory context method option pass was inverted.
15
+ - Shell options with spaces and without quotes were not escaped.
16
+ - Git task status did not display branch information.
17
+ - Ruby copy method argument include was ignored when used directly.
18
+ - Git commit could not push branch without same name as remote.
19
+
3
20
  ## [0.2.9] - 2025-04-17
4
21
 
5
22
  ### Changed
@@ -252,6 +269,7 @@
252
269
 
253
270
  - Changelog was created.
254
271
 
272
+ [0.2.10]: https://github.com/anpham6/squared/releases/tag/v0.2.10-ruby
255
273
  [0.2.9]: https://github.com/anpham6/squared/releases/tag/v0.2.9-ruby
256
274
  [0.2.8]: https://github.com/anpham6/squared/releases/tag/v0.2.8-ruby
257
275
  [0.2.7]: https://github.com/anpham6/squared/releases/tag/v0.2.7-ruby
@@ -262,6 +280,7 @@
262
280
  [0.2.2]: https://github.com/anpham6/squared/releases/tag/v0.2.2-ruby
263
281
  [0.2.1]: https://github.com/anpham6/squared/releases/tag/v0.2.1-ruby
264
282
  [0.2.0]: https://github.com/anpham6/squared/releases/tag/v0.2.0-ruby
283
+ [0.1.7]: https://github.com/anpham6/squared/releases/tag/v0.1.7-ruby
265
284
  [0.1.6]: https://github.com/anpham6/squared/releases/tag/v0.1.6-ruby
266
285
  [0.1.5]: https://github.com/anpham6/squared/releases/tag/v0.1.5-ruby
267
286
  [0.1.4]: https://github.com/anpham6/squared/releases/tag/v0.1.4-ruby
@@ -53,7 +53,7 @@ module Squared
53
53
  end
54
54
  wrap = ->(s, n) { "\x1B[#{n.join(';')}m#{s}\x1B[0m" }
55
55
  code = []
56
- args.concat(as_a(styles)).each_with_index do |type, i|
56
+ args.concat(as_a(styles)).flatten.each_with_index do |type, i|
57
57
  next unless type
58
58
 
59
59
  if index == -1
@@ -21,7 +21,7 @@ module Squared
21
21
  return false
22
22
  end
23
23
  attempts -= 1
24
- exit 1 unless attempts >= 0
24
+ exit 1 unless attempts > 0
25
25
  end
26
26
  rescue Interrupt
27
27
  puts
@@ -10,7 +10,7 @@ module Squared
10
10
 
11
11
  def shell_escape(val, quote: false, force: false)
12
12
  if (data = /\A(--?[^= ]+)((=|\s+)(["'])?(.+?)(["'])?)?\z/m.match(val = val.to_s))
13
- return val if !data[2] || (!data[4] && data[5] =~ /\s/)
13
+ return val if !data[2] || (!data[4] && !data[5].match?(/\s/))
14
14
 
15
15
  join = ->(opt) { data[1] + data[3] + shell_quote(opt) }
16
16
  if data[4] == data[6]
@@ -21,7 +21,7 @@ module Squared
21
21
  elsif Rake::Win32.windows?
22
22
  quote ? shell_quote(val, force: force) : val
23
23
  else
24
- Shellwords.escape(val)
24
+ val.empty? ? '' : Shellwords.escape(val)
25
25
  end
26
26
  end
27
27
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Squared
4
- VERSION = '0.2.9'
4
+ VERSION = '0.2.10'
5
5
  end
@@ -352,10 +352,10 @@ module Squared
352
352
  self
353
353
  end
354
354
 
355
- def build(*args, from: :build, sync: invoked_sync?('build'), **)
355
+ def build(*args, from: :run, sync: invoked_sync?('build'), **)
356
356
  banner = verbose
357
357
  if args.empty?
358
- return unless from == :build
358
+ return unless from == :run
359
359
 
360
360
  cmd, opts, var, flags = @output
361
361
  banner = verbose == 1 if task_invoked?('build', 'build:sync')
@@ -376,6 +376,7 @@ module Squared
376
376
  return unless respond_to?(:compose)
377
377
 
378
378
  cmd = compose(opts, flags, from: from, script: true)
379
+ from = :script if from == :run && script?
379
380
  end
380
381
  run(cmd, var, from: from, banner: banner, sync: sync)
381
382
  end
@@ -1118,7 +1119,7 @@ module Squared
1118
1119
  pwd = Pathname.pwd
1119
1120
  if block_given?
1120
1121
  begin
1121
- if path == pwd || pass == true || (pass.is_a?(String) && semscan(pass).join >= RUBY_VERSION)
1122
+ if path == pwd || pass == true || (pass.is_a?(String) && semscan(pass).join <= RUBY_VERSION)
1122
1123
  ret = instance_eval(&blk)
1123
1124
  else
1124
1125
  Dir.chdir(path)
@@ -543,6 +543,7 @@ module Squared
543
543
  def status(*, sync: invoked_sync?('status'), **)
544
544
  cmd = git_session 'status'
545
545
  cmd << (option('long') ? '--long' : '--short')
546
+ cmd << '--branch' if option('branch')
546
547
  if (val = option('ignore-submodules', ignore: false))
547
548
  cmd << basic_option('ignore-submodules', case val
548
549
  when '0', 'none'
@@ -722,53 +723,39 @@ module Squared
722
723
  raise_error('commit', 'pathspec', hint: 'missing') if (files = projectmap(files)).empty?
723
724
  "-- #{files.join(' ')}"
724
725
  end
725
- origin = nil
726
+ format = '%(if)%(HEAD)%(then)%(refname:short)...%(upstream:short)...%(upstream:track)%(end)'
726
727
  branch = nil
727
- upstream = nil
728
- source(git_output('fetch --no-tags --quiet'), io: true, banner: false)
729
- source(git_output('branch -vv --list'), io: true, banner: false).first.each do |val|
730
- next unless (data = /^\*\s(\S+)\s+(\h+)(?:\s\[(.+?)(?=\]\s)\])?\s/.match(val))
731
-
732
- branch = data[1]
733
- sha = data[2]
734
- if !data[3]
735
- unless (origin = option('repository', prefix: 'git', ignore: false))
736
- out = source(git_output('log -n1 --format=%h%d'), io: true, stdout: true, banner: false).first
737
- if (data = /^#{sha} \(HEAD -> #{Regexp.escape(branch)}, (.+?)\)$/.match(out))
738
- split_escape(data[1]).each do |s|
739
- next unless s.end_with?("/#{branch}")
740
-
741
- origin = s[0..s.size - branch.size - 2]
742
- break
743
- end
744
- end
745
- end
746
- upstream = true if origin
747
- elsif (data = Regexp.new("^(.+)/#{Regexp.escape(branch)}$").match(data[3]))
748
- origin = data[1]
728
+ origin = nil
729
+ source(git_output('fetch --no-tags --quiet'), io: true, banner: false, stdout: true)
730
+ cmd = git_output("for-each-ref --format=\"#{format}\" refs/heads")
731
+ source(cmd, io: true, banner: false).first.each do |line|
732
+ next if (line = line.chomp).empty?
733
+
734
+ branch, origin, hint = line.split('...')
735
+ if hint && !hint.match?(/^\[(\D+0,\D+0)\]$/)
736
+ raise_error('work tree is not usable', hint: hint[1..-2])
737
+ elsif origin.empty?
738
+ return nil if pass
739
+
740
+ raise_error('no remote upstream', hint: branch)
749
741
  end
750
742
  break
751
743
  end
752
- raise_error('commit', 'work tree is not usable') unless origin && branch
744
+ i = origin.index('/')
745
+ branch = "#{branch}:#{origin[i + 1..-1]}" unless origin.end_with?("/#{branch}")
746
+ origin = origin[0..i - 1]
753
747
  cmd = git_session('commit', option('dry-run') && '--dry-run', options: false)
754
- if amend
755
- cmd << '--amend'
756
- else
757
- cmd.delete('--amend')
758
- end
748
+ cmd << '--amend' if amend
759
749
  if message
760
750
  append_message message
761
751
  elsif flag == :'amend-orig' || option('no-edit')
762
752
  cmd << '--no-edit'
763
753
  end
764
754
  a = git_output 'add', '--verbose'
765
- b = git_output 'push', upstream && '--set-upstream'
766
- if dryrun?
767
- a << '--dry-run'
768
- b << '--dry-run'
769
- end
755
+ b = git_output 'push'
756
+ b << '--dry-run' if dryrun?
770
757
  a << pathspec
771
- b << '--force' if amend
758
+ b << '--force-with-lease' if amend
772
759
  b << origin << branch
773
760
  puts if pass
774
761
  source a
@@ -1097,16 +1084,22 @@ module Squared
1097
1084
  return unless (val = option('recurse-submodules', target: target, ignore: false))
1098
1085
 
1099
1086
  if from == :clone
1100
- projectmap(split_escape(val)).each do |path|
1101
- target << basic_option('recurse-submodules', path)
1087
+ case val
1088
+ when '0', 'false'
1089
+ target << '--no-recurse-submodules'
1090
+ when '1', 'true'
1091
+ target << '--recurse-submodules'
1092
+ else
1093
+ projectmap(split_escape(val)).each do |path|
1094
+ target << basic_option('recurse-submodules', path)
1095
+ end
1102
1096
  end
1103
- target
1104
1097
  else
1105
1098
  target << case val
1106
1099
  when 'no', '0'
1107
1100
  '--no-recurse-submodules'
1108
1101
  when 'yes', 'on-demand'
1109
- "--recurse-submodules#{from == :reset ? '' : "=#{val}"}"
1102
+ "--recurse-submodules=#{val}"
1110
1103
  else
1111
1104
  '--recurse-submodules'
1112
1105
  end
@@ -577,8 +577,8 @@ module Squared
577
577
  run
578
578
  end
579
579
 
580
- def compose(opts, flags = nil, script: false, from: :build)
581
- return unless opts && script && from == :build
580
+ def compose(opts, flags = nil, script: false, from: nil)
581
+ return unless opts && script
582
582
 
583
583
  ret = session dependbin, 'run', flags
584
584
  append_loglevel
@@ -588,7 +588,7 @@ module Squared
588
588
  when String
589
589
  ret << opts
590
590
  else
591
- raise_error("#{dependbin} script name", hint: opts.nil? ? 'missing' : 'invalid')
591
+ raise_error("#{dependbin} script name: given #{opts}", hint: from)
592
592
  end
593
593
  ret
594
594
  end
@@ -192,13 +192,15 @@ module Squared
192
192
  end
193
193
  end
194
194
 
195
- def copy(from: 'lib', include: nil, exclude: nil, into: @gemdir, override: false)
195
+ def copy(from: 'lib', into: @gemdir, override: false, **kwargs)
196
+ glob = kwargs[:include]
197
+ pass = kwargs[:exclude]
196
198
  if @copy && !override
197
199
  return super if runnable?(@copy)
198
200
 
199
201
  from = @copy[:from] if @copy.key?(:from)
200
202
  glob = @copy[:include] if @copy.key?(:include)
201
- exclude = @copy[:exclude] if @copy.key?(:exclude)
203
+ pass = @copy[:exclude] if @copy.key?(:exclude)
202
204
  into = @copy[:into] if @copy.key?(:into)
203
205
  end
204
206
  return unless into
@@ -210,10 +212,10 @@ module Squared
210
212
  as_a(from).each_with_index do |val, i|
211
213
  a = basepath(val)
212
214
  b = dest.join(val)
213
- c = glob[i] || glob[0]
215
+ c = glob[i] || glob.first
214
216
  log.info "cp #{a.join(c)} #{b}"
215
217
  begin
216
- copy_dir(a, b, c, pass: exclude, verbose: verbose)
218
+ copy_dir(a, b, c, pass: pass, verbose: verbose)
217
219
  rescue StandardError => e
218
220
  log.error e
219
221
  ret = on(:error, :copy, e)
@@ -3,8 +3,6 @@
3
3
  module Squared
4
4
  module Workspace
5
5
  module Repo
6
- include Common::Format
7
-
8
6
  class << self
9
7
  def read_manifest(path)
10
8
  require 'rexml/document'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2025-04-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  requirements: []
123
- rubygems_version: 3.6.8
123
+ rubygems_version: 3.6.2
124
124
  specification_version: 4
125
125
  summary: Rake task generator for managing multi-language workspaces.
126
126
  test_files: []