Skip to content

Commit e43d466

Browse files
authored
Preping version 2.0.2 (#205)
* Add new stuff to README * Fix typo in help * Bump version * Populate changelog * bundle update * lint stuff Signed-off-by: Phil Dibowitz <phil@ipom.com>
1 parent 9b0564b commit e43d466

File tree

8 files changed

+96
-43
lines changed

8 files changed

+96
-43
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# SugarJar Changelog
22

3+
## 2.0.2 (2026-01-08)
4+
5+
* Fix `branchclean` logic to properly compare with the target branch
6+
(might have refused to clean branches that could be cleaned)
7+
* Add new commands to handle remote branch cleanup as well as rename
8+
`bclean` (keeping backwards compatible aliases):
9+
* `localbranchclean` / `lbclean` - local branch clean. aliased as
10+
`bclean` for back-comat
11+
* `localbranchcleanall` / `lbcleanall` - local all branch clean aliased
12+
as `bcleanall` for back-compat
13+
* `remotebranchclean` / `rbclean` - remote branch clean
14+
* `remotebranchcleanall` / `rbcleanall` - remote all branch clean
15+
* `globalbranchclean` / `gbclean` - local+remote branch clean
16+
* `globalbranchcleanall` / `gbcleanall` - local+remote all branch clean
17+
* Added new `sync` command to aid syncing branches across multiple workstations,
18+
see help for details.
19+
* Fix meta-ref handling which fixes crashes when using `smartlog` during rebases
20+
* Handle worktress gracefully when doing branch cleans
21+
* Make unittests work properly outside of git repos
22+
323
## 2.0.1 (2025-05-12)
424

525
* Fix gemspec to include new library files

Gemfile.lock

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
sugarjar (2.0.1)
4+
sugarjar (2.0.2)
55
deep_merge
66
mixlib-log
77
mixlib-shellout
@@ -11,27 +11,27 @@ GEM
1111
remote: https://rubygems.org/
1212
specs:
1313
ast (2.4.3)
14-
chef-utils (18.7.6)
14+
chef-utils (18.8.54)
1515
concurrent-ruby
16-
concurrent-ruby (1.3.5)
16+
concurrent-ruby (1.3.6)
1717
deep_merge (1.2.2)
18-
diff-lcs (1.6.1)
19-
ffi (1.17.2)
20-
ffi (1.17.2-arm64-darwin)
21-
ffi (1.17.2-x86_64-darwin)
22-
ffi (1.17.2-x86_64-linux-gnu)
23-
json (2.11.3)
18+
diff-lcs (1.6.2)
19+
ffi (1.17.3)
20+
ffi (1.17.3-arm64-darwin)
21+
ffi (1.17.3-x86_64-darwin)
22+
ffi (1.17.3-x86_64-linux-gnu)
23+
json (2.18.0)
2424
kramdown (2.5.1)
2525
rexml (>= 3.3.9)
2626
kramdown-parser-gfm (1.1.0)
2727
kramdown (~> 2.0)
28-
language_server-protocol (3.17.0.4)
28+
language_server-protocol (3.17.0.5)
2929
lint_roller (1.1.0)
30-
mdl (0.13.0)
30+
mdl (0.15.0)
3131
kramdown (~> 2.3)
3232
kramdown-parser-gfm (~> 1.1)
33-
mixlib-cli (~> 2.1, >= 2.1.1)
34-
mixlib-config (>= 2.2.1, < 4)
33+
mixlib-cli
34+
mixlib-config
3535
mixlib-shellout
3636
mixlib-cli (2.1.8)
3737
mixlib-config (3.0.27)
@@ -41,49 +41,49 @@ GEM
4141
mixlib-shellout (3.3.9)
4242
chef-utils
4343
parallel (1.27.0)
44-
parser (3.3.8.0)
44+
parser (3.3.10.0)
4545
ast (~> 2.4.1)
4646
racc
4747
pastel (0.8.0)
4848
tty-color (~> 0.5)
49-
prism (1.4.0)
49+
prism (1.7.0)
5050
racc (1.8.1)
5151
rainbow (3.1.1)
52-
regexp_parser (2.10.0)
53-
rexml (3.4.2)
54-
rspec (3.13.0)
52+
regexp_parser (2.11.3)
53+
rexml (3.4.4)
54+
rspec (3.13.2)
5555
rspec-core (~> 3.13.0)
5656
rspec-expectations (~> 3.13.0)
5757
rspec-mocks (~> 3.13.0)
58-
rspec-core (3.13.3)
58+
rspec-core (3.13.6)
5959
rspec-support (~> 3.13.0)
60-
rspec-expectations (3.13.4)
60+
rspec-expectations (3.13.5)
6161
diff-lcs (>= 1.2.0, < 2.0)
6262
rspec-support (~> 3.13.0)
63-
rspec-mocks (3.13.4)
63+
rspec-mocks (3.13.7)
6464
diff-lcs (>= 1.2.0, < 2.0)
6565
rspec-support (~> 3.13.0)
66-
rspec-support (3.13.3)
67-
rubocop (1.75.5)
66+
rspec-support (3.13.6)
67+
rubocop (1.82.1)
6868
json (~> 2.3)
6969
language_server-protocol (~> 3.17.0.2)
7070
lint_roller (~> 1.1.0)
7171
parallel (~> 1.10)
7272
parser (>= 3.3.0.2)
7373
rainbow (>= 2.2.2, < 4.0)
7474
regexp_parser (>= 2.9.3, < 3.0)
75-
rubocop-ast (>= 1.44.0, < 2.0)
75+
rubocop-ast (>= 1.48.0, < 2.0)
7676
ruby-progressbar (~> 1.7)
7777
unicode-display_width (>= 2.4.0, < 4.0)
78-
rubocop-ast (1.44.1)
78+
rubocop-ast (1.49.0)
7979
parser (>= 3.3.7.2)
80-
prism (~> 1.4)
80+
prism (~> 1.7)
8181
ruby-progressbar (1.13.0)
82-
tomlrb (2.0.3)
82+
tomlrb (2.0.4)
8383
tty-color (0.6.0)
84-
unicode-display_width (3.1.4)
85-
unicode-emoji (~> 4.0, >= 4.0.4)
86-
unicode-emoji (4.0.4)
84+
unicode-display_width (3.2.0)
85+
unicode-emoji (~> 4.1)
86+
unicode-emoji (4.2.0)
8787

8888
PLATFORMS
8989
arm64-darwin

README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Jump to what you're most interested in:
3030
* [Cleaning up your own history](#cleaning-up-your-own-history)
3131
* [Better feature branches](#better-feature-branches)
3232
* [Smartlog](#smartlog)
33+
* [Sync work across workstations](#sync-work-across-workstations)
3334
* [Pulling in suggestions from the web](#pulling-in-suggestions-from-the-web)
3435
* [And more!](#and-more)
3536
* [Installation](#installation)
@@ -50,8 +51,10 @@ doesn't work. Git will tell you the branch isn't fully merged. You can, of
5051
course `git branch -D <branch>`, but that does no safety checks at all, it
5152
forces the deletion.
5253

53-
Enter `sj bclean` - it determines if the contents of your branch has been merge
54-
and safely deletes if so.
54+
Enter `sj lbclean` - it determines if the contents of your branch has been merge
55+
and safely deletes if so. (Note: `lbclean` stands for "local branch clean", and
56+
is aliased to `bclean` for both backwards-compatibility and also since it's the
57+
most common branch-cleanup command).
5558

5659
![bclean screenshot](https://github.com/jaymzh/sugarjar/blob/main/images/bclean.png)
5760

@@ -65,6 +68,17 @@ been merged:
6568

6669
![bcleanall screenshot](https://github.com/jaymzh/sugarjar/blob/main/images/bcleanall.png)
6770

71+
There is also `sj rbclean` ("remote branch clean") (and `sj rbcleanall`) for
72+
cleanup of remote branches. *Note*: This cannot differentiate between
73+
PR/feature branches which have been merged and long-lived release branches that
74+
have been merged (e.g. if '2.0-release' is a branch and has no commits not in
75+
main, it will be deleted).
76+
77+
There is even `sj gbclean` ("global branch clean") (and `sj gbcleanall`) which will
78+
do both the local and remote cleaning.
79+
80+
*NOTE*: Remote branch cleaning is still experimental, use with caution!
81+
6882
### Smarter clones and remotes
6983

7084
There's a pattern to every new repo we want to contribute to. First we fork,
@@ -275,6 +289,21 @@ smartlog` or `sj sl` for short.
275289

276290
![smartlog screenshot](https://github.com/jaymzh/sugarjar/blob/main/images/smartlog.png)
277291

292+
### Sync work across workstations
293+
294+
If you work on multiple workstations, keeping your branches in-sync can be a
295+
pain. SugarJar provides `sync` to help with this.
296+
297+
For example, if you do some work on feature `foo` on machine1 and push to
298+
`origin/foo` (intending to eventually merge to `upstream/main`), then on
299+
machine2, you pull that branch, do more work, which you also push to
300+
`origin/foo`, then on machine1, you can do `sj sync` to pull down the changes
301+
from `origin/foo`. If you have local changes, that are not already on
302+
`origin/foo`, those will be rebased on top of the changes from `origin/foo`.
303+
304+
It's very similar to `sj up`, but instead of rebasing on top of the tracking
305+
branch, it rebases on top of the push target branch.
306+
278307
### Pulling in suggestions from the web
279308

280309
When someone 'suggests' a change in the GitHub WebUI, once you choose to commit

bin/sj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ COMMANDS:
237237
238238
For example, if you do some work on feature `foo` on machine1 and
239239
push to `origin/foo` (intending to eventually merge to
240-
`upstream/foo`), then on machine2, you pull that branch, do more
240+
`upstream/main`), then on machine2, you pull that branch, do more
241241
work, which you also push to `origin/foo`, then on machine1, you
242242
can do `sj sync` to pull down the changes from `origin/foo`. If
243243
you have local changes, that are not already on `origin/foo`,

lib/sugarjar/commands/bclean.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,15 @@ def gbcleanall(remote = nil)
136136

137137
private
138138

139+
# rubocop:disable Naming/PredicateMethod
139140
def clean_branch(name, type = :local)
140141
undeleteable = MAIN_BRANCHES.dup
141142
undeleteable << 'HEAD' if type == :remote
142143
die("Cannot remove #{name} branch") if undeleteable.include?(name)
143144
SugarJar::Log.debug('Fetch relevant remote...')
144145
fetch_upstream
145146
fetch(remote_from_ref(name)) if type == :remote
146-
return false unless safe_to_clean(name)
147+
return false unless safe_to_clean?(name)
147148

148149
SugarJar::Log.debug('branch deemed safe to delete...')
149150
if type == :remote
@@ -157,8 +158,9 @@ def clean_branch(name, type = :local)
157158
end
158159
true
159160
end
161+
# rubocop:enable Naming/PredicateMethod
160162

161-
def safe_to_clean(branch)
163+
def safe_to_clean?(branch)
162164
# cherry -v will output 1 line per commit on the target branch
163165
# prefixed by a - or + - anything with a - can be dropped, anything
164166
# else cannot.

lib/sugarjar/commands/push.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def _smartpush(remote, branch, force)
3939
puts git(*args).stderr
4040
end
4141

42+
# rubocop:disable Naming/PredicateMethod
4243
def run_prepush
4344
@repo_config['on_push']&.each do |item|
4445
SugarJar::Log.debug("Running on_push check type #{item}")
@@ -49,5 +50,6 @@ def run_prepush
4950
end
5051
true
5152
end
53+
# rubocop:enable Naming/PredicateMethod
5254
end
5355
end

lib/sugarjar/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class SugarJar
2-
VERSION = '2.0.1'.freeze
2+
VERSION = '2.0.2'.freeze
33
end

spec/commands/bclean_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
SugarJar::Commands.new({ 'no_change' => true })
66
end
77

8-
context '#safe_to_clean' do
8+
context '#safe_to_clean?' do
99
it 'Allows cleanup when cherry -v shows no delta' do
1010
expect(sj).to receive(:tracked_branch).with('foo').
1111
and_return('origin/main')
1212
so = double({ 'stdout' => '' })
1313
expect(sj).to receive(:git).with('cherry', '-v', 'origin/main', 'foo').
1414
and_return(so)
15-
expect(sj.send(:safe_to_clean, 'foo')).to eq(true)
15+
expect(sj.send(:safe_to_clean?, 'foo')).to eq(true)
1616
end
1717

1818
it 'Allows cleanup when cherry -v shows no important delta' do
@@ -21,7 +21,7 @@
2121
so = double({ 'stdout' => "- aabbcc0 something\n-bbccdd1 another\n" })
2222
expect(sj).to receive(:git).with('cherry', '-v', 'origin/main', 'foo').
2323
and_return(so)
24-
expect(sj.send(:safe_to_clean, 'foo')).to eq(true)
24+
expect(sj.send(:safe_to_clean?, 'foo')).to eq(true)
2525
end
2626

2727
it 'Does not allow cleanup when we fail to build our merge test branch' do
@@ -42,7 +42,7 @@
4242
and_return(so2)
4343
expect(sj).to receive(:cleanup_tmp_branch).
4444
with(tmp_branch, branch, tracked_branch)
45-
expect(sj.send(:safe_to_clean, branch)).to eq(false)
45+
expect(sj.send(:safe_to_clean?, branch)).to eq(false)
4646
end
4747

4848
it 'Does not allow cleanup when merge test branch shows delta' do
@@ -65,7 +65,7 @@
6565
expect(sj).to receive(:git).with('diff', '--staged').and_return(so3)
6666
expect(sj).to receive(:cleanup_tmp_branch).
6767
with(tmp_branch, branch, tracked_branch)
68-
expect(sj.send(:safe_to_clean, branch)).to eq(false)
68+
expect(sj.send(:safe_to_clean?, branch)).to eq(false)
6969
end
7070

7171
it 'Does allows cleanup when merge test branch shows no delta' do
@@ -89,7 +89,7 @@
8989
expect(sj).to receive(:git).with('diff', '--staged').and_return(so3)
9090
expect(sj).to receive(:cleanup_tmp_branch).
9191
with(tmp_branch, branch, tracked_branch)
92-
expect(sj.send(:safe_to_clean, branch)).to eq(true)
92+
expect(sj.send(:safe_to_clean?, branch)).to eq(true)
9393
end
9494

9595
it 'Uses the correct base for detecting delta' do
@@ -99,7 +99,7 @@
9999
expect(sj).to receive(:git).
100100
with('cherry', '-v', 'origin/develop', 'feature/foo').
101101
and_return(so)
102-
expect(sj.send(:safe_to_clean, 'feature/foo')).to eq(true)
102+
expect(sj.send(:safe_to_clean?, 'feature/foo')).to eq(true)
103103
end
104104
end
105105
end

0 commit comments

Comments
 (0)