File tree 3 files changed +21
-1
lines changed
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -337,6 +337,10 @@ def worktree_remove(dir)
337
337
command ( 'worktree' , [ 'remove' , dir ] )
338
338
end
339
339
340
+ def worktree_prune
341
+ command ( 'worktree' , [ 'prune' ] )
342
+ end
343
+
340
344
def list_files ( ref_dir )
341
345
dir = File . join ( @git_dir , 'refs' , ref_dir )
342
346
files = [ ]
Original file line number Diff line number Diff line change @@ -39,5 +39,9 @@ def to_s
39
39
end
40
40
out
41
41
end
42
+
43
+ def prune
44
+ @base . lib . worktree_prune
45
+ end
42
46
end
43
47
end
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env ruby
2
-
2
+ require 'fileutils'
3
3
require File . dirname ( __FILE__ ) + '/../test_helper'
4
4
5
5
SAMPLE_LAST_COMMIT = '5e53019b3238362144c2766f02a2c00d91fcc023'
@@ -47,4 +47,16 @@ def test_worktree_add_and_remove
47
47
48
48
assert_equal ( @git . worktrees . size , 2 )
49
49
end
50
+
51
+ def test_worktree_prune
52
+ assert_equal ( 2 , @git . worktrees . size )
53
+
54
+ @git . worktree ( '/tmp/pp1' ) . add
55
+ assert_equal ( 3 , @git . worktrees . size )
56
+ @git . worktrees . prune
57
+ assert_equal ( 2 , @git . worktrees . size )
58
+ FileUtils . rm_rf ( '/tmp/pp1' )
59
+ @git . worktrees . prune
60
+ assert_equal ( 1 , @git . worktrees . size )
61
+ end
50
62
end
You can’t perform that action at this time.
0 commit comments