Skip to content

Instantly share code, notes, and snippets.

@beshkenadze
Created January 23, 2013 13:50
Show Gist options
  • Save beshkenadze/4605810 to your computer and use it in GitHub Desktop.
Save beshkenadze/4605810 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'yaml'
common_git_paths = "which git"
git_path = `#{common_git_paths}`.chomp
filename = File.join(File.dirname(File.expand_path(__FILE__)), '../app/config/parameters.yml')
abort('File not found') unless File.exists?(filename)
abort('Path not found') if (git_path.empty?)
command_line = git_path + " rev-parse --short HEAD"
sha = 'rev. ' + `#{command_line}`.chomp + " " + DateTime.now.strftime('%d/%m/%Y %H:%M:%S')
params = YAML::load_file(filename)
params['parameters']['version'] = sha
File.open(filename, 'w') {|f| f.puts params.to_yaml }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment