Module: Wralph::Run::Remove

Defined in:
lib/wralph/run/remove.rb

Class Method Summary collapse

Class Method Details

.run(issue_number) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/wralph/run/remove.rb', line 10

def self.run(issue_number)
  Init.ensure_initialized!

  branch_name = "issue-#{issue_number}".freeze

  # Delete local branch
  _, _, success = Interfaces::Shell.run_command("git branch -D #{branch_name}")
  if success
    Interfaces::Print.info "Deleted branch '#{branch_name}' locally"
  else
    Interfaces::Print.warning "Branch '#{branch_name}' not found locally"
  end

  # Delete remote branch
  _, _, success = Interfaces::Shell.run_command("git push origin --delete #{branch_name}")
  if success
    Interfaces::Print.info "Deleted branch '#{branch_name}' on remote"
  else
    Interfaces::Print.warning "Branch '#{branch_name}' not found on remote"
  end

  # Remove worktree
  _, _, success = Interfaces::Shell.run_command("wt remove #{branch_name}")
  if success
    Interfaces::Print.info "Removed worktree for branch '#{branch_name}'"
  else
    Interfaces::Print.warning "Worktree for branch '#{branch_name}' not found"
  end

  Interfaces::Print.success "Cleanup completed for issue ##{issue_number}"
end