Skip to content

Instantly share code, notes, and snippets.

@wizardishungry
Created March 26, 2014 01:24
Show Gist options
  • Save wizardishungry/9775209 to your computer and use it in GitHub Desktop.
Save wizardishungry/9775209 to your computer and use it in GitHub Desktop.
Ruby glue to commit and tag a bunch of tarballs
#!/usr/bin/env ruby
#usage:
# un-tar mpsh tars to directories and then
# ./tag.rb mpsh-1.0 mpsh-1-1 mpsh-1-2 mpsh-1-2-1 mpsh-1-3 mpsh-1-3-1 mpsh-1-4
dir = "mpsh"
author = "Dave Fischer <[email protected]>"
ARGV.each do|a|
a = a.sub /\/$/, ''
if File.directory?(a) then
ver = a.sub(/[a-z]*-([0-9.]*)/, '\1').gsub '-', '.'
puts "Dir: #{a} Ver: #{ver}"
puts `find #{dir} \! -iwholename '*.git*' -mindepth 1 -exec echo rm {} \\;`
puts `cp -Rvp #{a}/ #{dir}`
msg = "Auto-commit of #{ver}"
date = File.mtime(a)
puts `
export GIT_AUTHOR_DATE='#{date}' ;
cd #{dir} &&
git add --all . &&
git commit --author='#{author}' -m '#{msg}' &&
git tag -a #{ver} -m '#{msg}'
`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment