Skip to content

Instantly share code, notes, and snippets.

@pupca
Created November 12, 2010 14:39
Show Gist options
  • Save pupca/674161 to your computer and use it in GitHub Desktop.
Save pupca/674161 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#REPO/.git/hooks/commit-msg
message_file = ARGV[0]
message = File.read(message_file)
if /#\d+/.match(message)
id = /#(\d+)/.match(message)[1]
require 'rubygems'
require 'active_resource'
# Issue model on the client side
class Issue < ActiveResource::Base
self.site = 'http://devel.railsworx.org:56080'
self.user = ''
end
issues = Issue.find(id)
string = "##{id}: #{issues.subject} (http://www.devel.railsworx.org:56080/issues/#{id})"
message.gsub!(/#\d+/, string)
File.open(message_file, "w+") do |file|
file.puts message
end
puts message
else
puts "Specifikuj v commitu cislo tasku z redminu na kterem jsi pracoval!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment