Skip to content

Instantly share code, notes, and snippets.

@pbonnell
Last active August 29, 2015 14:06
Show Gist options
  • Save pbonnell/460190a9b78c3a78bcdd to your computer and use it in GitHub Desktop.
Save pbonnell/460190a9b78c3a78bcdd to your computer and use it in GitHub Desktop.
Ruby shell script to show what git branches contain the current release of a heroku app
#!/usr/bin/env ruby
if ARGV[0].nil?
puts "List the local branches of a git repository that contain the most recent release of a heroku app."
puts "usage: released-from heroku-app-name"
exit
else
h = `heroku releases -n1 -a#{ARGV[0]}`
puts h
parsed = h.scan(/Deploy (.{7}) /).flatten[0]
unless parsed.nil?
puts "#{parsed} is on :"
exec("git branch --contains #{parsed}")
end
end
# mv ~/Downloads/released-from.rb /usr/local/bin/released-from
# chmod +x /usr/local/bin/released-from
@pbonnell
Copy link
Author

mv ~/Downloads/released-from.rb /usr/local/bin/released-from
chmod +x /usr/local/bin/released-from

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment