hookie 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.travis.yml +3 -0
- data/README.md +20 -2
- data/Rakefile +2 -0
- data/hookie.gemspec +4 -2
- data/lib/hookie.rb +1 -5
- data/lib/hookie/plugins/empty_plugin.rb +0 -1
- data/lib/hookie/plugins/fisheye_plugin.rb +54 -0
- data/lib/hookie/version.rb +3 -0
- data/spec/base_plugin_spec.rb +5 -0
- data/spec/fisheye_plugin_spec.rb +69 -0
- data/spec/framework_spec.rb +107 -0
- data/spec/hipchat_plugin_spec.rb +71 -3
- data/spec/spec_helper.rb +5 -0
- data/travis.yml +3 -0
- metadata +42 -4
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Hookie is a pluggable framework for creating git hooks using Ruby. It was originally designed for writing hooks for gitolite, but should work for any hooks, including local ones.
|
4
4
|
|
5
|
+
[![Build Status](https://travis-ci.org/marcins/hookie.png?branch=develop)](https://travis-ci.org/marcins/hookie)
|
6
|
+
|
5
7
|
## Background
|
6
8
|
|
7
9
|
After we had setup [HipChat](http://hipchat.com) at our organisation I wanted to get notifications from gitolite pushes pushed to HipChat. I found the [gitolite-hipchat-notification](https://github.com/peplin/gitolite-hipchat-notification) project, and [forked it](https://github.com/marcins/gitolite-hipchat-notification) and cleaned it up a bit for my purposes. However this script wasn't very flexible in that you needed to add it individually to each repo (or suffer with a single config). Then I wanted to add Jenkins build notifications as well, so had to enhance the script to support running multiple tasks. Eventually it was all getting too crufty and so Hookie was born!
|
@@ -10,9 +12,11 @@ Hookie is designed so that you can have multiple actions take place as a result
|
|
10
12
|
|
11
13
|
Hookie includes those aforementioned plugins for HipChat and Jenkins in the base build.
|
12
14
|
|
15
|
+
In addition there is now a FishEye plugin (as of v1.0.1)
|
16
|
+
|
13
17
|
## Acknowledgements
|
14
18
|
|
15
|
-
Hookie is built on the base of @peplin's
|
19
|
+
Hookie is built on the base of @peplin's [gitolite-hipchat-notification](https://github.com/peplin/gitolite-hipchat-notification) project, which was originally forked from [gitolite-campfire-notification](https://github.com/LegionSB/gitolite-campfire-notification) - the magic of Open Source!
|
16
20
|
|
17
21
|
Hookie uses [grit](https://github.com/mojombo/grit) for accessing information in git repositories.
|
18
22
|
|
@@ -50,6 +54,10 @@ You can also install Hookie hooks manually, by adding them to the hooks director
|
|
50
54
|
|
51
55
|
## Configuration
|
52
56
|
|
57
|
+
**NOTE** for gitolite you will need to make the following change to .gitolite.rc or your config keys won't work!
|
58
|
+
|
59
|
+
GIT_CONFIG_KEYS => 'hookie\..*',
|
60
|
+
|
53
61
|
Hookie was written such that it can be configured using Gitolite's ability to set git config keys via the gitolite-admin repository.
|
54
62
|
|
55
63
|
You can set "global" config keys using the special repository @all in gitolite, and override or set project specific keys within the repository itself. This makes it easy to, for example, set your HipChat API key for all repos, but then set the room that gets notified in each repo separately - and this can all be done via the gitolite-admin repository, without requiring access to the git server.
|
@@ -61,7 +69,7 @@ An example conf/gitolite.conf:
|
|
61
69
|
|
62
70
|
repo testing
|
63
71
|
RW+ = @all
|
64
|
-
config hookie.core.allowedplugins = hipchat,jenkins
|
72
|
+
config hookie.core.allowedplugins = hipchat,jenkins,fisheye
|
65
73
|
config hookie.hipchat.room = 123456
|
66
74
|
config hookie.jenkins.url = http://jenkins.example.com/job/Test%20Job/build?token=test
|
67
75
|
config hookie.jenkins.branches=develop
|
@@ -72,6 +80,8 @@ An example conf/gitolite.conf:
|
|
72
80
|
config hookie.hipchat.from = "Git Test"
|
73
81
|
config hookie.core.web.commit = https://fisheye.example.com/changelog/%REPO%?cs=%COMMIT%
|
74
82
|
config hookie.core.web.browse = https://fisheye.example.com/browse/%REPO%
|
83
|
+
config hookie.fisheye.apikey = APIKEY
|
84
|
+
config hookie.fisheye.url = https://fisheye.example.com/rest-service-fecru/admin/repositories-v1/%REPO%/scan
|
75
85
|
|
76
86
|
The following core keys are used by the framework:
|
77
87
|
|
@@ -87,6 +97,7 @@ The following plugins are shipped with Hookie:
|
|
87
97
|
|
88
98
|
* HipChat - posts a notification to a HipChat room in response to a commit
|
89
99
|
* Jenkins - triggers a Jenkins build in reponse to a commit
|
100
|
+
* FishEye - triggers a scan of a FishEye repository in response to a commit
|
90
101
|
|
91
102
|
### HipChat
|
92
103
|
|
@@ -106,6 +117,13 @@ The following config keys apply to the Jenkins plugin:
|
|
106
117
|
* **hookie.jenkins.branches** - only trigger a build if the change set includes commits to the branches in this list. Comma separated. Default is to build for any commit.
|
107
118
|
* **hookie.jenkins.auth** - the username:token combo to use to authenticate with Jenkins
|
108
119
|
|
120
|
+
### FishEye
|
121
|
+
|
122
|
+
The following config keys apply to the Fisheye plugin:
|
123
|
+
|
124
|
+
* **hookie.fisheye.url** - the FishEye REST API URL (see the [FishEye docs](https://confluence.atlassian.com/display/FISHEYE033/Configuring+Commit+Hooks) for where to find this URL). You should use the placeholder `%REPO%` which will be replaced with the repo name
|
125
|
+
* **hookie.fisheye.apikey** - the FishEye REST API Key (see the [FishEye docs](https://confluence.atlassian.com/display/FISHEYE033/Setting+the+REST+API+token) for where to obtain this token)
|
126
|
+
|
109
127
|
## Writing Plugins
|
110
128
|
|
111
129
|
Hookie was designed to be extensible by writing your own plugins.
|
data/Rakefile
CHANGED
data/hookie.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
|
-
require 'hookie'
|
5
|
+
require 'hookie/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |gem|
|
8
8
|
gem.name = "hookie"
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.email = ["marcins@webqem.com"]
|
12
12
|
gem.description = %q{Hookie provides a way to write git hooks with ruby without too much worrying about any of the plumbing required, you can easily write your own plugins and focus on the core of your functionality.
|
13
13
|
|
14
|
-
Hookie includes plugins for Jenkins and HipChat.}
|
14
|
+
Hookie includes plugins for Jenkins, FishEye, and HipChat.}
|
15
15
|
gem.summary = %q{Framework for writing gitolite/git hooks with Ruby}
|
16
16
|
gem.homepage = "https://github.com/marcins/hookie"
|
17
17
|
|
@@ -23,5 +23,7 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_dependency 'grit', '~> 2.5.0'
|
24
24
|
gem.add_dependency 'diff-lcs', '~> 1.1.3'
|
25
25
|
|
26
|
+
gem.add_development_dependency 'rake', '>= 10.0.3'
|
26
27
|
gem.add_development_dependency 'rspec', '~> 2.12.0'
|
28
|
+
gem.add_development_dependency 'simplecov', '>= 0.4.0'
|
27
29
|
end
|
data/lib/hookie.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative 'base_plugin'
|
2
|
+
|
3
|
+
require 'time'
|
4
|
+
require 'net/https'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module Hookie
|
8
|
+
module Plugin
|
9
|
+
class FishEyePlugin < BasePlugin
|
10
|
+
def to_s
|
11
|
+
"FishEye Notifier"
|
12
|
+
end
|
13
|
+
|
14
|
+
def should_run?
|
15
|
+
warnings = []
|
16
|
+
if @framework.changes.empty?
|
17
|
+
log "No changes"
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
warnings << "hookie.fisheye.apikey not set!" unless @config[:apikey]
|
21
|
+
warnings << "hookie.fisheye.url not set!" unless @config[:url]
|
22
|
+
|
23
|
+
log warnings.join(", ") unless warnings.empty?
|
24
|
+
|
25
|
+
warnings.empty?
|
26
|
+
end
|
27
|
+
|
28
|
+
def post_receive
|
29
|
+
log "Sending scan request to FishEye ... "
|
30
|
+
response = notify()
|
31
|
+
if response == []
|
32
|
+
log "Request sent to FishEye"
|
33
|
+
elsif response[:message]
|
34
|
+
log "Error: #{response[:message]}"
|
35
|
+
else
|
36
|
+
log "Unknown response #{response}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def notify
|
42
|
+
uri = URI.parse(@config[:url].gsub('%REPO%', @framework.repo_name))
|
43
|
+
http = Net::HTTP.new(uri.host, uri.port, @config[:proxyaddress], @config[:proxyport])
|
44
|
+
http.use_ssl = true
|
45
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
46
|
+
request = Net::HTTP::Post.new(uri.path)
|
47
|
+
request['X-Api-Key'] = @config[:apikey]
|
48
|
+
|
49
|
+
JSON.parse(http.request(request).body, {symbolize_names: true})
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/spec/base_plugin_spec.rb
CHANGED
@@ -19,6 +19,11 @@ describe Hookie::BasePlugin do
|
|
19
19
|
it "should initialise" do
|
20
20
|
|
21
21
|
end
|
22
|
+
|
23
|
+
it "is runnable" do
|
24
|
+
@plugin.should_run?.should be_true
|
25
|
+
end
|
26
|
+
|
22
27
|
it "should correctly derive the plugin name" do
|
23
28
|
@plugin.to_s.should eq "Base"
|
24
29
|
@plugin.config_key.should eq "base"
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'hookie'
|
3
|
+
require 'hookie/plugins/fisheye_plugin'
|
4
|
+
|
5
|
+
describe Hookie::Plugin::FishEyePlugin do
|
6
|
+
before :each do
|
7
|
+
@hookie = double(Hookie::Framework)
|
8
|
+
@config = double(Grit::Config)
|
9
|
+
@config.stub(:keys).and_return([])
|
10
|
+
|
11
|
+
@hookie.stub(:config).and_return(@config)
|
12
|
+
@hookie.stub(:log)
|
13
|
+
end
|
14
|
+
|
15
|
+
context "FishEye plugin" do
|
16
|
+
before :each do
|
17
|
+
@plugin = Hookie::Plugin::FishEyePlugin.new @hookie
|
18
|
+
end
|
19
|
+
|
20
|
+
context "config" do
|
21
|
+
it "identifies itself" do
|
22
|
+
@plugin.to_s.should eq "FishEye Notifier"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "shouldn't run only when there are no changes" do
|
26
|
+
@hookie.should_receive(:changes).once.and_return([])
|
27
|
+
@plugin.should_run?.should be_false
|
28
|
+
end
|
29
|
+
|
30
|
+
it "shouldn't run when there are changes but config is missing" do
|
31
|
+
@hookie.should_receive(:changes).once.and_return(["something"])
|
32
|
+
@hookie.should_receive(:log).once
|
33
|
+
@plugin.should_run?.should be_false
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should run when there are no changes and config is correct" do
|
37
|
+
@config.should_receive(:keys).and_return(['hookie.fisheye.apikey','hookie.fisheye.url'])
|
38
|
+
@config.should_receive('[]').with('hookie.fisheye.apikey').and_return("ABC123")
|
39
|
+
@config.should_receive('[]').with('hookie.fisheye.url').and_return("http://localhost/test/%REPO%/")
|
40
|
+
plugin = Hookie::Plugin::FishEyePlugin.new @hookie
|
41
|
+
@hookie.should_receive(:changes).once.and_return(["something"])
|
42
|
+
@hookie.should_not_receive(:log)
|
43
|
+
plugin.should_run?.should be_true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "responds to success" do
|
48
|
+
# FIXME this neds to be better
|
49
|
+
@plugin.should_receive(:notify).and_return([])
|
50
|
+
@hookie.should_receive(:log).with(any_args)
|
51
|
+
@hookie.should_receive(:log).with(@plugin, /sent/)
|
52
|
+
@plugin.post_receive
|
53
|
+
end
|
54
|
+
|
55
|
+
it "responds to failure" do
|
56
|
+
@plugin.should_receive(:notify).and_return({code: 401, message: "ERROR"})
|
57
|
+
@hookie.should_receive(:log).with(any_args)
|
58
|
+
@hookie.should_receive(:log).with(@plugin, /ERROR/)
|
59
|
+
@plugin.post_receive
|
60
|
+
end
|
61
|
+
|
62
|
+
it "responds to an unknown response" do
|
63
|
+
@plugin.should_receive(:notify).and_return({foo: 'bar'})
|
64
|
+
@hookie.should_receive(:log).with(any_args)
|
65
|
+
@hookie.should_receive(:log).with(@plugin, /unknown/i)
|
66
|
+
@plugin.post_receive
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/spec/framework_spec.rb
CHANGED
@@ -13,6 +13,16 @@ describe Hookie do
|
|
13
13
|
context 'initialisation' do
|
14
14
|
it "intialises" do
|
15
15
|
hookie = Hookie::Framework.new "test_hook", Dir.getwd
|
16
|
+
hookie
|
17
|
+
end
|
18
|
+
|
19
|
+
it "can can use the hook static" do
|
20
|
+
@config.stub(:[])
|
21
|
+
begin
|
22
|
+
Hookie::Framework.hook "foo"
|
23
|
+
rescue SystemExit => e
|
24
|
+
e.status.should be 255
|
25
|
+
end
|
16
26
|
end
|
17
27
|
|
18
28
|
it "reads changes" do
|
@@ -29,9 +39,58 @@ describe Hookie do
|
|
29
39
|
change[:ref].should eq "refs/heads/master"
|
30
40
|
|
31
41
|
change[:commit].should be commit
|
42
|
+
|
43
|
+
change2 = hookie.changes[1]
|
44
|
+
change2[:old_hash].should eq "0000000000000000000000000000000000000000"
|
45
|
+
change2[:new_hash].should eq "09e6a76d20ae8c8e1d40ce21b6ea586ff860e5d3"
|
46
|
+
change2[:ref].should eq "refs/heads/develop"
|
32
47
|
end
|
33
48
|
end
|
34
49
|
|
50
|
+
context "runner" do
|
51
|
+
before(:each) do
|
52
|
+
@config.stub(:keys).and_return([])
|
53
|
+
@hookie = Hookie::Framework.new "test_hook", Dir.getwd
|
54
|
+
end
|
55
|
+
|
56
|
+
it "exits if no allowed plugins set" do
|
57
|
+
@config.stub(:[]).with("hookie.core.allowedplugins").and_return(nil)
|
58
|
+
begin
|
59
|
+
@hookie.run_plugins("test")
|
60
|
+
rescue SystemExit => e
|
61
|
+
e.status.should be 255
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
module Hookie
|
66
|
+
module Plugin
|
67
|
+
class TestPlugin < BasePlugin
|
68
|
+
def test
|
69
|
+
log "ran test"
|
70
|
+
end
|
71
|
+
def errors
|
72
|
+
raise "Fudge"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it "runs a plugin" do
|
79
|
+
@config.stub(:keys).and_return(["hookie.core.allowedplugins"])
|
80
|
+
@config.stub(:[]).with("hookie.core.allowedplugins").and_return(["test"])
|
81
|
+
@hookie.should_receive(:log).with(anything, "ran test")
|
82
|
+
@hookie.run_plugins("test")
|
83
|
+
end
|
84
|
+
|
85
|
+
it "handles plugin failure" do
|
86
|
+
@config.stub(:keys).and_return(["hookie.core.allowedplugins"])
|
87
|
+
@config.stub(:[]).with("hookie.core.allowedplugins").and_return(["test"])
|
88
|
+
@hookie.should_receive(:log).with(anything, /exception/i)
|
89
|
+
@hookie.run_plugins("errors")
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
35
94
|
context "helpers" do
|
36
95
|
before(:each) do
|
37
96
|
@hookie = Hookie::Framework.new "test_hook", Dir.getwd
|
@@ -62,5 +121,53 @@ describe Hookie do
|
|
62
121
|
commit.stub(:id).and_return("ABC")
|
63
122
|
@hookie.commit_url(commit).should eq "TEST testrepo TEST ABC"
|
64
123
|
end
|
124
|
+
|
125
|
+
it "correctly gets the name of a bare repo" do
|
126
|
+
@repo.stub(:bare).and_return(true)
|
127
|
+
@repo.stub(:path).and_return("/foo/bar/baz.git")
|
128
|
+
@config.stub(:[]).with('hookie.core.repo.name').and_return(nil)
|
129
|
+
@hookie.repo_name.should eq "baz"
|
130
|
+
end
|
131
|
+
|
132
|
+
it "correctly gets the name of a non-bare repo" do
|
133
|
+
@repo.stub(:bare).and_return(false)
|
134
|
+
@repo.stub(:path).and_return("/foo/bar/baz/.git")
|
135
|
+
@config.stub(:[]).with('hookie.core.repo.name').and_return(nil)
|
136
|
+
@hookie.repo_name.should eq "baz"
|
137
|
+
end
|
138
|
+
|
139
|
+
it "collects heads" do
|
140
|
+
def head_helper(name, commit_id)
|
141
|
+
head = double("Grit::Head")
|
142
|
+
head.stub(:name).and_return(name)
|
143
|
+
commit = double("Grit::Commit")
|
144
|
+
commit.stub(:id).and_return(commit_id)
|
145
|
+
head.stub(:commit).and_return(commit)
|
146
|
+
head
|
147
|
+
end
|
148
|
+
heads = [
|
149
|
+
head_helper("one", "1"),
|
150
|
+
head_helper("two", "2"),
|
151
|
+
head_helper("three", "2")
|
152
|
+
]
|
153
|
+
|
154
|
+
@repo.stub(:heads).with(any_args).and_return(heads)
|
155
|
+
commit = double("Grit::Commit")
|
156
|
+
commit.stub(:id).and_return("1")
|
157
|
+
@hookie.head_names_for_commit(commit).should have(1).items
|
158
|
+
end
|
159
|
+
|
160
|
+
it "logs stuff" do
|
161
|
+
class TestPlugin
|
162
|
+
def to_s
|
163
|
+
"Test"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
plugin = TestPlugin.new
|
167
|
+
Time.stub(:now).and_return(Time.parse("01/04/2013 09:00:00"))
|
168
|
+
@hookie.should_receive(:puts).with("[2013-04-01 09:00:00] Test: test")
|
169
|
+
@hookie.log(plugin, "test")
|
170
|
+
end
|
171
|
+
|
65
172
|
end
|
66
173
|
end
|
data/spec/hipchat_plugin_spec.rb
CHANGED
@@ -11,12 +11,17 @@ describe Hookie::Plugin::HipChatPlugin do
|
|
11
11
|
@hookie.stub(:config).and_return(@config)
|
12
12
|
@hookie.stub(:log)
|
13
13
|
end
|
14
|
+
|
14
15
|
context "HipChat plugin" do
|
15
16
|
before :each do
|
16
17
|
@plugin = Hookie::Plugin::HipChatPlugin.new @hookie
|
17
18
|
end
|
18
19
|
|
19
20
|
context "config" do
|
21
|
+
it "identifies itself" do
|
22
|
+
@plugin.to_s.should eq "HipChat Notifier"
|
23
|
+
end
|
24
|
+
|
20
25
|
it "shouldn't run only when there are no changes" do
|
21
26
|
@hookie.should_receive(:changes).once.and_return([])
|
22
27
|
@plugin.should_run?.should be_false
|
@@ -39,13 +44,76 @@ describe Hookie::Plugin::HipChatPlugin do
|
|
39
44
|
end
|
40
45
|
end
|
41
46
|
|
42
|
-
it "
|
47
|
+
it "responds to success" do
|
43
48
|
# FIXME this neds to be better
|
44
49
|
@plugin.stub(:format_message).and_return("message")
|
45
|
-
@plugin.should_receive(:speak).with("message").and_return({
|
46
|
-
@hookie.should_receive(:log).
|
50
|
+
@plugin.should_receive(:speak).with("message").and_return({:status => "sent"})
|
51
|
+
@hookie.should_receive(:log).with(any_args)
|
52
|
+
@hookie.should_receive(:log).with(@plugin, /sent/)
|
53
|
+
@plugin.post_receive
|
54
|
+
end
|
55
|
+
|
56
|
+
it "responds to failure" do
|
57
|
+
@plugin.stub(:format_message).and_return("message")
|
58
|
+
@plugin.should_receive(:speak).with("message").and_return({error: { message: "ERROR"}})
|
59
|
+
@hookie.should_receive(:log).with(any_args)
|
60
|
+
@hookie.should_receive(:log).with(@plugin, /ERROR/)
|
47
61
|
@plugin.post_receive
|
48
62
|
end
|
49
63
|
|
64
|
+
it "responds to an unknown response" do
|
65
|
+
@plugin.stub(:format_message).and_return("message")
|
66
|
+
@plugin.should_receive(:speak).with("message").and_return({})
|
67
|
+
@hookie.should_receive(:log).with(any_args)
|
68
|
+
@hookie.should_receive(:log).with(@plugin, /unknown/i)
|
69
|
+
@plugin.post_receive
|
70
|
+
end
|
71
|
+
|
72
|
+
context "message" do
|
73
|
+
def commit_stub(abbrev, author, message)
|
74
|
+
commit = double(Grit::Commit)
|
75
|
+
commit.stub(:id_abbrev).and_return(abbrev)
|
76
|
+
commit.stub(:author).and_return(author)
|
77
|
+
commit.stub(:short_message).and_return(message)
|
78
|
+
commit
|
79
|
+
end
|
80
|
+
|
81
|
+
before :each do
|
82
|
+
@hookie.stub(:repo_url).and_return(nil)
|
83
|
+
@hookie.stub(:repo_name).and_return("REPO")
|
84
|
+
@hookie.stub(:commit_url).and_return("")
|
85
|
+
@hookie.stub(:head_names_for_commit).and_return([])
|
86
|
+
end
|
87
|
+
|
88
|
+
it "properly formats a message for one change" do
|
89
|
+
change = {
|
90
|
+
commit: commit_stub("00000", "Author", "Message")
|
91
|
+
}
|
92
|
+
|
93
|
+
@hookie.stub(:changes).and_return([change])
|
94
|
+
expected_message = "Commits just pushed to REPO:<br/><a href=''>00000</a> Author: Message<br/>"
|
95
|
+
|
96
|
+
@plugin.should_receive(:speak).with(expected_message).and_return({status: "sent"})
|
97
|
+
@plugin.post_receive
|
98
|
+
end
|
99
|
+
|
100
|
+
it "properly formats a message for multiple changes" do
|
101
|
+
stub = commit_stub("00001", "Author2", "Message2")
|
102
|
+
change = [
|
103
|
+
{ commit: commit_stub("00000", "Author", "Message") },
|
104
|
+
{ commit: stub }
|
105
|
+
]
|
106
|
+
|
107
|
+
@hookie.stub(:head_names_for_commit).with(stub).and_return(["test"])
|
108
|
+
|
109
|
+
@hookie.stub(:changes).and_return(change)
|
110
|
+
expected_message = "Commits just pushed to REPO:<br/><a href=''>00000</a> Author: Message<br/><a href=''>00001</a> (test) Author2: Message2<br/>"
|
111
|
+
|
112
|
+
@plugin.should_receive(:speak).with(expected_message).and_return({status: "sent"})
|
113
|
+
@plugin.post_receive
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
50
118
|
end
|
51
119
|
end
|
data/spec/spec_helper.rb
CHANGED
data/travis.yml
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hookie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: grit
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 1.1.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 10.0.3
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 10.0.3
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: rspec
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,10 +75,26 @@ dependencies:
|
|
59
75
|
- - ~>
|
60
76
|
- !ruby/object:Gem::Version
|
61
77
|
version: 2.12.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: simplecov
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.4.0
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.4.0
|
62
94
|
description: ! "Hookie provides a way to write git hooks with ruby without too much
|
63
95
|
worrying about any of the plumbing required, you can easily write your own plugins
|
64
96
|
and focus on the core of your functionality. \n\n Hookie includes plugins for
|
65
|
-
Jenkins and HipChat."
|
97
|
+
Jenkins, FishEye, and HipChat."
|
66
98
|
email:
|
67
99
|
- marcins@webqem.com
|
68
100
|
executables:
|
@@ -71,6 +103,7 @@ extensions: []
|
|
71
103
|
extra_rdoc_files: []
|
72
104
|
files:
|
73
105
|
- .gitignore
|
106
|
+
- .travis.yml
|
74
107
|
- Gemfile
|
75
108
|
- LICENSE.txt
|
76
109
|
- README.md
|
@@ -81,13 +114,17 @@ files:
|
|
81
114
|
- lib/hookie/framework.rb
|
82
115
|
- lib/hookie/plugins/base_plugin.rb
|
83
116
|
- lib/hookie/plugins/empty_plugin.rb
|
117
|
+
- lib/hookie/plugins/fisheye_plugin.rb
|
84
118
|
- lib/hookie/plugins/hipchat_plugin.rb
|
85
119
|
- lib/hookie/plugins/jenkins_plugin.rb
|
120
|
+
- lib/hookie/version.rb
|
86
121
|
- spec/base_plugin_spec.rb
|
122
|
+
- spec/fisheye_plugin_spec.rb
|
87
123
|
- spec/framework_spec.rb
|
88
124
|
- spec/hipchat_plugin_spec.rb
|
89
125
|
- spec/jenkins_plugin_spec.rb
|
90
126
|
- spec/spec_helper.rb
|
127
|
+
- travis.yml
|
91
128
|
homepage: https://github.com/marcins/hookie
|
92
129
|
licenses: []
|
93
130
|
post_install_message:
|
@@ -108,12 +145,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
145
|
version: '0'
|
109
146
|
requirements: []
|
110
147
|
rubyforge_project:
|
111
|
-
rubygems_version: 1.8.
|
148
|
+
rubygems_version: 1.8.25
|
112
149
|
signing_key:
|
113
150
|
specification_version: 3
|
114
151
|
summary: Framework for writing gitolite/git hooks with Ruby
|
115
152
|
test_files:
|
116
153
|
- spec/base_plugin_spec.rb
|
154
|
+
- spec/fisheye_plugin_spec.rb
|
117
155
|
- spec/framework_spec.rb
|
118
156
|
- spec/hipchat_plugin_spec.rb
|
119
157
|
- spec/jenkins_plugin_spec.rb
|