Class: JiraHook
- Inherits:
-
Object
- Object
- JiraHook
- Defined in:
- lib/svn_jira_hook.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#check_right(username, issue_key_regex, message) ⇒ Object
check the message is match the issue_key_regex and assign to the user.
- #get_issue_number(message, keyprefix) ⇒ Object
- #has_right(username, issue_id) ⇒ Object
-
#initialize(base_url = nil) ⇒ JiraHook
constructor
A new instance of JiraHook.
- #login(user, pass) ⇒ Object
Constructor Details
Class Method Details
.check(commit_author, commit_log, keyprefix, config = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/svn_jira_hook.rb', line 16 def self.check(argv, keyprefix, config = nil) repo_path = argv[0] transaction = argv[1] svnlook = 'svnlook' #commit_dirs_changed = `#{svnlook} dirs-changed #{repo_path} -t #{transaction}` #commit_changed = `#{svnlook} changed #{repo_path} -t #{transaction}` = `#{svnlook} author #{repo_path} -t #{transaction}`.chop commit_log = `#{svnlook} log #{repo_path} -t #{transaction}` #commit_diff = `#{svnlook} diff #{repo_path} -t #{transaction}` #commit_date = `#{svnlook} date #{repo_path} -t #{transaction}` if commit_log.nil? || commit_log.empty? STDERR.puts("'#{commit_log}' doesn't exist as a issue on Jira") exit(1) end check(, commit_log, keyprefix, config) end |
.configuration ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/svn_jira_hook.rb', line 94 def self.configuration if defined?(SVN_HOOKS_CONFIG_PATH) config_file = SVN_HOOKS_CONFIG_PATH else config_file = '/etc/svn_hooks.yml' end YAML::load(IO.read(config_file)) end |
Instance Method Details
#check_right(username, issue_key_regex, message) ⇒ Object
check the message is match the issue_key_regex and assign to the user
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/svn_jira_hook.rb', line 57 def check_right(username, issue_key_regex, ) if .nil? || .empty? return false end issue_id = get_issue_number(, issue_key_regex) if issue_id.nil? return false end has_right(username, issue_id) end |
#get_issue_number(message, keyprefix) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/svn_jira_hook.rb', line 81 def get_issue_number(, keyprefix) # key="ab" => key=[Aa][Bb] keyreg = [] keyprefix.each_char do |c| keyreg << "[#{c.upcase}#{c.downcase}]" end re = Regexp.new("#{keyreg.join("")}-[0-9]+") if =~ re "#{$&}".upcase end end |
#has_right(username, issue_id) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/svn_jira_hook.rb', line 68 def has_right(username, issue_id) begin issue = @jira.getIssue(issue_id) if issue.assignee == username && issue.status == '3' return true else return false end rescue SOAP::FaultError return false end end |
#login(user, pass) ⇒ Object
11 12 13 |
# File 'lib/svn_jira_hook.rb', line 11 def login(user, pass) @jira.login(user, pass) end |