Skip to content

Instantly share code, notes, and snippets.

@mcrisc
Created February 24, 2010 14:45
Show Gist options
  • Save mcrisc/313483 to your computer and use it in GitHub Desktop.
Save mcrisc/313483 to your computer and use it in GitHub Desktop.
# CVS tag scanner (Ruby)
# collecting all existing tags
tags = []
IO.popen('cvs status -v .') do |p|
while line = p.gets
match = /(\S+)\s+\(revision:.+\)/.match(line)
tags << match[1] if match
end
end
# looking for production tags
tags = tags.uniq.find_all {|tag| tag =~ /_PROD$/} # production tags have a trailing _PROD
# creating menu
puts
puts "Possible production tags:"
tags.each_with_index do |tag, i|
puts "#{i}: #{tag}"
end
puts
CVS_UPDATE = "cvs update -dPRr"
print "Choose a number to execute '#{CVS_UPDATE}' on (ctrl+c to abort): "
index = gets.to_i
# running cvs update
if index < tags.length
cmd_line = "#{CVS_UPDATE} #{tags[index]}".squeeze
puts "Starting: #{cmd_line}"
exec cmd_line
else
puts "Invalid option."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment