ctree 0.5.3 → 0.5.5

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: 8abbf0956853273481c598fe775b0da106a06f6fdd9a49d54598bd16e08cf566
4
- data.tar.gz: b663bf6b45e76e44fc67cf93a3d49a2b287c3f184a6bdbc9520a9ea757a81c5e
3
+ metadata.gz: 8ef0c528d52a2d9fef65f64d67341972783baaaac2dec877a760fa0ac55f2359
4
+ data.tar.gz: b48b547b46a9c02e82ec6ebcf22d29e48338d617bc85a7e95f2a32ee773870ab
5
5
  SHA512:
6
- metadata.gz: 37489240879d544d297168677500092b26e57d473af18b36ecdbdcc7bc68fa4d14600c0957f037ec24912fccb33129e8e351a1fb5ae849625fd084171731c274
7
- data.tar.gz: 87db5c5490d551df4abba9572f1568d2fa4fd06e2474274e7c32338445931665114e3c9fcd56b62bad4220d0a6179fdd66ce8d5cf476f6642dedd5a10619e210
6
+ metadata.gz: 4f92fea22adb1c0555d90954ebc36f5e256e83ad6f67921797fc3bd13730272f2790f860b0673d8839ea306c3b9deecbb9c696b6c2241cbcd28bcf2cf4e6e419
7
+ data.tar.gz: 389c6ebdbfa98c3cfc213c8a5320dece53e019adcab2b9aa0b5be9ce5c97b07fdf4a2affff06c41bfb1ad0d84f8873b69d4647a795dbe35d057b04864e90a5d3
data/CHANGELOG.md CHANGED
@@ -7,9 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.5] - 2026-11-30
11
+
12
+ - Fixed `ctree free` creating a new placeholder branch from
13
+ the current HEAD instead of the default branch
14
+
15
+ ## [0.5.4] - 2026-10-19
16
+
17
+ - Added a Rakefile for standard local build flow
18
+ - Improved the gem packaging
19
+
10
20
  ## [0.5.3] - 2026-10-12
11
21
 
12
- - Added gemspec
22
+ - Added gemspec and dependencies
13
23
  - Added file/volume size to log file
14
24
  - Cleaned up the codebase
15
25
 
data/README.md CHANGED
@@ -193,17 +193,17 @@ Run **from inside a worktree** (no arguments). Resets the worktree to a free
193
193
  placeholder branch so it can be reused. ctree:
194
194
 
195
195
  1. Lists all local branches whose names start with the configured
196
- `free_branch_prefix` (default `FREE-`).
196
+ `free_branch_prefix` (default `FREE-`).
197
197
  2. Checks out the first available branch — one not currently checked out in
198
- any worktree — sorted alphabetically.
198
+ any worktree — sorted alphabetically.
199
199
  3. If all free branches are occupied, creates the next sequential one,
200
- filling gaps in the numeric sequence. For example, if `FREE-001` and
201
- `FREE-003` both exist and are checked out, it creates and checks out
202
- `FREE-002`. If no free branches exist at all, it creates `FREE-001`.
203
- Numbers are zero-padded to at least 3 digits (`FREE-001`, `FREE-002`, …).
200
+ filling gaps in the numeric sequence. For example, if `FREE-001` and
201
+ `FREE-003` both exist and are checked out, it creates and checks out
202
+ `FREE-002`. If no free branches exist at all, it creates `FREE-001`.
203
+ Numbers are zero-padded to at least 3 digits (`FREE-001`, `FREE-002`, …).
204
204
  4. Rebases the checked-out branch onto the source repo's `master` (skipped
205
- automatically if already up to date). Aborts and reports on conflict —
206
- resolve manually and re-run `ctree rebase` from the worktree.
205
+ automatically if already up to date). Aborts and reports on conflict —
206
+ resolve manually and re-run `ctree rebase` from the worktree.
207
207
 
208
208
  ### env
209
209
 
data/lib/ctree/cli.rb CHANGED
@@ -138,7 +138,6 @@ module Ctree
138
138
  "FREE-"). If all are occupied, creates the next sequential one, filling gaps
139
139
  (FREE-001 + FREE-003 occupied → creates FREE-002). The prefix is configurable
140
140
  via free_branch_prefix in .ctree/config.yml.
141
-
142
141
  HELP
143
142
  "env" => <<~HELP,
144
143
  Usage:
data/lib/ctree/free.rb CHANGED
@@ -32,20 +32,25 @@ module Ctree
32
32
  current_branch_out, _, cb_st = Sh.capture3("git", "-C", target_path.to_s, "rev-parse", "--abbrev-ref", "HEAD")
33
33
  Log.die "could not resolve current branch" unless cb_st.success?
34
34
  current_branch = current_branch_out.strip
35
+ default_branch = Git.detect_default_branch(source_root)
36
+
35
37
  if !prefix.empty? && current_branch.start_with?(prefix)
38
+ ahead = commits_ahead(source_root, default_branch, current_branch)
39
+ warn_polluted_current(current_branch, ahead, default_branch) unless ahead.zero?
36
40
  Log.info "already on a free branch (#{current_branch}); nothing to do"
37
41
  exit 0
38
42
  end
39
-
40
43
  branches_out, _, branches_st = Sh.capture3("git", "-C", source_root.to_s, "branch", "--list", "#{prefix}*")
41
44
  Log.die "git branch --list failed" unless branches_st.success?
42
45
  all_free = branches_out.lines.map { |l| l.sub(/\A[*+ ] /, "").strip }.reject(&:empty?).sort
43
-
44
46
  worktree_raw, _, wt_st = Sh.capture3("git", "-C", source_root.to_s, "worktree", "list", "--porcelain")
45
47
  Log.die "git worktree list failed" unless wt_st.success?
46
48
  occupied = List.parse_worktree_porcelain(worktree_raw).filter_map { |e| e[:branch] }.to_set
47
-
48
- branch = first_available_branch(all_free, occupied)
49
+ branch = first_available_branch(all_free, occupied) do |candidate|
50
+ ahead = commits_ahead(source_root, default_branch, candidate)
51
+ warn_stale_placeholder(candidate, ahead, default_branch) unless ahead.zero?
52
+ ahead.zero?
53
+ end
49
54
  if branch
50
55
  _, err, st = Spinner.with_spinner("checking out #{branch}") do
51
56
  Sh.capture3("git", "-C", target_path.to_s, "checkout", branch)
@@ -54,18 +59,35 @@ module Ctree
54
59
  else
55
60
  branch = next_sequential_branch(prefix, all_free)
56
61
  _, err, st = Spinner.with_spinner("checking out #{branch}") do
57
- Sh.capture3("git", "-C", target_path.to_s, "checkout", "-b", branch)
62
+ Sh.capture3("git", "-C", target_path.to_s, "checkout", "--no-track", "-b", branch, default_branch)
58
63
  end
59
64
  Log.die "git checkout -b #{branch} failed: #{err.strip}" unless st.success?
60
65
  end
61
66
  Log.info "checked out #{branch}"
62
-
63
- default_branch = Git.detect_default_branch(source_root)
64
67
  Rebase.rebase_branch_onto_default(target_path, branch, default_branch)
65
68
  end
66
69
 
67
70
  def first_available_branch(all_free, occupied)
68
- all_free.sort.find { |b| !occupied.include?(b) }
71
+ all_free.sort.find { |b| !occupied.include?(b) && (!block_given? || yield(b)) }
72
+ end
73
+
74
+ def commits_ahead(source_root, default_branch, branch)
75
+ out, err, st = Sh.capture3("git", "-C", source_root.to_s,
76
+ "rev-list", "--count", "#{default_branch}..#{branch}")
77
+ Log.die "git rev-list #{default_branch}..#{branch} failed: #{err.strip}" unless st.success?
78
+ out.strip.to_i
79
+ end
80
+
81
+ def warn_stale_placeholder(branch, ahead, default_branch)
82
+ noun = ahead == 1 ? "commit" : "commits"
83
+ Log.warn_ "skipping #{branch}: #{ahead} #{noun} not on #{default_branch} " \
84
+ "(see: git log #{default_branch}..#{branch}). Move that work to a named branch to reuse it."
85
+ end
86
+
87
+ def warn_polluted_current(branch, ahead, default_branch)
88
+ noun = ahead == 1 ? "commit" : "commits"
89
+ Log.warn_ "#{branch} has #{ahead} #{noun} not on #{default_branch} " \
90
+ "(see: git log #{default_branch}..#{branch}). Move that work to a named branch, then reset the placeholder."
69
91
  end
70
92
 
71
93
  def next_sequential_branch(prefix, all_free)
data/lib/ctree/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ctree
4
- VERSION = "0.5.3"
4
+ VERSION = "0.5.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ctree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - mytrak
@@ -23,7 +23,7 @@ dependencies:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
25
  version: '3.12'
26
- description: ctree lets you run several branches of a Docker-compose project at once,
26
+ description: ctree lets you run multiple branches of a Docker-compose project at once,
27
27
  each in its own sibling git worktree with replicated Docker volumes. Manage the
28
28
  full lifecycle with create, delete, list, rebase, and update commands.
29
29
  email:
@@ -58,6 +58,8 @@ licenses:
58
58
  metadata:
59
59
  github_repo: https://github.com/mytrak/ctree
60
60
  changelog_uri: https://github.com/mytrak/ctree/blob/main/CHANGELOG.md
61
+ source_code_uri: https://github.com/mytrak/ctree
62
+ rubygems_mfa_required: 'true'
61
63
  rdoc_options: []
62
64
  require_paths:
63
65
  - lib
@@ -72,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
74
  - !ruby/object:Gem::Version
73
75
  version: '0'
74
76
  requirements: []
75
- rubygems_version: 3.6.9
77
+ rubygems_version: 4.0.23
76
78
  specification_version: 4
77
79
  summary: Run multiple branches of a Docker-compose repo side by side
78
80
  test_files: []