17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/worktrees/commands/remove.rb', line 17
def call(name:, **options)
begin
manager = WorktreeManager.new
remove_options = {
delete_branch: options[:delete_branch],
force_untracked: options[:force_untracked],
force: options[:force]
}
remove_options[:merge_base] = options[:merge_base] if options[:merge_base]
result = manager.remove_worktree(name, remove_options)
if result
puts "Removed worktree: #{name}"
puts " Path: (deleted)"
if options[:delete_branch]
puts " Branch: #{name} (deleted)"
else
puts " Branch: #{name} (kept)"
puts ''
puts 'Note: Use --delete-branch to also remove the branch if fully merged'
end
end
rescue ValidationError => e
warn "ERROR: Validation: #{e.message}"
warn 'Use \'worktrees list\' to see existing worktrees'
exit(2)
rescue StateError => e
warn "ERROR: Precondition: #{e.message}"
exit(3)
rescue GitError => e
warn "ERROR: Git: #{e.message}"
exit(3)
rescue StandardError => e
warn "ERROR: #{e.message}"
exit(1)
end
end
|