brunch 0.8.0 → 0.8.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/README.md +259 -147
  4. data/lib/brunch/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f77dd24e00604eea2485dff005164094eb6f6e8633d81e96616df5bf25420ef2
4
- data.tar.gz: 578505da516fbd81dfdd6c54e397ac0d4861e25e7af5b482a6e4f8fcf2aa4043
3
+ metadata.gz: 318ff646dd610a9647612d8ea0fcc446e5122215f4517d665fc639b5bfca740d
4
+ data.tar.gz: e4aeddec12c82d9b0d33caddf6a366840e3db8badd45fec4114f57bd034c3d86
5
5
  SHA512:
6
- metadata.gz: c80c84a7078a91a71c69517d68d9b5093d13c6e97b8662e5ec98aecf2b2d2b07daaa49713da6046c51ca16c41c63cc58b50c2e6c286f1c5ede0ed0c3f2ce5ab2
7
- data.tar.gz: 759c3e32ad7957cdec4b3babe27ad211262ce4f177b0ce6a2f4a0f9d3db26ed81ed332c930e2690e7cc3f9195f7528a5fa80b5ddf8cd4aa7063c32f9e0c18648
6
+ metadata.gz: d334e9cc379f39f4866626e8801adbdc9cbe8aace2d0249b8b4a6a81020b34ec35eca8b8dcf742622e06545d58086966ed087784b077460bdc7e56e5ec150f1c
7
+ data.tar.gz: b34f7f1baf8dbbf6a56669ccc310846eab6aa23d891fa05e4adbe541e1ab1ccea954bfdb46c087fba7a47e3601f45f967efb1de8ff93d7678cb361abaec6eb1c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.8.1 - 2026-09-29
6
+
7
+ - Reorganize the README into a step-by-step guide for branches, parallel
8
+ worktrees, managers, and everyday commands.
9
+
5
10
  ## 0.8.0 - 2026-09-29
6
11
 
7
12
  - Use one worktree-based lifecycle for both branch switches and parallel
data/README.md CHANGED
@@ -2,51 +2,46 @@
2
2
 
3
3
  ![Brunch — container per branch and worktree](brunch.webp)
4
4
 
5
- Brunch runs isolated development environments for Git worktrees. The main
6
- checkout is a worktree too: switching branches there reuses its port, while
7
- additional worktrees run in parallel on different host ports. Docker Compose
8
- is the default manager; Podman
9
- Compose, local processes, and project commands are also supported.
5
+ Brunch runs isolated development environments for Git branches and worktrees.
10
6
 
11
- Each branch environment has a distinct Compose project name, network, and
12
- named volumes. The active environment runs from its live worktree directory,
13
- including uncommitted changes when the manager rebuilds or reloads the app.
7
+ Each branch gets its own environment. With Compose, that means a separate project, network, containers, and named volumes. Branches checked out in the same worktree share its host port, while additional worktrees get different ports and can run in parallel.
8
+
9
+ Docker Compose is the default manager. Podman Compose, local processes, and custom project commands are also supported.
14
10
 
15
11
  ## Requirements
16
12
 
17
- - Ruby 3.1 or newer
18
- - Git 2.28 or newer
19
- - A supported environment manager: Docker Compose, Podman Compose, or project commands
20
- - [`git-hooks-ext`](https://github.com/ciembor/git-hooks-ext)
13
+ - Ruby 3.1+
14
+ - Git 2.28+
15
+ - Docker Compose, Podman Compose, or another supported manager
16
+ - [git-hooks-ext](https://github.com/ciembor/git-hooks-ext)
21
17
 
22
18
  ## Installation
23
19
 
24
- Install [`git-hooks-ext`](https://github.com/ciembor/git-hooks-ext) so that
25
- `ghe` is on your `PATH`, then install Brunch:
20
+ Install [git-hooks-ext](https://github.com/ciembor/git-hooks-ext) so that `ghe` is available on your `PATH`, then install Brunch:
26
21
 
27
- ```sh
22
+ ```bash
28
23
  gem install brunch
29
24
  ```
30
25
 
31
- Run `brunch install` inside each Git repository you want Brunch to manage.
32
- It installs the `git-hooks-ext` bridge and project-local hooks, and refuses
33
- to replace an existing hook owned by another tool.
26
+ Inside each repository you want Brunch to manage:
27
+
28
+ ```bash
29
+ brunch install
30
+ ```
31
+
32
+ Brunch installs its hooks through `git-hooks-ext` and will not overwrite hooks owned by another tool.
34
33
 
35
- ## Project configuration
34
+ ## Configuration
36
35
 
37
- Add `brunch.yml` to the project root. Docker Compose is the default, so the
38
- following remains sufficient for Compose projects:
36
+ Add `brunch.yml` to the repository root.
37
+
38
+ For Docker Compose:
39
39
 
40
40
  ```yaml
41
41
  compose_file: compose.yaml
42
42
  ```
43
43
 
44
- The referenced Compose file belongs to the application. Brunch does not impose
45
- a database or service stack: applications may define PostgreSQL, MySQL, Redis,
46
- Sidekiq, Elasticsearch, or any other services they need.
47
- Unknown `brunch.yml` fields are errors, so configuration typos are not ignored.
48
-
49
- Expose the application port with `BRUNCH_PORT`:
44
+ Expose the application through `BRUNCH_PORT`:
50
45
 
51
46
  ```yaml
52
47
  services:
@@ -55,121 +50,134 @@ services:
55
50
  - "127.0.0.1:${BRUNCH_PORT}:3000"
56
51
  ```
57
52
 
58
- The first activated worktree prefers `127.0.0.1:3000`. Every worktree keeps
59
- its assigned host port while its branches take turns using it. Other worktrees
60
- receive a different free port; running containers can never bind the same host
61
- address and port. To prefer another starting port, set `preferred_port: 4000`.
62
- Brunch persists assignments privately in `.git/brunch/state.json`.
53
+ The first activated worktree prefers port `3000`. Additional worktrees receive another free port.
63
54
 
64
- ## Using Brunch
55
+ To prefer a different starting port:
65
56
 
66
- First, commit `brunch.yml` and your Compose file (or the configuration for
67
- another manager). The repository needs at least one commit before Brunch can
68
- start an environment. Install the hooks once per repository, then activate
69
- the checked-out branch:
57
+ ```yaml
58
+ preferred_port: 4000
59
+ ```
70
60
 
71
- ```sh
61
+ Port assignments are persisted per worktree in `.git/brunch/state.json`.
62
+
63
+ ## Getting started
64
+
65
+ Commit `brunch.yml` and the application configuration first. The repository must contain at least one commit.
66
+
67
+ Then run:
68
+
69
+ ```bash
72
70
  brunch install
73
71
  brunch doctor
74
72
  brunch activate
75
73
  brunch status
74
+ ```
75
+
76
+ `brunch activate` starts the environment for the currently checked-out branch.
77
+
78
+ To print only the current worktree's port:
79
+
80
+ ```bash
76
81
  brunch port
77
82
  ```
78
83
 
79
- Open `http://127.0.0.1:3000` if port 3000 is free, or use the port printed by
80
- `brunch activate` / `brunch port`. Brunch starts the application in the
81
- background. With Compose, the app must listen on the container port mapped in
82
- `compose.yaml`.
84
+ Open the application on the printed port, for example:
83
85
 
84
- ### Branches in one checkout
86
+ ```text
87
+ http://127.0.0.1:3000
88
+ ```
89
+
90
+ With Compose, the application must listen on the container port mapped in the Compose file.
91
+
92
+ ## Branch switching
85
93
 
86
- Once the hooks are installed, ordinary Git branch switches stop the old
87
- environment and start the new one automatically:
94
+ Once the hooks are installed, normal Git branch switches automatically stop the previous branch environment and start the new one:
88
95
 
89
- ```sh
96
+ ```bash
90
97
  git switch -c feature/login
91
- brunch status
92
98
  git switch main
93
99
  ```
94
100
 
95
- Both branches use this checkout's assigned host port. With Compose, they keep
96
- separate projects and volumes. To start the checked-out branch manually (for
97
- example, after `brunch stop`), run `brunch activate`. Run `brunch restart` to
98
- rebuild it after changing files that are copied into the image.
101
+ Branches checked out in the same worktree reuse that worktree's host port.
99
102
 
100
- ### Parallel worktrees
103
+ With Compose, each branch keeps its own Compose project and named volumes, so persistent resources remain isolated between branches.
101
104
 
102
- There is no mode switch. Commit the same `brunch.yml` in your repository, then
103
- create additional worktrees. Run `brunch install` again after upgrading Brunch
104
- to install its worktree hooks.
105
+ To manually start the environment after `brunch stop`:
105
106
 
106
- ```sh
107
+ ```bash
108
+ brunch activate
109
+ ```
110
+
111
+ To rebuild and restart it:
112
+
113
+ ```bash
114
+ brunch restart
115
+ ```
116
+
117
+ Compose builds use files from the live worktree, including uncommitted changes.
118
+
119
+ 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.
120
+
121
+ ## Parallel worktrees
122
+
123
+ Additional worktrees run independently on different host ports.
124
+
125
+ Create them with `git-hooks-ext`:
126
+
127
+ ```bash
107
128
  ghe worktree add -b feature-a ../feature-a
108
129
  ghe worktree add -b feature-b ../feature-b
130
+ ```
131
+
132
+ Then:
133
+
134
+ ```bash
109
135
  cd ../feature-a
110
- brunch port # port for this worktree
111
- brunch ports # ports for all worktrees
112
- ```
113
-
114
- Each worktree runs independently on a different host port, so `feature-a` and
115
- `feature-b` can be used at the same time. Run `brunch status` or `brunch port`
116
- inside each worktree to find its address. Switching branches inside one
117
- worktree does not stop the others.
118
-
119
- `ghe worktree add`, `move`, and `remove` emit lifecycle events. Git's
120
- `post-checkout` hook handles branch changes inside any worktree, including the
121
- main checkout. If you use plain `git worktree add`, run `brunch activate` in the
122
- new worktree; after a plain move or removal, run `brunch cleanup` from a
123
- remaining worktree.
124
-
125
- The source directory is never deleted by Brunch. It keeps a separate control
126
- copy under `.git/brunch/controls` so it can shut down Compose or run a custom
127
- `remove` command after a worktree has been removed. Switching branches within
128
- one worktree keeps the old branch's environment stopped, with its own named
129
- volumes. Removing the worktree removes all of its Brunch environments. The
130
- `local_process` manager also writes its log to the control directory, keeping
131
- the worktree clean. Custom `remove` commands that depend on project files must
132
- be committed, because the control copy is based on the worktree's last commit.
133
-
134
- Docker builds read uncommitted files from the live worktree. To see edits in
135
- an already running container without rebuilding, configure a source bind
136
- mount or another reload mechanism in the project's Compose file.
137
- `brunch restart` rebuilds the current environment.
138
-
139
- Before upgrading from an older branch-only configuration, stop its running
140
- environment and clean up its legacy state. Brunch refuses to reinterpret an
141
- old non-empty branch state as worktree state, preventing orphaned containers.
142
-
143
- ### Custom manager commands
144
-
145
- Use the `command` manager when the project is started by another tool. Brunch
146
- runs commands from the live worktree with these variables: `BRUNCH_REF`,
147
- `BRUNCH_PORT`, `BRUNCH_PROJECT`, and `BRUNCH_SNAPSHOT`. The last variable points
148
- to the live worktree for compatibility with manager adapters.
149
136
 
150
- ```yaml
151
- manager: command
152
- commands:
153
- create: bin/environment create
154
- start: bin/environment start
155
- stop: bin/environment stop
156
- remove: bin/environment remove
137
+ brunch port
138
+ brunch ports
157
139
  ```
158
140
 
159
- `create` provisions manager-owned resources; it is optional for the `command`
160
- manager. `start` must return after
161
- it has launched the environment (for example, by delegating to a daemon or
162
- supervisor). `stop` is used when switching branches; `remove` is used when
163
- a worktree is deleted and should remove any manager-owned persistent
164
- resources. This makes the adapter suitable for Podman, Kubernetes wrappers,
165
- Foreman/Overmind wrappers, or a project-specific script.
141
+ `brunch port` prints the current worktree's port.
166
142
 
167
- Optional `status`, `health`, and `logs` commands power the corresponding Brunch
168
- commands. A successful `health` command reports a healthy environment.
143
+ `brunch ports` lists ports assigned to all worktrees.
144
+
145
+ Switching branches inside one worktree does not affect environments running in other worktrees.
146
+
147
+ If you create a worktree with plain Git:
148
+
149
+ ```bash
150
+ git worktree add -b feature-c ../feature-c
151
+ ```
152
+
153
+ activate Brunch manually inside it:
154
+
155
+ ```bash
156
+ cd ../feature-c
157
+ brunch activate
158
+ ```
159
+
160
+ After moving or removing worktrees with plain Git, run:
161
+
162
+ ```bash
163
+ brunch cleanup
164
+ ```
165
+
166
+ Brunch never deletes the worktree source directory.
167
+
168
+ ## Managers
169
+
170
+ ### Docker Compose
171
+
172
+ Docker Compose is the default manager:
173
+
174
+ ```yaml
175
+ compose_file: compose.yaml
176
+ ```
169
177
 
170
178
  ### Podman Compose
171
179
 
172
- Podman Compose uses the same Compose file contract as Docker Compose:
180
+ Podman Compose uses the same Compose file contract:
173
181
 
174
182
  ```yaml
175
183
  manager: podman_compose
@@ -178,66 +186,170 @@ compose_file: compose.yaml
178
186
 
179
187
  ### Local process
180
188
 
181
- Use `local_process` for a development command such as `bin/dev`.
182
- Brunch starts it in a dedicated process group, records its PID, stops that
183
- group on a branch switch, and saves its output under `.git/brunch/controls`.
189
+ Use `local_process` for a development command such as `bin/dev`:
184
190
 
185
191
  ```yaml
186
192
  manager: local_process
187
193
  command: bin/dev
188
194
  ```
189
195
 
190
- ## Lifecycle
196
+ Brunch starts and stops the process together with the branch environment and stores its output under `.git/brunch/controls`.
197
+
198
+ ### Custom commands
199
+
200
+ Use the `command` manager to integrate Brunch with project-specific tooling:
201
+
202
+ ```yaml
203
+ manager: command
204
+ commands:
205
+ create: bin/environment create
206
+ start: bin/environment start
207
+ stop: bin/environment stop
208
+ remove: bin/environment remove
209
+ ```
210
+
211
+ Brunch runs these commands from the live worktree with:
212
+
213
+ ```text
214
+ BRUNCH_REF
215
+ BRUNCH_PORT
216
+ BRUNCH_PROJECT
217
+ BRUNCH_SNAPSHOT
218
+ ```
219
+
220
+ `BRUNCH_SNAPSHOT` points to the live worktree for compatibility with manager adapters.
221
+
222
+ `create` is optional.
223
+
224
+ `start` must return after launching the environment.
225
+
226
+ `stop` is called when switching away from the active branch.
227
+
228
+ `remove` is called when the corresponding worktree environment is deleted and should remove manager-owned persistent resources.
229
+
230
+ Optional commands:
231
+
232
+ ```yaml
233
+ commands:
234
+ status: bin/environment status
235
+ health: bin/environment health
236
+ logs: bin/environment logs
237
+ ```
238
+
239
+ These power the corresponding Brunch operations.
240
+
241
+ ## Worktree lifecycle
242
+
243
+ A branch checkout stops the previous environment in that worktree and starts the new one on the same host port.
191
244
 
192
- - A branch checkout stops the previous environment in that worktree, then
193
- creates and starts the new one on the same port.
194
- - Each worktree keeps its own current environment and port. Other worktrees
195
- continue running during branch switches.
196
- - Checking out a remote branch into a new local tracking branch works through
197
- the same `post-checkout` hook.
198
- - `brunch cleanup` removes environments belonging to deleted worktrees.
245
+ Other worktrees continue running.
199
246
 
200
- Git 2.39 cannot reliably report a normal `git branch -d` operation to a hook.
201
- Stopped branch environments remain until their worktree is removed.
247
+ Removing a worktree removes its Brunch environments. Brunch keeps the information needed to shut down manager resources under `.git/brunch/controls`, so cleanup can still run after the worktree itself is gone.
202
248
 
203
- ## Operations
249
+ If a custom `remove` command depends on project files, those files must be committed because cleanup after worktree removal uses the last committed state.
204
250
 
205
- ```sh
206
- brunch status # current worktree environment, manager status and port
207
- brunch ports # worktree-to-port list; current worktree is marked in green
208
- brunch port # only the current worktree's port, suitable for scripts
209
- brunch stop # stop the active environment without deleting it
210
- brunch restart # recreate and start the active environment
211
- brunch logs # show the last 100 logs (or run commands.logs)
251
+ `brunch cleanup` removes environments belonging to worktrees that no longer exist.
252
+
253
+ Git does not expose every branch deletion workflow reliably to hooks, so stopped branch environments may remain until their worktree is removed.
254
+
255
+ ## Commands
256
+
257
+ ```bash
258
+ brunch install
259
+ ```
260
+
261
+ Install Brunch hooks for the repository.
262
+
263
+ ```bash
264
+ brunch activate
265
+ ```
266
+
267
+ Start the environment for the current branch.
268
+
269
+ ```bash
270
+ brunch status
271
+ ```
272
+
273
+ Show the current environment, manager status, and port.
274
+
275
+ ```bash
276
+ brunch port
277
+ ```
278
+
279
+ Print the current worktree's port.
280
+
281
+ ```bash
282
+ brunch ports
283
+ ```
284
+
285
+ List ports assigned to all worktrees.
286
+
287
+ ```bash
288
+ brunch stop
289
+ ```
290
+
291
+ Stop the active environment without removing it.
292
+
293
+ ```bash
294
+ brunch restart
295
+ ```
296
+
297
+ Recreate and start the active environment.
298
+
299
+ ```bash
300
+ brunch logs
212
301
  brunch logs --follow
213
- brunch run -- bin/rails console # runs on the host in the live worktree, not in a container
214
- brunch doctor # verify Git, installed hooks, configuration, manager and ports
215
- brunch cleanup # delete environments for removed worktrees
216
302
  ```
217
303
 
218
- Brunch coordinates commands with locks under `.git/brunch`, writes `state.json`
219
- atomically, and retries interrupted environment setup on the next activation.
304
+ Show environment logs.
305
+
306
+ ```bash
307
+ brunch run -- bin/rails console
308
+ ```
309
+
310
+ Run a command on the host from the live worktree.
311
+
312
+ ```bash
313
+ brunch doctor
314
+ ```
315
+
316
+ Check Git, installed hooks, configuration, manager availability, and ports.
317
+
318
+ ```bash
319
+ brunch cleanup
320
+ ```
321
+
322
+ Remove environments belonging to deleted worktrees.
323
+
324
+ ## Upgrading from older configurations
325
+
326
+ Before upgrading from an older branch-only configuration, stop its running environment and clean up its legacy state.
327
+
328
+ Brunch will not reinterpret an existing non-empty branch-only state as worktree state.
220
329
 
221
330
  ## Development
222
331
 
223
- ```sh
332
+ ```bash
224
333
  bundle install
225
334
  bin/install-pre-commit
226
335
  bundle exec rake quality
227
336
  gem build brunch.gemspec
228
337
  ```
229
338
 
230
- Container E2E tests use real temporary Git repositories, Compose containers,
231
- and HTTP requests. Run them with Docker or Podman:
339
+ Run container integration tests with Docker Compose:
232
340
 
233
- ```sh
341
+ ```bash
234
342
  BRUNCH_INTEGRATION_MANAGER=docker_compose bundle exec rake test
343
+ ```
344
+
345
+ Or Podman Compose:
346
+
347
+ ```bash
235
348
  BRUNCH_INTEGRATION_MANAGER=podman_compose bundle exec rake test
236
349
  ```
237
350
 
238
- CI runs both managers on pushes and pull requests. Without the environment
239
- variable, container tests are skipped by the local quality check.
351
+ Without `BRUNCH_INTEGRATION_MANAGER`, container integration tests are skipped by the local quality check.
352
+
353
+ The pre-commit hook runs RuboCop with automatic corrections, Reek, and the full test suite. SimpleCov requires 100% line and branch coverage for `lib/**/*.rb`.
240
354
 
241
- The pre-commit hook runs RuboCop with automatic corrections, Reek, and the full
242
- test suite. SimpleCov requires 100% line and branch coverage of `lib/**/*.rb`. When
243
- RuboCop changes a file, review and stage the correction before committing.
355
+ If RuboCop modifies a file, review and stage the changes before committing.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Brunch
4
- VERSION = "0.8.0"
4
+ VERSION = "0.8.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: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Ciemborowicz