commit2jira 0.1.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +21 -0
- data/README.markdown +2 -0
- data/bin/commit2jira +37 -0
- data/commit2jira.gemspec +3 -3
- data/features/command_line.feature +88 -0
- data/features/step_definitions/cli_steps.rb +12 -0
- data/features/support/env.rb +3 -0
- data/lib/commit2jira.rb +5 -1
- data/spec/commit2jira_spec.rb +35 -0
- metadata +16 -11
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,25 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
aruba (0.4.11)
|
5
|
+
childprocess (>= 0.2.3)
|
6
|
+
cucumber (>= 1.1.1)
|
7
|
+
ffi (>= 1.0.11)
|
8
|
+
rspec (>= 2.7.0)
|
9
|
+
builder (3.0.0)
|
10
|
+
childprocess (0.3.1)
|
11
|
+
ffi (~> 1.0.6)
|
12
|
+
cucumber (1.1.9)
|
13
|
+
builder (>= 2.1.2)
|
14
|
+
diff-lcs (>= 1.1.2)
|
15
|
+
gherkin (~> 2.9.0)
|
16
|
+
json (>= 1.4.6)
|
17
|
+
term-ansicolor (>= 1.0.6)
|
4
18
|
diff-lcs (1.1.3)
|
19
|
+
ffi (1.0.11)
|
20
|
+
gherkin (2.9.3)
|
21
|
+
json (>= 1.4.6)
|
22
|
+
json (1.6.6)
|
5
23
|
rake (0.9.2)
|
6
24
|
rspec (2.7.0)
|
7
25
|
rspec-core (~> 2.7.0)
|
@@ -11,10 +29,13 @@ GEM
|
|
11
29
|
rspec-expectations (2.7.0)
|
12
30
|
diff-lcs (~> 1.1.2)
|
13
31
|
rspec-mocks (2.7.0)
|
32
|
+
term-ansicolor (1.0.7)
|
14
33
|
|
15
34
|
PLATFORMS
|
16
35
|
ruby
|
17
36
|
|
18
37
|
DEPENDENCIES
|
38
|
+
aruba
|
39
|
+
cucumber
|
19
40
|
rake
|
20
41
|
rspec
|
data/README.markdown
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# commit2jira
|
2
2
|
|
3
|
+
[![Build Status](https://buildhive.cloudbees.com/job/lookout/job/commit2jira/badge/icon)](https://buildhive.cloudbees.com/job/lookout/job/commit2jira/)
|
4
|
+
|
3
5
|
|
4
6
|
commit2jira is a simple gem for parsing a commit message for JIRAs referenced
|
5
7
|
in the meta-data block of the commit body.
|
data/bin/commit2jira
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'rubygems'
|
7
|
+
require 'commit2jira'
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
options = {}
|
12
|
+
parser = OptionParser.new do |opts|
|
13
|
+
opts.banner = "Usage: commit2jira [options]"
|
14
|
+
|
15
|
+
opts.on('-p', '--projects=PROJECTS', "Comma separated list of JIRA projects") do |p|
|
16
|
+
options[:projects] = p.split(',')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
parser.parse!
|
21
|
+
|
22
|
+
if options[:projects].nil?
|
23
|
+
puts parser
|
24
|
+
exit 1
|
25
|
+
end
|
26
|
+
|
27
|
+
found = false
|
28
|
+
Commit2Jira.from_message(options[:projects], ARGF.read) do |project, number|
|
29
|
+
found = true
|
30
|
+
puts "#{project.upcase}-#{number}"
|
31
|
+
end
|
32
|
+
|
33
|
+
unless found
|
34
|
+
puts "No JIRAs found!"
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
|
data/commit2jira.gemspec
CHANGED
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'commit2jira'
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.2.#{ENV['BUILD_NUMBER'] || 'dev'}"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["R. Tyler Croy"]
|
9
|
-
s.email = ["rtyler.croy@
|
10
|
-
s.homepage = 'https://
|
9
|
+
s.email = ["rtyler.croy@lookout.com"]
|
10
|
+
s.homepage = 'https://github.com/lookout/commit2jira'
|
11
11
|
s.summary = %q{a gem for parsing jiras from commits}
|
12
12
|
s.description = %q{Herpy derpy}
|
13
13
|
|
@@ -0,0 +1,88 @@
|
|
1
|
+
Feature: Allow piping commit messages into a command line tool
|
2
|
+
In order to list the JIRAs for a specific commit
|
3
|
+
As a command line user
|
4
|
+
I should be able to parse out JIRAs from any bit of text
|
5
|
+
|
6
|
+
|
7
|
+
Scenario: Without any options
|
8
|
+
When I run `commit2jira`
|
9
|
+
Then the exit status should be 1
|
10
|
+
And the output should contain:
|
11
|
+
"""
|
12
|
+
Usage: commit2jira
|
13
|
+
"""
|
14
|
+
|
15
|
+
Scenario: With a single project
|
16
|
+
Given the commit:
|
17
|
+
"""
|
18
|
+
commit 49060a4b0d7c6e9ddfc20a42eae8dbd93d03b458
|
19
|
+
Author: R. Tyler Croy <rtyler.croy@mylookout.com>
|
20
|
+
Date: Fri Apr 6 17:29:07 2012 -0700
|
21
|
+
|
22
|
+
Add the MIT license
|
23
|
+
|
24
|
+
JIRA: DEMO-1
|
25
|
+
"""
|
26
|
+
When I pipe the commit into `commit2jira -p demo`
|
27
|
+
Then the exit status should be 0
|
28
|
+
And the output should contain exactly:
|
29
|
+
"""
|
30
|
+
DEMO-1
|
31
|
+
|
32
|
+
"""
|
33
|
+
|
34
|
+
Scenario: A single project with multiple JIRAs
|
35
|
+
Given the commit:
|
36
|
+
"""
|
37
|
+
commit 49060a4b0d7c6e9ddfc20a42eae8dbd93d03b458
|
38
|
+
Author: R. Tyler Croy <rtyler.croy@mylookout.com>
|
39
|
+
Date: Fri Apr 6 17:29:07 2012 -0700
|
40
|
+
|
41
|
+
Add the MIT license
|
42
|
+
|
43
|
+
JIRA: DEMO-1, DEMO-2
|
44
|
+
"""
|
45
|
+
When I pipe the commit into `commit2jira -p demo`
|
46
|
+
Then the exit status should be 0
|
47
|
+
And the output should contain exactly:
|
48
|
+
"""
|
49
|
+
DEMO-1
|
50
|
+
DEMO-2
|
51
|
+
|
52
|
+
"""
|
53
|
+
|
54
|
+
Scenario: Multiple projects
|
55
|
+
Given the commit:
|
56
|
+
"""
|
57
|
+
commit 49060a4b0d7c6e9ddfc20a42eae8dbd93d03b458
|
58
|
+
Author: R. Tyler Croy <rtyler.croy@mylookout.com>
|
59
|
+
Date: Fri Apr 6 17:29:07 2012 -0700
|
60
|
+
|
61
|
+
Add the MIT license
|
62
|
+
|
63
|
+
JIRA: DEMO-1, LAB-2
|
64
|
+
"""
|
65
|
+
When I pipe the commit into `commit2jira -p demo,lab`
|
66
|
+
Then the exit status should be 0
|
67
|
+
And the output should contain exactly:
|
68
|
+
"""
|
69
|
+
DEMO-1
|
70
|
+
LAB-2
|
71
|
+
|
72
|
+
"""
|
73
|
+
|
74
|
+
Scenario: No referenced JIRAs
|
75
|
+
Given the commit:
|
76
|
+
"""
|
77
|
+
commit 49060a4b0d7c6e9ddfc20a42eae8dbd93d03b458
|
78
|
+
Author: R. Tyler Croy <rtyler.croy@mylookout.com>
|
79
|
+
Date: Fri Apr 6 17:29:07 2012 -0700
|
80
|
+
|
81
|
+
Add the MIT license
|
82
|
+
"""
|
83
|
+
When I pipe the commit into `commit2jira -p demo`
|
84
|
+
Then the exit status should be 1
|
85
|
+
And the output should contain:
|
86
|
+
"""
|
87
|
+
No JIRAs found!
|
88
|
+
"""
|
data/lib/commit2jira.rb
CHANGED
@@ -2,10 +2,14 @@
|
|
2
2
|
require 'rubygems'
|
3
3
|
|
4
4
|
module Commit2Jira
|
5
|
-
def from_message(projects, message, &block)
|
5
|
+
def from_message(projects, message, precise_match=false, &block)
|
6
6
|
if message.nil? or message.empty?
|
7
7
|
return
|
8
8
|
end
|
9
|
+
if precise_match
|
10
|
+
message = message.split("\n").select {|line| line.start_with?("JIRA:")}.join("\n")
|
11
|
+
end
|
12
|
+
|
9
13
|
regex = /\b(#{projects.join('|')})-(\d+)\b/i
|
10
14
|
|
11
15
|
message.scan(regex) do |match|
|
data/spec/commit2jira_spec.rb
CHANGED
@@ -32,5 +32,40 @@ END
|
|
32
32
|
expected_project.should == found_project
|
33
33
|
expected_number.should == found_number
|
34
34
|
end
|
35
|
+
|
36
|
+
it "should call the block for two JIRAs with the right projects" do
|
37
|
+
expected_projects = ['FOO', 'BAR']
|
38
|
+
expected_numbers = [4779, 5013]
|
39
|
+
message =<<END
|
40
|
+
This is a simple commit message referencing #{expected_projects[0]}-#{expected_numbers[0]}
|
41
|
+
|
42
|
+
JIRA: #{expected_projects[1]}-#{expected_numbers[1]}
|
43
|
+
END
|
44
|
+
Commit2Jira.from_message(['foo', 'bar'], message) do |project, number|
|
45
|
+
expected_projects.shift if project == expected_projects[0]
|
46
|
+
expected_numbers.shift if number == expected_numbers[0]
|
47
|
+
end
|
48
|
+
|
49
|
+
expected_projects.should be_empty
|
50
|
+
expected_numbers.should be_empty
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should call the block for only the JIRAs explicitly mentioned when specified" do
|
54
|
+
expected_projects = ['BAR', 'BAZ']
|
55
|
+
expected_numbers = [5013, 8724]
|
56
|
+
message =<<END
|
57
|
+
This is a simple commit message referencing FOO-4779
|
58
|
+
|
59
|
+
JIRA: #{expected_projects[0]}-#{expected_numbers[0]}, #{expected_projects[1]}-#{expected_numbers[1]}
|
60
|
+
END
|
61
|
+
|
62
|
+
Commit2Jira.from_message(['foo', 'bar', 'baz'], message, true) do |project, number|
|
63
|
+
expected_projects.shift if project == expected_projects[0]
|
64
|
+
expected_numbers.shift if number == expected_numbers[0]
|
65
|
+
end
|
66
|
+
|
67
|
+
expected_projects.should be_empty
|
68
|
+
expected_numbers.should be_empty
|
69
|
+
end
|
35
70
|
end
|
36
71
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commit2jira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- R. Tyler Croy
|
@@ -15,15 +15,14 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
19
|
-
default_executable:
|
18
|
+
date: 2012-11-15 00:00:00 Z
|
20
19
|
dependencies: []
|
21
20
|
|
22
21
|
description: Herpy derpy
|
23
22
|
email:
|
24
|
-
- rtyler.croy@
|
25
|
-
executables:
|
26
|
-
|
23
|
+
- rtyler.croy@lookout.com
|
24
|
+
executables:
|
25
|
+
- commit2jira
|
27
26
|
extensions: []
|
28
27
|
|
29
28
|
extra_rdoc_files: []
|
@@ -35,11 +34,14 @@ files:
|
|
35
34
|
- LICENSE
|
36
35
|
- README.markdown
|
37
36
|
- Rakefile
|
37
|
+
- bin/commit2jira
|
38
38
|
- commit2jira.gemspec
|
39
|
+
- features/command_line.feature
|
40
|
+
- features/step_definitions/cli_steps.rb
|
41
|
+
- features/support/env.rb
|
39
42
|
- lib/commit2jira.rb
|
40
43
|
- spec/commit2jira_spec.rb
|
41
|
-
|
42
|
-
homepage: https://source.flexilis.local/rcroy/commit2jira
|
44
|
+
homepage: https://github.com/lookout/commit2jira
|
43
45
|
licenses: []
|
44
46
|
|
45
47
|
post_install_message:
|
@@ -68,9 +70,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
70
|
requirements: []
|
69
71
|
|
70
72
|
rubyforge_project:
|
71
|
-
rubygems_version: 1.
|
73
|
+
rubygems_version: 1.8.24
|
72
74
|
signing_key:
|
73
75
|
specification_version: 3
|
74
76
|
summary: a gem for parsing jiras from commits
|
75
77
|
test_files:
|
78
|
+
- features/command_line.feature
|
79
|
+
- features/step_definitions/cli_steps.rb
|
80
|
+
- features/support/env.rb
|
76
81
|
- spec/commit2jira_spec.rb
|