squared 0.1.6 → 0.1.7

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: 7630bfea46c3328ad2c6a12c865a913c3efad5609815b4b5dee647abd9e43665
4
- data.tar.gz: 7c791bd8356e85949829196c6eddca1ad29227189471a9a89c02b8eb48c101cc
3
+ metadata.gz: a84fd3fef43628c438131d98c9ac058b2511a7a7f0edab355ae534137a612d1d
4
+ data.tar.gz: 46e0925a6e7d854d71602aee88d54c2efff7e7ff782d847fd85e95759bad3ffb
5
5
  SHA512:
6
- metadata.gz: 8fa16263ea3d1d1012d308bc41dda0f72557329c1e0e491fce519b3cb9d9fd67b6ebc635747737053213ffb3dd21e86d4318b49c1de72dbffdce7d93f5cb698a
7
- data.tar.gz: 73d2f5163e5d5c87abbb9894933829a88a8d589424eb70bfb39ae8c8721af1050da7f8e1c2e3d2566f914ccd90ea230fc7138dcad7d77fbd559131aa4121c7aa
6
+ metadata.gz: e90a44a3914f551b4567d2013882ce362dfdc43b44bb157cb24fb2b6171cb64c46dbbb680ba7fcc17fd32f76d0e8d82bfa5ddc411eb00de5524ab5407135d413
7
+ data.tar.gz: 993f3899bf89ed18f8b89ddda7019c33484b76d2a770a72b8280fa898af6a7caecceafe862de7854236c9e52ddb7c2100cd9e388b8afb4dd3d0f4427647f15ad
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.7] - 2025-04-27
4
+
5
+ ### Fixed
6
+
7
+ - Project directory context method option pass was inverted.
8
+ - Shell options with spaces and without quotes were not escaped.
9
+ - Git task status did not display branch information.
10
+ - Ruby copy method argument include was ignored when used directly.
11
+ - Git commit could not push branch without same name as remote.
12
+
3
13
  ## [0.1.6] - 2025-04-17
4
14
 
5
15
  ### Fixed
@@ -108,6 +118,7 @@
108
118
 
109
119
  - Changelog was created.
110
120
 
121
+ [0.1.7]: https://github.com/anpham6/squared/releases/tag/v0.1.7-ruby
111
122
  [0.1.6]: https://github.com/anpham6/squared/releases/tag/v0.1.6-ruby
112
123
  [0.1.5]: https://github.com/anpham6/squared/releases/tag/v0.1.5-ruby
113
124
  [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.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
@@ -922,7 +922,7 @@ module Squared
922
922
  def pwd_set(done = nil, pass: false, &blk)
923
923
  pwd = Pathname.pwd
924
924
  if block_given?
925
- if path == pwd || pass == true || (pass.is_a?(String) && semscan(pass).join >= RUBY_VERSION)
925
+ if path == pwd || pass == true || (pass.is_a?(String) && semscan(pass).join <= RUBY_VERSION)
926
926
  ret = instance_eval(&blk)
927
927
  else
928
928
  Dir.chdir(path)
@@ -295,6 +295,7 @@ module Squared
295
295
 
296
296
  def status
297
297
  cmd = git_session 'status', option('long') ? '--long' : '--short'
298
+ cmd << '--branch' if option('branch')
298
299
  if (val = option('ignore-submodules', ignore: false))
299
300
  cmd << shell_option('ignore-submodules', case val
300
301
  when '0', 'none'
@@ -465,41 +466,29 @@ module Squared
465
466
  raise_error('commit', 'pathspec', hint: 'missing') if (files = projectmap(files)).empty?
466
467
  "-- #{files.join(' ')}"
467
468
  end
468
- origin = nil
469
+ format = '%(if)%(HEAD)%(then)%(refname:short)...%(upstream:short)...%(upstream:track)%(end)'
469
470
  branch = nil
470
- upstream = false
471
- source('git fetch --no-tags --quiet', io: true, banner: false)
472
- source('git branch -vv --list', io: true, banner: false).first.each do |val|
473
- next unless (data = /\A\*\s(\S+)\s+(\h+)(?:\s\[(.+?)(?=\]\s)\])?\s/.match(val))
474
-
475
- branch = data[1]
476
- sha = data[2]
477
- if !data[3]
478
- unless (origin = option('repository', prefix: 'git', ignore: false))
479
- out = source('git log -n1 --format=%h%d', io: true, stdout: true, banner: false).first
480
- if (data = /\A#{sha} \(HEAD -> #{Regexp.escape(branch)}, (.+?)\)\z/.match(out))
481
- split_escape(data[1]).each do |s|
482
- next unless s.end_with?("/#{branch}")
483
-
484
- origin = s[0..s.size - branch.size - 2]
485
- break
486
- end
487
- end
488
- end
489
- upstream = !origin.nil?
490
- elsif (data = Regexp.new("\\A(.+)/#{Regexp.escape(branch)}\\z").match(data[3]))
491
- origin = data[1]
471
+ origin = nil
472
+ source('git fetch --no-tags --quiet', io: true, banner: false, stdout: true)
473
+ source("git for-each-ref --format=\"#{format}\" refs/heads", io: true, banner: false).first.each do |line|
474
+ next if (line = line.chomp).empty?
475
+
476
+ branch, origin, hint = line.split('...')
477
+ if hint && !hint.match?(/^\[(\D+0,\D+0)\]$/)
478
+ raise_error('work tree is not usable', hint: hint[1..-2])
479
+ elsif origin.empty?
480
+ return nil if pass
481
+
482
+ raise_error('no remote upstream', hint: branch)
492
483
  end
493
484
  break
494
485
  end
495
- raise_error('commit', 'work tree is not usable') unless origin && branch
486
+ i = origin.index('/')
487
+ branch = "#{branch}:#{origin[i + 1..-1]}" unless origin.end_with?("/#{branch}")
488
+ origin = origin[0..i - 1]
496
489
  cmd = git_session 'commit'
497
490
  cmd << '--dry-run' if option('dry-run')
498
- if amend
499
- cmd << '--amend'
500
- else
501
- cmd.delete('--amend')
502
- end
491
+ cmd << '--amend' if amend
503
492
  if message
504
493
  append_message message
505
494
  elsif flag == :'amend-orig' || option('no-edit')
@@ -507,13 +496,9 @@ module Squared
507
496
  end
508
497
  a = ['git add --verbose']
509
498
  b = ['git push']
510
- b << '--set-upstream' if upstream
511
- if dry_run?
512
- a << '--dry-run'
513
- b << '--dry-run'
514
- end
499
+ b << '--dry-run' if dry_run?
515
500
  a << pathspec
516
- b << '--force' if amend
501
+ b << '--force-with-lease' if amend
517
502
  b << origin << branch
518
503
  puts if pass
519
504
  source a.join(' ')
@@ -207,13 +207,15 @@ module Squared
207
207
  end
208
208
  end
209
209
 
210
- def copy(from: 'lib', include: nil, exclude: nil, into: @gemdir, override: false)
210
+ def copy(from: 'lib', into: @gemdir, override: false, **kwargs)
211
+ glob = kwargs[:include]
212
+ pass = kwargs[:exclude]
211
213
  if @copy && !override
212
214
  return super if runnable?(@copy)
213
215
 
214
216
  from = @copy[:from] if @copy.key?(:from)
215
217
  glob = @copy[:include] if @copy.key?(:include)
216
- exclude = @copy[:exclude] if @copy.key?(:exclude)
218
+ pass = @copy[:exclude] if @copy.key?(:exclude)
217
219
  into = @copy[:into] if @copy.key?(:into)
218
220
  end
219
221
  return unless into
@@ -224,9 +226,9 @@ module Squared
224
226
  as_a(from).each_with_index do |val, i|
225
227
  a = basepath(val)
226
228
  b = dest.join(val)
227
- c = glob[i] || glob[0]
229
+ c = glob[i] || glob.first
228
230
  log.info "cp #{a.join(c)} #{b}"
229
- copy_d(a, b, glob: c, pass: exclude, verbose: verbose)
231
+ copy_d(a, b, glob: c, pass: pass, verbose: verbose)
230
232
  end
231
233
  end
232
234
 
@@ -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,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: squared
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - An Pham
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2025-04-28 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: rake
@@ -106,6 +107,7 @@ metadata:
106
107
  homepage_uri: https://github.com/anpham6/squared
107
108
  source_code_uri: https://github.com/anpham6/squared
108
109
  documentation_uri: https://squared.readthedocs.io
110
+ post_install_message:
109
111
  rdoc_options: []
110
112
  require_paths:
111
113
  - lib
@@ -120,7 +122,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
122
  - !ruby/object:Gem::Version
121
123
  version: '0'
122
124
  requirements: []
123
- rubygems_version: 3.6.8
125
+ rubygems_version: 3.3.27
126
+ signing_key:
124
127
  specification_version: 4
125
128
  summary: Rake task generator for managing multi-language workspaces.
126
129
  test_files: []