brunch 1.1.0 → 1.1.1

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: bfbfbc36f9114715c3b656aeeb831010e8e75e1ccc15d8c7229813b4489ceac6
4
- data.tar.gz: 6a98d0331e7d758bacafad88344dd92a0a105b60c06ead342d35fb928e36cc0f
3
+ metadata.gz: a5f8f14648bdb686475a9218411c5359c37dcba381ef4ac358c0b5aa06a72627
4
+ data.tar.gz: 678a130e837c647983b4f2043ba0408121ba4d78d5697a36093af47c00cc87bf
5
5
  SHA512:
6
- metadata.gz: 64bbfe38e607cf1cf8cc1e9ce042e104653a4ac0958fdeca87ff6e40e4febf0f09e287d9c55f6cb7ce75c17a3062ad6edb1cd159f18407d3a52415192360c52b
7
- data.tar.gz: ea493ddaa2e3431665a0a0a0d1c42f99a3013c9ab5ccafc98b170a98dfddd20188a7bd53dc6384f99a1469a5aba1b52298b1edd9881287e4d8c3365d246719c6
6
+ metadata.gz: 1f20f0fa144538315abeb04ff906994ff3313248aa2ce108c80acc74eb286f38c0756145b1a11bda28a7963c0d5d0dd5abf378166a951f56abe39f4133d8d331
7
+ data.tar.gz: b8b4d4faa393311bc7cd851461bf9c89885f30c55875581ac34ffecdd4a7d187d616c16a69ed8920ec568d80e22905bd1354a5f911ba6cd72aeade341a8d750e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.1 - 2026-10-16
4
+
5
+ - Support the short port notation that older Podman Compose versions preserve
6
+ in rendered configuration when `ports: auto` is enabled.
7
+ - Run Podman Compose cleanup from Brunch's control directory after a worktree
8
+ has been removed.
9
+
3
10
  ## 1.1.0 - 2026-10-16
4
11
 
5
12
  - Add opt-in `ports: auto` for Docker Compose and Podman Compose. Brunch now
@@ -29,7 +29,7 @@ module Brunch
29
29
  mapping = published_mapping(service, port)
30
30
  next port unless mapping
31
31
 
32
- port.merge("published" => indexed.fetch(key(mapping)))
32
+ rewrite_port(port, mapping, indexed.fetch(key(mapping)))
33
33
  end
34
34
  end
35
35
  document
@@ -40,7 +40,9 @@ module Brunch
40
40
  end
41
41
 
42
42
  def published_mapping(service, port)
43
- raise CLI::ConfigurationError, "Unsupported Compose port for #{service}; use Compose long syntax with ports: auto." unless port.is_a?(Hash)
43
+ return short_mapping(service, port) if port.is_a?(String)
44
+
45
+ raise CLI::ConfigurationError, "Unsupported Compose port for #{service}." unless port.is_a?(Hash)
44
46
  return unless port.key?("published") && !port["published"].to_s.empty?
45
47
 
46
48
  published = integer(port["published"], "published host port for #{service}")
@@ -53,6 +55,30 @@ module Brunch
53
55
  end
54
56
  private_class_method :published_mapping
55
57
 
58
+ def rewrite_port(port, mapping, host)
59
+ return port.merge("published" => host) if port.is_a?(Hash)
60
+
61
+ value = [mapping.fetch("host_ip"), host, mapping.fetch("target")].reject { |part| part == "" }.join(":")
62
+ mapping.fetch("protocol") == "tcp" ? value : "#{value}/#{mapping.fetch('protocol')}"
63
+ end
64
+ private_class_method :rewrite_port
65
+
66
+ def short_mapping(service, port)
67
+ value, protocol = port.split("/", 2)
68
+ parts = value.split(":")
69
+ raise CLI::ConfigurationError, "Unsupported Compose port for #{service}: #{port.inspect}." unless (2..3).cover?(parts.length)
70
+
71
+ target = integer(parts.pop, "container port for #{service}")
72
+ published = integer(parts.pop, "published host port for #{service}")
73
+ host_ip = parts.pop.to_s
74
+ normalized_protocol = protocol || "tcp"
75
+ raise CLI::ConfigurationError, "Unsupported protocol #{normalized_protocol.inspect} for #{service}." unless %w[tcp udp].include?(normalized_protocol)
76
+
77
+ { "service" => service.to_s, "target" => target, "protocol" => normalized_protocol,
78
+ "host_ip" => host_ip, "published" => published }
79
+ end
80
+ private_class_method :short_mapping
81
+
56
82
  def integer(value, description)
57
83
  Integer(value).tap do |port|
58
84
  raise CLI::ConfigurationError, "Invalid #{description}: #{value.inspect}." unless CLI::PORT_RANGE.cover?(port)
@@ -99,7 +99,7 @@ module Brunch
99
99
  end
100
100
 
101
101
  def render_compose(entry)
102
- output, error, status = Open3.capture3(environment(entry), *source_compose_command(entry, "config"), **compose_options(entry))
102
+ output, error, status = Open3.capture3(environment(entry), *source_compose_command(entry, "config"), **source_compose_options(entry))
103
103
  return [output, nil] if status.success?
104
104
 
105
105
  [nil, error]
@@ -144,6 +144,7 @@ module Brunch
144
144
  end
145
145
 
146
146
  def compose_options(_entry) = {}
147
+ def source_compose_options(entry) = compose_options(entry)
147
148
 
148
149
  def compose_directory(entry)
149
150
  source = entry.fetch("snapshot")
@@ -183,7 +184,8 @@ module Brunch
183
184
  ["podman", "compose", "-p", entry.fetch("project"), "-f", File.join(directory, entry.fetch("compose_file")), *arguments]
184
185
  end
185
186
 
186
- def compose_options(entry) = { chdir: entry.fetch("snapshot") }
187
+ def compose_options(entry) = { chdir: compose_directory(entry) }
188
+ def source_compose_options(entry) = { chdir: entry.fetch("snapshot") }
187
189
 
188
190
  def ports_command = ["podman", "ps", "--format", "{{.Ports}}"]
189
191
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Brunch
4
- VERSION = "1.1.0"
4
+ VERSION = "1.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brunch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Ciemborowicz