bonchi 0.7.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2af66b530d16c1004fe1d290edf3a28ea189999df19561fbd70f0d2779f31510
4
- data.tar.gz: 99edcbb95cbb4cdd4aa6d752b6266e3392f69833654fece86f8cef8918c5441c
3
+ metadata.gz: '053922f8049bc9788caaf72af772fcd9058945e2964183228c339922109029f4'
4
+ data.tar.gz: b2058d5ed48143f1eb54c42ecb614087bd4e3a23a461a31d0c749146366454cb
5
5
  SHA512:
6
- metadata.gz: e58e2d259376816627e4905885d19a5785ca525c1fda135af38c6a849726f37e088c5244b03e46789b164a088a8ece8d9c3153377d3a8476c0f851555b576ed4
7
- data.tar.gz: e4d9300d822379d8423fc1f55b6501a6abae8c0441be618ca9651d6af2197b12556de05e4eee96b94f946d51b5f1069e1ed379c6924f69154c4d105071203d68
6
+ metadata.gz: 24cdf46ea9f71a1bfec30f23d2765b51a1dc036e06059693f14379b192822fd850a28ab667e8439a65ed20cb2cd5b4fd1c818213c5d5c34e46ff9c03d3cbdaa5
7
+ data.tar.gz: a512b18c8ba6e77f5cbbeaa8584738c1f41a3754fc08ffaa9f6a1a04d76a753194ec55837ce413545b351f59936b1640c1c53d91ac68bc9d40f75a604b04c096
data/lib/bonchi/cli.rb CHANGED
@@ -115,7 +115,9 @@ module Bonchi
115
115
  which ports to allocate, and what setup command to run.
116
116
  DESC
117
117
  def init
118
- path = File.join(Dir.pwd, ".worktree.yml")
118
+ root = Git.toplevel
119
+ abort "Error: not inside a git repository" unless root
120
+ path = File.join(root, ".worktree.yml")
119
121
  if File.exist?(path)
120
122
  abort "Error: .worktree.yml already exists"
121
123
  end
data/lib/bonchi/git.rb CHANGED
@@ -24,6 +24,11 @@ module Bonchi
24
24
  `git worktree list --porcelain`.lines.first.sub("worktree ", "").strip
25
25
  end
26
26
 
27
+ def toplevel
28
+ root = `git rev-parse --show-toplevel 2>/dev/null`.strip
29
+ root.empty? ? nil : root
30
+ end
31
+
27
32
  def worktree_list
28
33
  `git worktree list`.lines.map(&:strip).reject(&:empty?)
29
34
  end
@@ -1,3 +1,4 @@
1
+ require "set"
1
2
  require "yaml"
2
3
  require "socket"
3
4
 
@@ -6,6 +7,21 @@ module Bonchi
6
7
  DEFAULT_MIN = 4000
7
8
  DEFAULT_MAX = 5000
8
9
 
10
+ # Ports browsers refuse to connect to (Chrome: ERR_UNSAFE_PORT, Firefox: a
11
+ # similar block). Allocating one of these for a dev web server makes it
12
+ # unreachable in the browser even though the server binds fine. This is
13
+ # Chromium's kRestrictedPorts list (net/base/port_util.cc); ports outside
14
+ # the pool range are harmless to keep listed. 4045 (lockd) and 4190 (sieve)
15
+ # fall inside the default 4000..5000 range.
16
+ UNSAFE_PORTS = [
17
+ 1, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 25, 37, 42, 43, 53, 69, 77,
18
+ 79, 87, 95, 101, 102, 103, 104, 109, 110, 111, 113, 115, 117, 119, 123,
19
+ 135, 137, 139, 143, 161, 179, 389, 427, 465, 512, 513, 514, 515, 526,
20
+ 530, 531, 532, 540, 548, 554, 556, 563, 587, 601, 636, 989, 990, 993,
21
+ 995, 1719, 1720, 1723, 2049, 3659, 4045, 4190, 5060, 5061, 6000, 6566,
22
+ 6665, 6666, 6667, 6668, 6669, 6697, 10080
23
+ ].to_set.freeze
24
+
9
25
  def initialize
10
26
  @path = GlobalConfig.config_path
11
27
  load_config
@@ -26,7 +42,7 @@ module Bonchi
26
42
 
27
43
  new_ports = {}
28
44
  port_names.each do |name|
29
- port = (@min..@max).find { |p| !used.include?(p) && port_available?(p) }
45
+ port = (@min..@max).find { |p| !used.include?(p) && !UNSAFE_PORTS.include?(p) && port_available?(p) }
30
46
  abort "Error: no available port for #{name}" unless port
31
47
  used << port
32
48
  new_ports[name] = port
data/lib/bonchi/setup.rb CHANGED
@@ -6,7 +6,7 @@ module Bonchi
6
6
  include Colors
7
7
 
8
8
  def initialize(worktree: nil)
9
- @worktree = worktree || Dir.pwd
9
+ @worktree = worktree || Git.toplevel || Dir.pwd
10
10
  @main_worktree = Git.main_worktree
11
11
  end
12
12
 
@@ -148,7 +148,7 @@ module Bonchi
148
148
  end
149
149
 
150
150
  def ensure_trailing_newline(content)
151
- content.empty? || content.end_with?("\n") ? content : content + "\n"
151
+ (content.empty? || content.end_with?("\n")) ? content : content + "\n"
152
152
  end
153
153
 
154
154
  def run_pre_setup(commands)
@@ -1,3 +1,3 @@
1
1
  module Bonchi
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bonchi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gert Goet
@@ -63,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  requirements: []
66
- rubygems_version: 3.6.7
66
+ rubygems_version: 4.0.10
67
67
  specification_version: 4
68
68
  summary: Git worktree manager
69
69
  test_files: []