brunch 0.8.1 → 0.8.3
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 +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +10 -3
- data/lib/brunch/managers.rb +13 -0
- data/lib/brunch/version.rb +1 -1
- data/lib/brunch/worktree_mode.rb +34 -6
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e566d43380555cbea682f52dbbedc64bf1e4a95b681a7c60b266c98aedd5f28e
|
|
4
|
+
data.tar.gz: 212f72d4aa56f57d4ca878a9da515fbdb8730317f2e61ac8b55b33128f679b0c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5c3a334e07d02110511e678b252880bbf3c7ac8028377611c72d275d7018d89adeba270377f4a6f325c53783c34a674f23af5e374ccefc8b54e09ac07602ccb7
|
|
7
|
+
data.tar.gz: a5f2857d35bb150e3adc613eb731636b43a286ba74ec4e2afd29a3e75ca9c9433dda5e174fa092db8b179ec9840fcf7ecf3bfd198a6e9104eb0272e017e9eaa3
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.8.3 - 2026-09-29
|
|
6
|
+
|
|
7
|
+
- Detect containers that exit immediately after a Compose resume and report the
|
|
8
|
+
failure instead of claiming the branch environment is running.
|
|
9
|
+
- Retry activation when a recorded running environment has actually stopped.
|
|
10
|
+
|
|
11
|
+
## 0.8.2 - 2026-09-29
|
|
12
|
+
|
|
13
|
+
- Resume stopped branch containers without rebuilding or replacing them when
|
|
14
|
+
switching back, preserving files in their writable layers.
|
|
15
|
+
- Group `brunch ports` by worktree and show stopped branch environments in gray.
|
|
16
|
+
|
|
5
17
|
## 0.8.1 - 2026-09-29
|
|
6
18
|
|
|
7
19
|
- Reorganize the README into a step-by-step guide for branches, parallel
|
data/README.md
CHANGED
|
@@ -101,6 +101,8 @@ git switch main
|
|
|
101
101
|
Branches checked out in the same worktree reuse that worktree's host port.
|
|
102
102
|
|
|
103
103
|
With Compose, each branch keeps its own Compose project and named volumes, so persistent resources remain isolated between branches.
|
|
104
|
+
Returning to a previously activated branch starts its stopped containers again,
|
|
105
|
+
preserving files written inside them. The branch keeps the same host port.
|
|
104
106
|
|
|
105
107
|
To manually start the environment after `brunch stop`:
|
|
106
108
|
|
|
@@ -108,12 +110,15 @@ To manually start the environment after `brunch stop`:
|
|
|
108
110
|
brunch activate
|
|
109
111
|
```
|
|
110
112
|
|
|
111
|
-
To rebuild and
|
|
113
|
+
To rebuild and recreate its containers explicitly:
|
|
112
114
|
|
|
113
115
|
```bash
|
|
114
116
|
brunch restart
|
|
115
117
|
```
|
|
116
118
|
|
|
119
|
+
`brunch restart` may discard data stored only in a container's writable layer.
|
|
120
|
+
Put important data, such as databases, in named volumes.
|
|
121
|
+
|
|
117
122
|
Compose builds use files from the live worktree, including uncommitted changes.
|
|
118
123
|
|
|
119
124
|
If you want source edits to appear in an already running container without rebuilding, configure a bind mount or another reload mechanism in your Compose setup.
|
|
@@ -140,7 +145,9 @@ brunch ports
|
|
|
140
145
|
|
|
141
146
|
`brunch port` prints the current worktree's port.
|
|
142
147
|
|
|
143
|
-
`brunch ports`
|
|
148
|
+
`brunch ports` groups the current and previously activated branches under each
|
|
149
|
+
worktree. Stopped branches appear in gray and retain their worktree's port for
|
|
150
|
+
the next activation.
|
|
144
151
|
|
|
145
152
|
Switching branches inside one worktree does not affect environments running in other worktrees.
|
|
146
153
|
|
|
@@ -282,7 +289,7 @@ Print the current worktree's port.
|
|
|
282
289
|
brunch ports
|
|
283
290
|
```
|
|
284
291
|
|
|
285
|
-
List
|
|
292
|
+
List current and stopped branch environments grouped by worktree.
|
|
286
293
|
|
|
287
294
|
```bash
|
|
288
295
|
brunch stop
|
data/lib/brunch/managers.rb
CHANGED
|
@@ -15,6 +15,8 @@ module Brunch
|
|
|
15
15
|
|
|
16
16
|
def create(_entry) = true
|
|
17
17
|
|
|
18
|
+
def resume(entry) = start(entry)
|
|
19
|
+
|
|
18
20
|
def environment(entry)
|
|
19
21
|
{
|
|
20
22
|
"BRUNCH_REF" => entry.fetch("ref", ""),
|
|
@@ -67,6 +69,17 @@ module Brunch
|
|
|
67
69
|
|
|
68
70
|
def start(entry) = compose(entry, "up", "--detach", "--build", "--remove-orphans")
|
|
69
71
|
|
|
72
|
+
def resume(entry)
|
|
73
|
+
return false unless compose(entry, "start")
|
|
74
|
+
|
|
75
|
+
# Compose can report success even when the application exits immediately.
|
|
76
|
+
3.times do
|
|
77
|
+
sleep 0.2
|
|
78
|
+
return false unless healthy?(entry)
|
|
79
|
+
end
|
|
80
|
+
true
|
|
81
|
+
end
|
|
82
|
+
|
|
70
83
|
def status(entry)
|
|
71
84
|
return "unavailable" unless available?
|
|
72
85
|
|
data/lib/brunch/version.rb
CHANGED
data/lib/brunch/worktree_mode.rb
CHANGED
|
@@ -100,11 +100,16 @@ module Brunch
|
|
|
100
100
|
abort "#{config.fetch('manager')} is unavailable." unless manager.available?
|
|
101
101
|
|
|
102
102
|
existing = nil
|
|
103
|
+
current_ref = nil
|
|
103
104
|
with_state_lock do |data|
|
|
104
105
|
record = data.fetch("worktrees", {})[id]
|
|
105
106
|
existing = record&.fetch("environments", {})&.[](ref)
|
|
107
|
+
current_ref = record&.[]("current")
|
|
108
|
+
end
|
|
109
|
+
if existing && !force && existing["snapshot"] == path && existing["status"] == "running" &&
|
|
110
|
+
current_ref == ref && worktree_manager(existing).status(existing) != "stopped"
|
|
111
|
+
return
|
|
106
112
|
end
|
|
107
|
-
return if existing && !force && existing["snapshot"] == path && existing["head"] == head && existing["status"] == "running"
|
|
108
113
|
|
|
109
114
|
previous = nil
|
|
110
115
|
port = nil
|
|
@@ -120,6 +125,19 @@ module Brunch
|
|
|
120
125
|
data.fetch("worktrees").fetch(id).fetch("environments").fetch(previous.fetch("ref"))["status"] = "stopped"
|
|
121
126
|
end
|
|
122
127
|
end
|
|
128
|
+
if existing && !force && existing["snapshot"] == path && existing["status"] != "starting"
|
|
129
|
+
with_state_lock { |data| data.fetch("worktrees").fetch(id)["current"] = ref }
|
|
130
|
+
unless worktree_manager(existing).resume(existing)
|
|
131
|
+
abort "Could not resume environment for #{path}; the container may have exited. Check brunch logs. " \
|
|
132
|
+
"If dependencies changed, rebuild with brunch restart (this replaces the container)."
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
with_state_lock do |data|
|
|
136
|
+
data.fetch("worktrees").fetch(id).fetch("environments").fetch(ref)["status"] = "running"
|
|
137
|
+
end
|
|
138
|
+
puts "Resumed #{ref} in #{path} at http://127.0.0.1:#{existing.fetch('port')}"
|
|
139
|
+
return
|
|
140
|
+
end
|
|
123
141
|
abort "Could not reset environment for #{path}." if existing && !worktree_manager(existing).reset(existing)
|
|
124
142
|
|
|
125
143
|
project = "brunch-#{id[0, 12]}-#{Digest::SHA256.hexdigest(ref)[0, 12]}"
|
|
@@ -252,12 +270,22 @@ module Brunch
|
|
|
252
270
|
data = state
|
|
253
271
|
current_id = worktree_identity(repo_root)
|
|
254
272
|
data.fetch("worktrees", {}).sort_by { |_id, record| record.fetch("path") }.each do |id, record|
|
|
255
|
-
|
|
256
|
-
next
|
|
273
|
+
environments = record.fetch("environments", {})
|
|
274
|
+
next if environments.empty?
|
|
257
275
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
276
|
+
path = record.fetch("path")
|
|
277
|
+
puts(id == current_id ? color("● #{path}", 32) : "○ #{path}")
|
|
278
|
+
branches = environments.sort_by { |ref, _entry| [ref == record["current"] ? 0 : 1, ref] }
|
|
279
|
+
branches.each_with_index do |(ref, entry), index|
|
|
280
|
+
prefix = index == branches.length - 1 ? " └─" : " ├─"
|
|
281
|
+
running = ref == record["current"] && entry["status"] == "running"
|
|
282
|
+
unless running
|
|
283
|
+
puts color("#{prefix} ○ #{ref} #{entry.fetch('port')}", 90)
|
|
284
|
+
next
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
puts "#{prefix} #{color("● #{ref}", 32)} #{entry.fetch('port')}"
|
|
288
|
+
end
|
|
261
289
|
end
|
|
262
290
|
end
|
|
263
291
|
|