svn-hook-tools 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +14 -0
- data/README +12 -0
- data/Rakefile +56 -0
- data/lib/jira4r/jira4r.rb +34 -0
- data/lib/jira4r/jira_tool.rb +211 -0
- data/lib/jira4r/v2/JiraSoapServiceDriver.rb +981 -0
- data/lib/jira4r/v2/jiraService.rb +817 -0
- data/lib/jira4r/v2/jiraServiceMappingRegistry.rb +976 -0
- data/lib/jiraService.rb +21 -0
- data/lib/jiraServiceMappingRegistry.rb +21 -0
- data/lib/svn_jira_hook.rb +77 -0
- data/pre-commit.sample +19 -0
- data/test/test_helper.rb +4 -0
- metadata +93 -0
data/lib/jiraService.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright 2007 Codehaus Foundation #
|
3
|
+
# #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); #
|
5
|
+
# you may not use this file except in compliance with the License. #
|
6
|
+
# You may obtain a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
################################################################################
|
16
|
+
|
17
|
+
# This is a pointless file to get around the inflexibility of the WSDL2RUBY code.
|
18
|
+
#
|
19
|
+
# It appears to be impossible to get it to generate files into a useful directory structure
|
20
|
+
#
|
21
|
+
# Oh well...
|
@@ -0,0 +1,21 @@
|
|
1
|
+
################################################################################
|
2
|
+
# Copyright 2007 Codehaus Foundation #
|
3
|
+
# #
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); #
|
5
|
+
# you may not use this file except in compliance with the License. #
|
6
|
+
# You may obtain a copy of the License at #
|
7
|
+
# #
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
9
|
+
# #
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
13
|
+
# See the License for the specific language governing permissions and #
|
14
|
+
# limitations under the License. #
|
15
|
+
################################################################################
|
16
|
+
|
17
|
+
# This is a pointless file to get around the inflexibility of the WSDL2RUBY code.
|
18
|
+
#
|
19
|
+
# It appears to be impossible to get it to generate files into a useful directory structure
|
20
|
+
#
|
21
|
+
# Oh well...
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "jira4r/jira_tool"
|
3
|
+
|
4
|
+
|
5
|
+
class JiraHook
|
6
|
+
|
7
|
+
def initialize(base_url)
|
8
|
+
@jira = ::Jira4R::JiraTool.new(2, base_url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def login(user, pass)
|
12
|
+
@jira.login(user, pass)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.check(argv)
|
16
|
+
repo_path = argv[0]
|
17
|
+
transaction = argv[1]
|
18
|
+
svnlook = 'svnlook'
|
19
|
+
|
20
|
+
#commit_dirs_changed = `#{svnlook} dirs-changed #{repo_path} -t #{transaction}`
|
21
|
+
#commit_changed = `#{svnlook} changed #{repo_path} -t #{transaction}`
|
22
|
+
commit_author = `#{svnlook} author #{repo_path} -t #{transaction}`.chop
|
23
|
+
commit_log = `#{svnlook} log #{repo_path} -t #{transaction}`
|
24
|
+
#commit_diff = `#{svnlook} diff #{repo_path} -t #{transaction}`
|
25
|
+
#commit_date = `#{svnlook} date #{repo_path} -t #{transaction}`
|
26
|
+
|
27
|
+
if commit_log.nil? || commit_log.empty?
|
28
|
+
STDERR.puts("提交注释必须填写,而且需要包括分配给你的bug号!")
|
29
|
+
exit(1)
|
30
|
+
end
|
31
|
+
|
32
|
+
jira = JiraHook.new('http://192.168.0.3/jira')
|
33
|
+
jira.login('username', 'password')
|
34
|
+
|
35
|
+
unless jira.check_right(commit_author, '[Ss][Bb]', commit_log)
|
36
|
+
STDERR.puts("提交注释中必须包括分配给你的bug号!\n例如: SB-10: 修改说明")
|
37
|
+
exit(1)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# check the message is match the issue_key_regex
|
43
|
+
# and assign to the user
|
44
|
+
def check_right(username, issue_key_regex, message)
|
45
|
+
if message.nil? || message.empty?
|
46
|
+
return false
|
47
|
+
end
|
48
|
+
issue_id = getIssueNumber(message, issue_key_regex)
|
49
|
+
if issue_id.nil?
|
50
|
+
return false
|
51
|
+
end
|
52
|
+
has_right(username, issue_id)
|
53
|
+
end
|
54
|
+
|
55
|
+
def has_right(username, issue_id)
|
56
|
+
begin
|
57
|
+
issue = @jira.getIssue(issue_id)
|
58
|
+
if issue.assignee == username && issue.status == '3'
|
59
|
+
return true
|
60
|
+
else
|
61
|
+
return false
|
62
|
+
end
|
63
|
+
rescue SOAP::FaultError
|
64
|
+
return false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def getIssueNumber(message, keyreg)
|
69
|
+
re = Regexp.new("#{keyreg}-[0-9]+")
|
70
|
+
if message =~ re
|
71
|
+
"#{$&}".upcase
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
data/pre-commit.sample
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rujira'
|
5
|
+
|
6
|
+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
7
|
+
# new version
|
8
|
+
|
9
|
+
# /etc/jira-config
|
10
|
+
# -
|
11
|
+
# url: http://192.168.0.3/jira
|
12
|
+
# username: crazycode
|
13
|
+
# password: ******
|
14
|
+
require 'rubygems'
|
15
|
+
require 'svn_jira_hook'
|
16
|
+
|
17
|
+
# or JiraHook.setup(url, user, pass)
|
18
|
+
|
19
|
+
JiraHook.check(ARGV)
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: svn-hook-tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 1
|
10
|
+
version: 0.5.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- crazycode
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-09 00:00:00 +08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: soap4r
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: svn jira hook ruby lib.
|
36
|
+
email: crazycode@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README
|
44
|
+
files:
|
45
|
+
- LICENSE
|
46
|
+
- README
|
47
|
+
- Rakefile
|
48
|
+
- lib/jira4r/jira4r.rb
|
49
|
+
- lib/jira4r/jira_tool.rb
|
50
|
+
- lib/jira4r/v2/JiraSoapServiceDriver.rb
|
51
|
+
- lib/jira4r/v2/jiraService.rb
|
52
|
+
- lib/jira4r/v2/jiraServiceMappingRegistry.rb
|
53
|
+
- lib/jiraService.rb
|
54
|
+
- lib/jiraServiceMappingRegistry.rb
|
55
|
+
- lib/svn_jira_hook.rb
|
56
|
+
- pre-commit.sample
|
57
|
+
- test/test_helper.rb
|
58
|
+
has_rdoc: true
|
59
|
+
homepage: http://github.com/crazycode/svn-hook-tools
|
60
|
+
licenses: []
|
61
|
+
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 3
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
requirements: []
|
86
|
+
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.3.7
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: svn jira hook lib.
|
92
|
+
test_files: []
|
93
|
+
|