Created
October 29, 2010 21:55
-
-
Save jmeridth/654514 to your computer and use it in GitHub Desktop.
git enforced commit message (windows)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'soap/wsdlDriver' | |
| require 'grit' | |
| jira_address = "http://host:8080" | |
| jira_username= "username" | |
| jira_password = "password" | |
| repo = Grit::Repo.new(".") | |
| while (input = STDIN.read) != '' | |
| old_rev, new_rev, ref = input.split(" ") | |
| regex = /((KEY1|KEY2)-(\d+)(,\s*(KEY1|KEY2)-(\d+))*:*)/i | |
| ignore_regex = /^Merge Branch.*/i | |
| repo.commits_between(old_rev, new_rev).each do |commit| | |
| next if commit.message =~ ignore_regex | |
| unless commit.message =~ regex | |
| puts "[POLICY] Your message is either formatted incorrectly" | |
| puts "or contains an unknown project key" | |
| puts "FORMAT: [KEY1|KEY2]-#: message" | |
| puts "for multiple issues: [KEY1|KEY2]-#,[KEY1|KEY2-#,...: message" | |
| puts "Your message: #{commit.message}" | |
| exit 1 | |
| end | |
| wsdl_url = "#{jira_address}/rpc/soap/jirasoapservice-v2?wsdl" | |
| proxy = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver | |
| auth = proxy.login(jira_username, jira_password) | |
| issues = commit.message[regex] | |
| issues.gsub(':','').split(',').each do |issue| | |
| begin | |
| info = proxy.getIssue(auth, issue.strip) | |
| rescue SOAP::FaultError => e | |
| puts "[POLICY] The issue #{issue.strip} does not exist" | |
| exit 1 | |
| end | |
| end | |
| end | |
| end |
ChristopherMacGown
commented
Oct 30, 2010
Author
the only issue with using soap4r gem was that you'll see:
remote: ignored attr: {}abstract
for each of the SOAP calls. was still better than the savon gem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment