github-hooker 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +7 -5
- data/README.md +90 -0
- data/github-hooker.gemspec +2 -2
- data/lib/github-hooker.rb +7 -1
- data/lib/github-hooker/version.rb +1 -1
- data/spec/github-hooker_spec.rb +2 -2
- metadata +14 -13
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
github-hooker (0.1.
|
5
|
-
|
4
|
+
github-hooker (0.1.1)
|
5
|
+
activesupport (~> 3.0)
|
6
6
|
rest-client (~> 1.6.7)
|
7
7
|
thor (~> 0.14.6)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
activesupport (3.2.1)
|
13
|
+
i18n (~> 0.6)
|
14
|
+
multi_json (~> 1.0)
|
15
15
|
addressable (2.2.6)
|
16
16
|
crack (0.3.1)
|
17
17
|
diff-lcs (1.1.3)
|
@@ -24,7 +24,9 @@ GEM
|
|
24
24
|
guard (>= 0.2.2)
|
25
25
|
guard-rspec (0.6.0)
|
26
26
|
guard (>= 0.10.0)
|
27
|
+
i18n (0.6.0)
|
27
28
|
mime-types (1.17.2)
|
29
|
+
multi_json (1.0.4)
|
28
30
|
rake (0.9.2.2)
|
29
31
|
rest-client (1.6.7)
|
30
32
|
mime-types (>= 1.16)
|
data/README.md
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# github-hooker
|
2
|
+
|
3
|
+
This is an internal gem at PlataformaTec (<http://plataformatec.com.br>).
|
4
|
+
|
5
|
+
We use it to create and delete hooks in our github repositories (like campfire notifications for push and pull_requests and CI integration with web push hooks).
|
6
|
+
|
7
|
+
## Configuration
|
8
|
+
|
9
|
+
First, create `~/.github-hooker.yml` with
|
10
|
+
|
11
|
+
```yml
|
12
|
+
user: github_username
|
13
|
+
password: github_password
|
14
|
+
campfire_token: campfire_api_token
|
15
|
+
```
|
16
|
+
|
17
|
+
### Why I need to write my password?
|
18
|
+
|
19
|
+
The hook API is only accessible by the v3 Github API. There's a Oauth2 authentication method, but in order to use that you would need to set up a new application with Github, and then collect the token by an http callback (that must be accessible on the web). For the sake of simplicity, we use the other way to authenticate (http auth basic).
|
20
|
+
|
21
|
+
Then you can use the command `github-hooker` to list, create web and campfire hooks or delete them. Other hooks are not yet implemented (pull requests are appreciated!).
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
The user specified MUST have administration rights for the repositories you want to set/delete hooks.
|
26
|
+
|
27
|
+
The available commands are:
|
28
|
+
|
29
|
+
```
|
30
|
+
$ github-hooker
|
31
|
+
Tasks:
|
32
|
+
github-hooker help [TASK] # Describe available tasks or one specific task
|
33
|
+
github-hooker list user/repo # List hooks in the given repository
|
34
|
+
github-hooker web user/repo events --url=URL # Add a web hook in the given repository. Events must be separated by commas.
|
35
|
+
github-hooker campfire user/repo events --room=ROOM --subdomain=SUBDOMAIN # Add a campfire hook in the given repository. Events must be separated by commas.
|
36
|
+
github-hooker delete user/repo hook_number # Delete the hook from the given repository
|
37
|
+
```
|
38
|
+
|
39
|
+
### List hooks
|
40
|
+
|
41
|
+
```
|
42
|
+
github-hooker list plataformatec/devise
|
43
|
+
```
|
44
|
+
|
45
|
+
### Create a new web hook
|
46
|
+
|
47
|
+
```
|
48
|
+
github-hooker web plataformatec/devise "pull_requests, push" --url=http://mycallback.com/callback
|
49
|
+
```
|
50
|
+
|
51
|
+
This creates a new web hook that calls the url specified by `--url`. The events that this hooks listens must be the third argument and they must be separeted by commas.
|
52
|
+
|
53
|
+
### Create a new campfire hook
|
54
|
+
|
55
|
+
```
|
56
|
+
github-hooker campfire plataformatec/devise pull_requests,push,issue_comment --room="My Room" --subdomain="My Subdomain"
|
57
|
+
```
|
58
|
+
|
59
|
+
Creates a new campfire hook. The token used for authentication with Campfire must be provided in your `~/.github-hooker.yml` (see Configuration above).
|
60
|
+
|
61
|
+
### Delete a hook
|
62
|
+
|
63
|
+
```
|
64
|
+
github-hooker delete plataformatec/devise 1010
|
65
|
+
```
|
66
|
+
|
67
|
+
Deletes the hook 1010 from the given repository. You can get the hook id from the url listed in `github-hooker list user/repo`.
|
68
|
+
|
69
|
+
## Events
|
70
|
+
|
71
|
+
The available events that github gives us are:
|
72
|
+
|
73
|
+
Campfire events:
|
74
|
+
|
75
|
+
- push
|
76
|
+
- pull_requests
|
77
|
+
- issues
|
78
|
+
|
79
|
+
Web events:
|
80
|
+
|
81
|
+
- push
|
82
|
+
- pull_requests
|
83
|
+
- issues
|
84
|
+
- issue_comment
|
85
|
+
|
86
|
+
Github's documentation about hooks (http://developer.github.com/v3/repos/hooks/ and https://api.github.com/hooks) does not have all these hooks listed, but they are working with us.
|
87
|
+
|
88
|
+
## License
|
89
|
+
|
90
|
+
MIT License. Copyright 2012 Plataforma Tecnologia. http://blog.plataformatec.com.br
|
data/github-hooker.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ["george@plataformatec.com.br"]
|
10
10
|
s.homepage = ""
|
11
11
|
s.summary = %q{ hook them all }
|
12
|
-
s.description = %q{
|
12
|
+
s.description = %q{ github-hooker creates and deletes hooks in your github repository }
|
13
13
|
|
14
14
|
s.rubyforge_project = "github-hooker"
|
15
15
|
|
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.add_dependency "rest-client", "~> 1.6.7"
|
22
22
|
s.add_dependency "thor", "~> 0.14.6"
|
23
|
-
s.add_dependency "
|
23
|
+
s.add_dependency "activesupport", "~> 3.0"
|
24
24
|
end
|
data/lib/github-hooker.rb
CHANGED
@@ -34,7 +34,13 @@ module Github
|
|
34
34
|
:user => config["user"],
|
35
35
|
:password => config["password"]
|
36
36
|
)
|
37
|
-
|
37
|
+
response = RestClient::Request.execute(options)
|
38
|
+
case response.code
|
39
|
+
when 201, 200
|
40
|
+
JSON.parse(response)
|
41
|
+
when 204, 404, 500
|
42
|
+
response
|
43
|
+
end
|
38
44
|
end
|
39
45
|
|
40
46
|
def self.config_filename
|
data/spec/github-hooker_spec.rb
CHANGED
@@ -39,7 +39,7 @@ describe Github::Hooker do
|
|
39
39
|
it "adds a new web hook in the given repo" do
|
40
40
|
WebMock.stub_request(:post, "https://user:password@api.github.com/repos/user/repo/hooks").
|
41
41
|
with(:body => "{\"active\":\"true\",\"name\":\"web\",\"events\":[\"pull_request\",\"issue\"],\"config\":{\"url\":\"http://example.com/callback\"}}").
|
42
|
-
to_return(:status =>
|
42
|
+
to_return(:status => 201, :body => "{}", :headers => {})
|
43
43
|
|
44
44
|
hook_options = {
|
45
45
|
:name => "web",
|
@@ -54,7 +54,7 @@ describe Github::Hooker do
|
|
54
54
|
|
55
55
|
it "deletes a hook in the given repo" do
|
56
56
|
WebMock.stub_request(:delete, "https://user:password@api.github.com/repos/user/repo/hooks/1010").
|
57
|
-
to_return(:status =>
|
57
|
+
to_return(:status => 204, :body => "", :headers => {})
|
58
58
|
|
59
59
|
subject.delete_hook("user/repo", 1010)
|
60
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-hooker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
16
|
-
requirement: &
|
16
|
+
requirement: &70291867146740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.6.7
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70291867146740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thor
|
27
|
-
requirement: &
|
27
|
+
requirement: &70291867146020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,19 +32,19 @@ dependencies:
|
|
32
32
|
version: 0.14.6
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70291867146020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: activesupport
|
38
|
+
requirement: &70291867145520 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 3.0
|
43
|
+
version: '3.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
-
description: ! '
|
46
|
+
version_requirements: *70291867145520
|
47
|
+
description: ! ' github-hooker creates and deletes hooks in your github repository '
|
48
48
|
email:
|
49
49
|
- george@plataformatec.com.br
|
50
50
|
executables:
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- Gemfile
|
58
58
|
- Gemfile.lock
|
59
59
|
- Guardfile
|
60
|
+
- README.md
|
60
61
|
- Rakefile
|
61
62
|
- bin/github-hooker
|
62
63
|
- github-hooker.gemspec
|
@@ -82,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
83
|
version: '0'
|
83
84
|
segments:
|
84
85
|
- 0
|
85
|
-
hash:
|
86
|
+
hash: 2168196875312501794
|
86
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
88
|
none: false
|
88
89
|
requirements:
|
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
92
|
version: '0'
|
92
93
|
segments:
|
93
94
|
- 0
|
94
|
-
hash:
|
95
|
+
hash: 2168196875312501794
|
95
96
|
requirements: []
|
96
97
|
rubyforge_project: github-hooker
|
97
98
|
rubygems_version: 1.8.11
|