Skip to content

Instantly share code, notes, and snippets.

@xnuk
Created February 28, 2019 06:08
Show Gist options
  • Save xnuk/0208f6cee812e86986646e1a47cd18ef to your computer and use it in GitHub Desktop.
Save xnuk/0208f6cee812e86986646e1a47cd18ef to your computer and use it in GitHub Desktop.
set = Set.new ["HEAD"]
process = Process.new "git", args: [
"for-each-ref",
"--count=100",
"--sort=-committerdate",
"refs/",
"--format=%(refname:short)",
"--no-merged=HEAD"
], output: Process::Redirect::Pipe
process.output.each_line do |l|
branch_name = l.strip.sub /^origin\//, ""
puts branch_name unless set.includes? branch_name
set << branch_name
end
exit process.wait.exit_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment