mass-hooker 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +43 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +2 -0
- data/bin/hooker +6 -0
- data/hooker.gemspec +27 -0
- data/lib/hooker.rb +11 -0
- data/lib/hooker/cli.rb +81 -0
- data/lib/hooker/hooks.rb +41 -0
- data/lib/hooker/repos.rb +17 -0
- data/lib/hooker/version.rb +3 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16fce5dffec8973fe828d82e70d13f8579d7f419
|
4
|
+
data.tar.gz: 83feebd2478d5fe8fd187fd43a5f505372f8ef55
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f2dea31e2b2b046bca905f2e08b6b3d7c2024f299fbf56e1842a1664c02acb9cc219eb40daf267f733246da0b37268e99c4feb3ead09bc38fe30afa5731ac038
|
7
|
+
data.tar.gz: e875e742f0ad1adc6552a616899c2495d305d1ca36de6137ee86f7ccf152e5381fb55be4da90b7e19b7a2e7ea4fcfd4a5c83602766f0db4742181d2ff1f677db
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mass-hooker (0.0.1)
|
5
|
+
octokit (~> 3.0)
|
6
|
+
thor (~> 0.19)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.3.6)
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
faraday (0.9.0)
|
14
|
+
multipart-post (>= 1.2, < 3)
|
15
|
+
multipart-post (2.0.0)
|
16
|
+
octokit (3.1.0)
|
17
|
+
sawyer (~> 0.5.3)
|
18
|
+
rake (10.3.2)
|
19
|
+
rspec (3.0.0)
|
20
|
+
rspec-core (~> 3.0.0)
|
21
|
+
rspec-expectations (~> 3.0.0)
|
22
|
+
rspec-mocks (~> 3.0.0)
|
23
|
+
rspec-core (3.0.3)
|
24
|
+
rspec-support (~> 3.0.0)
|
25
|
+
rspec-expectations (3.0.3)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.0.0)
|
28
|
+
rspec-mocks (3.0.3)
|
29
|
+
rspec-support (~> 3.0.0)
|
30
|
+
rspec-support (3.0.3)
|
31
|
+
sawyer (0.5.4)
|
32
|
+
addressable (~> 2.3.5)
|
33
|
+
faraday (~> 0.8, < 0.10)
|
34
|
+
thor (0.19.1)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
bundler (~> 1.6)
|
41
|
+
mass-hooker!
|
42
|
+
rake
|
43
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Tomas Varaneckas
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Tomas Varaneckas
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Hooker
|
2
|
+
|
3
|
+
Command line tool to control GitHub repository web hooks in multiple repos in bulk.
|
4
|
+
|
5
|
+
### Installing
|
6
|
+
|
7
|
+
```console
|
8
|
+
$ gem install mass-hooker
|
9
|
+
```
|
10
|
+
|
11
|
+
### Before you run it
|
12
|
+
|
13
|
+
```console
|
14
|
+
$ export GITHUB_OAUTH_TOKEN=<your_token>
|
15
|
+
````
|
16
|
+
|
17
|
+
Your token must have `hooks_admin` permission.
|
18
|
+
|
19
|
+
## Examples
|
20
|
+
|
21
|
+
### Make sure all organization repos have a hook
|
22
|
+
|
23
|
+
```console
|
24
|
+
$ hooker ensure_hooks \
|
25
|
+
--org your_org \
|
26
|
+
--hook_url http://your.hook.handler/do/stuff \
|
27
|
+
--events pull_request,issues
|
28
|
+
```
|
29
|
+
|
30
|
+
### List all hooks in all organization private repos
|
31
|
+
|
32
|
+
```console
|
33
|
+
$ hooker hooks \
|
34
|
+
--org your_org \
|
35
|
+
--type private
|
36
|
+
```
|
37
|
+
|
38
|
+
### Getting more help
|
39
|
+
|
40
|
+
Run `hooker help` or `hooker help <command>`.
|
data/Rakefile
ADDED
data/bin/hooker
ADDED
data/hooker.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hooker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'mass-hooker'
|
8
|
+
spec.version = Hooker::VERSION
|
9
|
+
spec.authors = ['Tomas Varaneckas']
|
10
|
+
spec.email = ['tomas.varaneckas@gmail.com']
|
11
|
+
spec.summary = %q{Control GitHub repository hooks in multiple repos in bulk}
|
12
|
+
spec.description = %q{Command line tool to control GitHub repository hooks in multiple repos in bulk}
|
13
|
+
spec.homepage = 'https://github.com/spajus/hooker'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'thor', '~> 0.19'
|
22
|
+
spec.add_runtime_dependency 'octokit', '~> 3.0'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
end
|
data/lib/hooker.rb
ADDED
data/lib/hooker/cli.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'hooker/version'
|
3
|
+
require 'hooker/repos'
|
4
|
+
require 'hooker/hooks'
|
5
|
+
module Hooker
|
6
|
+
class CLI < Thor
|
7
|
+
|
8
|
+
desc 'version', 'Show Hooker version'
|
9
|
+
map %w(-v --version) => :version
|
10
|
+
def version
|
11
|
+
puts "Hooker version #{::Hooker::VERSION}"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'repos', 'List all repos'
|
15
|
+
option :user
|
16
|
+
option :org
|
17
|
+
option :type
|
18
|
+
def repos
|
19
|
+
puts ::Hooker::Repos.list(options).map(&:full_name).sort.join("\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'hooks', 'List hooks'
|
23
|
+
option :user
|
24
|
+
option :org
|
25
|
+
option :type
|
26
|
+
option :repo
|
27
|
+
def hooks
|
28
|
+
if repo = options[:repo]
|
29
|
+
print_hooks(repo)
|
30
|
+
else
|
31
|
+
repos = ::Hooker::Repos.list(options).map(&:full_name).sort
|
32
|
+
repos.each { |r| print_hooks(r) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'ensure_hooks', 'Updates or creates hook'
|
37
|
+
option :user
|
38
|
+
option :org
|
39
|
+
option :type
|
40
|
+
option :repo
|
41
|
+
option :hook_url
|
42
|
+
option :events
|
43
|
+
def ensure_hooks
|
44
|
+
hook_url = options[:hook_url]
|
45
|
+
events = options[:events]
|
46
|
+
if hook_url.nil? || events.nil?
|
47
|
+
puts 'Please provide --hook_url <url> and --events <comma,separated,events>'
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
events = events.split(',')
|
51
|
+
if events.empty?
|
52
|
+
puts 'Please provide --events <comma,separated,events>'
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
if repo = options[:repo]
|
56
|
+
ensure_hook(repo, hook_url, events)
|
57
|
+
else
|
58
|
+
repos = ::Hooker::Repos.list(options).map(&:full_name).sort
|
59
|
+
repos.each { |r| ensure_hook(r, hook_url, events) }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def ensure_hook(repo, hook_url, events)
|
66
|
+
puts repo
|
67
|
+
puts ::Hooker::Hooks.ensure_exists(repo, hook_url, events, options)
|
68
|
+
puts "\n"
|
69
|
+
end
|
70
|
+
|
71
|
+
def print_hooks(repo)
|
72
|
+
puts "#{repo}\n"
|
73
|
+
hooks = ::Hooker::Hooks.list(repo)
|
74
|
+
longest_url_size = hooks.map { |h| h.config.url ? h.config.url.size : 0 }.max
|
75
|
+
hooks.each do |hook|
|
76
|
+
puts ::Hooker::Hooks.format_string(hook, longest_url_size)
|
77
|
+
end
|
78
|
+
puts '-' * 50
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/lib/hooker/hooks.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Hooker
|
2
|
+
module Hooks
|
3
|
+
extend self
|
4
|
+
def list(repo, options = {})
|
5
|
+
opts = {}
|
6
|
+
Hooker.client.hooks(repo, opts).select { |h| h.name == 'web' }
|
7
|
+
end
|
8
|
+
|
9
|
+
def ensure_exists(repo, hook_url, events, opts)
|
10
|
+
opts = {}
|
11
|
+
hooks = Hooker.client.hooks(repo, opts).select { |h| h.name == 'web' }
|
12
|
+
hook = hooks.select { |h| h.config.url == hook_url }.first
|
13
|
+
if hook
|
14
|
+
res = Hooker.client.edit_hook(repo, hook.id, 'web', {
|
15
|
+
url: hook_url,
|
16
|
+
content_type: 'json'
|
17
|
+
},
|
18
|
+
{
|
19
|
+
events: events,
|
20
|
+
active: true
|
21
|
+
})
|
22
|
+
"updated: #{res.url}"
|
23
|
+
else
|
24
|
+
res = Hooker.client.create_hook(repo, 'web', {
|
25
|
+
url: hook_url,
|
26
|
+
content_type: 'json'
|
27
|
+
},
|
28
|
+
{
|
29
|
+
events: events,
|
30
|
+
active: true
|
31
|
+
})
|
32
|
+
"created: #{res.url}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def format_string(hook, longest_url_length)
|
37
|
+
url_format = "%-#{longest_url_length}s"
|
38
|
+
"#{'%-10d' % hook.id} | #{url_format % hook.config[:url]} | #{hook.events.join(',')}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/hooker/repos.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Hooker
|
2
|
+
module Repos
|
3
|
+
extend self
|
4
|
+
def list(options)
|
5
|
+
opts = {}
|
6
|
+
if options[:type]
|
7
|
+
opts[:type] = options[:type]
|
8
|
+
end
|
9
|
+
if options[:org]
|
10
|
+
Hooker.client.organization_repositories(options[:org], opts)
|
11
|
+
elsif options[:user]
|
12
|
+
Hooker.client.repositories(options[:user], opts)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mass-hooker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomas Varaneckas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.19'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.19'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: octokit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Command line tool to control GitHub repository hooks in multiple repos
|
84
|
+
in bulk
|
85
|
+
email:
|
86
|
+
- tomas.varaneckas@gmail.com
|
87
|
+
executables:
|
88
|
+
- hooker
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- .gitignore
|
93
|
+
- Gemfile
|
94
|
+
- Gemfile.lock
|
95
|
+
- LICENSE
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/hooker
|
100
|
+
- hooker.gemspec
|
101
|
+
- lib/hooker.rb
|
102
|
+
- lib/hooker/cli.rb
|
103
|
+
- lib/hooker/hooks.rb
|
104
|
+
- lib/hooker/repos.rb
|
105
|
+
- lib/hooker/version.rb
|
106
|
+
homepage: https://github.com/spajus/hooker
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.2.2
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Control GitHub repository hooks in multiple repos in bulk
|
130
|
+
test_files: []
|