Files
dotfiles/dot_config/nushell/nu_scripts/sourced/github/merged-branches/merged-branches.nu
Cian Hughes 896af887ca Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows)
and improves grepability with neovim/telescope
2024-11-07 13:52:17 +00:00

15 lines
469 B
Nu

#!/usr/bin/env nu
gh api $"orgs/($env.OWNER)/repos"
|from json
|each {|repo|
gh api $"repos/($env.OWNER)/($repo.name)/pulls?state=closed"
|from json
|if ($in|length) > 0 {
each {|pull|
print $"Removing branch ($pull.head.ref) from repo ($repo.name)"
gh api -X DELETE $"repos/($env.OWNER)/($repo.name)/git/refs/heads/($pull.head.ref)"
}
} else {
print $"Repo ($repo.name) has no branches to delete"
}
}