mothra 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 +17 -0
- data/.mothra.yml +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +69 -0
- data/Rakefile +2 -0
- data/bin/mothra +3 -0
- data/lib/mothra/cli.rb +153 -0
- data/lib/mothra/version.rb +3 -0
- data/lib/mothra.rb +6 -0
- data/mothra.gemspec +29 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d882ca3ec4237ce4af39b9c28f8c922b6be09962
|
4
|
+
data.tar.gz: 08c484888b69d285afa3172664c85259d184b0b9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 20c53291e674d4548d367ce19a90157567612f7dd7ef34ad3583db69623c30bd54499d814ecfa1f21ce288746d27694ce307f0bcb97b815879209ce9151407d8
|
7
|
+
data.tar.gz: 905afdd4df8e5f8fdabca7da37593e306896f3e52bf3cb0434aab321ef41028cba6d08d828ecf3fe45d63a2fe1961efe90e6a1e4326e97e182610d8dd9554ab5
|
data/.gitignore
ADDED
data/.mothra.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Jin-Sih Lin
|
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,69 @@
|
|
1
|
+
# Mothra
|
2
|
+
|
3
|
+
A FreeBSD send-pr command line tool for bugzilla system.
|
4
|
+
|
5
|
+
[https://bugs.freebsd.org/bugzilla/](https://bugs.freebsd.org/bugzilla/)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install mothra
|
10
|
+
|
11
|
+
## Add ~/.mothra.yml settings
|
12
|
+
$ curl https://raw.githubusercontent.com/pct/mothra/master/.mothra.yml > ~/.mothra.yml
|
13
|
+
|
14
|
+
or create manually:
|
15
|
+
|
16
|
+
# bugzilla base data
|
17
|
+
BZ_URL: https://bugs.freebsd.org/bugzilla/
|
18
|
+
BZ_USER: test@example.com
|
19
|
+
BZ_PASSWD: test
|
20
|
+
|
21
|
+
PRODUCT: Ports & Packages
|
22
|
+
COMPONENT: Individual Port(s)
|
23
|
+
STATUS: ['New', 'Open', 'In Progress', 'UNCONFIRMED']
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
Commands:
|
27
|
+
mothra attach <bug_id>, <file_path> # add attachment to <bug_id>
|
28
|
+
mothra create <summary> # set PR summary only, no attachments
|
29
|
+
mothra help [COMMAND] # Describe available commands or one specific command
|
30
|
+
mothra search <keyword>, <days_ago=180> # search keyword from bugzilla summary for last 180 days or you want
|
31
|
+
mothra submit <summary>, <file_path> # send-pr to bugs.freebsd.org
|
32
|
+
|
33
|
+
## Reference
|
34
|
+
1. [https://bugs.freebsd.org/bugzilla/](https://bugs.freebsd.org/bugzilla/)
|
35
|
+
2. [http://www.bugzilla.org/docs/4.4/en/html/api/Bugzilla/WebService/Server/JSONRPC.html](http://www.bugzilla.org/docs/4.4/en/html/api/Bugzilla/WebService/Server/JSONRPC.html)
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
Copyright (c) 2015 Jin-Sih Lin
|
40
|
+
|
41
|
+
MIT License
|
42
|
+
|
43
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
44
|
+
a copy of this software and associated documentation files (the
|
45
|
+
"Software"), to deal in the Software without restriction, including
|
46
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
47
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
48
|
+
permit persons to whom the Software is furnished to do so, subject to
|
49
|
+
the following conditions:
|
50
|
+
|
51
|
+
The above copyright notice and this permission notice shall be
|
52
|
+
included in all copies or substantial portions of the Software.
|
53
|
+
|
54
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
55
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
56
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
57
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
58
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
59
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
60
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
1. Fork it ( https://github.com/pct/mothra/fork )
|
65
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
66
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
67
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
68
|
+
5. Create a new Pull Request
|
69
|
+
|
data/Rakefile
ADDED
data/bin/mothra
ADDED
data/lib/mothra/cli.rb
ADDED
@@ -0,0 +1,153 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#require 'awesome_print'
|
4
|
+
require 'date'
|
5
|
+
require 'colorize'
|
6
|
+
require 'thor'
|
7
|
+
require 'rodzilla'
|
8
|
+
|
9
|
+
require 'base64'
|
10
|
+
require 'pathname'
|
11
|
+
|
12
|
+
def get_file_name(file_path)
|
13
|
+
Pathname.new(file_path).basename
|
14
|
+
end
|
15
|
+
|
16
|
+
def base64(file_path)
|
17
|
+
Base64.encode64(IO.read(file_path))
|
18
|
+
end
|
19
|
+
|
20
|
+
def check_config
|
21
|
+
config_file = "#{Dir.home}/.mothra.yml"
|
22
|
+
|
23
|
+
if not File.exist?(config_file)
|
24
|
+
puts 'You should set ~/.mothra.yml first!'.yellow
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
check_config
|
30
|
+
|
31
|
+
class CLI < Thor
|
32
|
+
def initialize(*args)
|
33
|
+
super
|
34
|
+
@config = YAML.load_file "#{Dir.home}/.mothra.yml"
|
35
|
+
@bz = Rodzilla::Resource::Bug.new(@config['BZ_URL'], @config['BZ_USER'], @config['BZ_PASSWD'], :json)
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'search <keyword>, <days_ago=180>', 'search keyword from bugzilla summary for last 180 days or you want'
|
39
|
+
def search(keyword, days_ago=180)
|
40
|
+
search_days = DateTime.now - days_ago.to_i
|
41
|
+
results = @bz.search(product: @config['PRODUCT'],
|
42
|
+
component: @config['COMPONENT'],
|
43
|
+
creation_time: search_days,
|
44
|
+
status: @config['STATUS'],
|
45
|
+
summary: keyword
|
46
|
+
)
|
47
|
+
|
48
|
+
if not results['bugs'].empty?
|
49
|
+
results['bugs'].each_with_index do |r, i|
|
50
|
+
print "[#{r['id']}] ".yellow
|
51
|
+
print "[#{r['status']}] ".cyan
|
52
|
+
print "#{r['summary']} ".white
|
53
|
+
puts "[#{r['last_change_time']}] ".light_black
|
54
|
+
end
|
55
|
+
else
|
56
|
+
puts 'Not found.'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'create <summary>', 'set PR summary only, no attachments'
|
61
|
+
def create(summary)
|
62
|
+
bug_id = _create(summary)
|
63
|
+
|
64
|
+
if not bug_id
|
65
|
+
puts 'Send-pr fail, please try again!'.yellow
|
66
|
+
else
|
67
|
+
print 'PR'
|
68
|
+
print " [#{bug_id}] ".yellow
|
69
|
+
puts "created!"
|
70
|
+
puts "#{@config['BZ_URL']}/show_bug.cgi?id=#{bug_id}".cyan
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
desc 'attach <bug_id>, <file_path>', 'add attachment to <bug_id>'
|
75
|
+
def attach(bug_id, file_path)
|
76
|
+
attach_id = _attach(bug_id, file_path)
|
77
|
+
|
78
|
+
if not attach_id
|
79
|
+
puts 'Fail to add attachments, please try again!'.yellow
|
80
|
+
else
|
81
|
+
print 'PR'
|
82
|
+
print " [#{bug_id}] ".cyan
|
83
|
+
print 'had add an attachment, '
|
84
|
+
puts " [#{attach_id}] ".yellow
|
85
|
+
puts "#{@config['BZ_URL']}/show_bug.cgi?id=#{bug_id}".cyan
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc 'submit <summary>, <file_path>', 'send-pr to bugs.freebsd.org'
|
90
|
+
def submit(summary, file_path)
|
91
|
+
bug_id = _create(summary)
|
92
|
+
|
93
|
+
if not bug_id
|
94
|
+
puts 'Send-pr fail, please try again!'.yellow
|
95
|
+
exit
|
96
|
+
end
|
97
|
+
|
98
|
+
attach_id = _attach(bug_id, file_path)
|
99
|
+
|
100
|
+
if not attach_id
|
101
|
+
puts 'Fail to add attachments, please upload attachment manually!'.yellow
|
102
|
+
else
|
103
|
+
print 'PR'
|
104
|
+
print " [#{bug_id}] ".cyan
|
105
|
+
print 'had add an attachment, '
|
106
|
+
puts " [#{attach_id}] ".yellow
|
107
|
+
end
|
108
|
+
puts "#{@config['BZ_URL']}/show_bug.cgi?id=#{bug_id}".cyan
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
|
113
|
+
def _create(summary)
|
114
|
+
begin
|
115
|
+
ret = @bz.create!(product: @config['PRODUCT'],
|
116
|
+
component: @config['COMPONENT'],
|
117
|
+
#version: '1.0', #bugzilla test
|
118
|
+
#op_sys: 'FreeBSD', #bugzilla test
|
119
|
+
#platform: 'All', #bugzilla test
|
120
|
+
version: 'Latest',
|
121
|
+
severity: 'Affects Only Me',
|
122
|
+
op_sys: 'Any',
|
123
|
+
platform: 'Any',
|
124
|
+
summary: summary
|
125
|
+
)
|
126
|
+
|
127
|
+
ret['id']
|
128
|
+
rescue
|
129
|
+
false
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def _attach(bug_id, file_path)
|
134
|
+
file_name = get_file_name(file_path)
|
135
|
+
file_base64 = base64(file_path)
|
136
|
+
|
137
|
+
begin
|
138
|
+
ret = @bz.add_attachment!(ids: [bug_id],
|
139
|
+
data: file_base64,
|
140
|
+
file_name: file_name,
|
141
|
+
summary: 'Just add an attachment.',
|
142
|
+
content_type: 'text/plain',
|
143
|
+
)
|
144
|
+
|
145
|
+
ret['ids'][0]
|
146
|
+
rescue
|
147
|
+
false
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
CLI.start(ARGV)
|
data/lib/mothra.rb
ADDED
data/mothra.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'mothra/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mothra"
|
8
|
+
spec.version = Mothra::VERSION
|
9
|
+
spec.authors = ["Jin-Sih Lin"]
|
10
|
+
spec.email = ["linpct@gmail.com"]
|
11
|
+
spec.summary = %q{Mothra, a FreeBSD send-pr tool for bugzilla}
|
12
|
+
spec.description = %q{Mothra, a FreeBSD send-pr tool for bugzilla}
|
13
|
+
spec.homepage = ""
|
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_dependency "thor"
|
22
|
+
spec.add_dependency "rodzilla"
|
23
|
+
spec.add_dependency "colorize"
|
24
|
+
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "awesome_print"
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mothra
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jin-Sih Lin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-05 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'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rodzilla
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
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: awesome_print
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
description: Mothra, a FreeBSD send-pr tool for bugzilla
|
112
|
+
email:
|
113
|
+
- linpct@gmail.com
|
114
|
+
executables:
|
115
|
+
- mothra
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".mothra.yml"
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/mothra
|
126
|
+
- lib/mothra.rb
|
127
|
+
- lib/mothra/cli.rb
|
128
|
+
- lib/mothra/version.rb
|
129
|
+
- mothra.gemspec
|
130
|
+
homepage: ''
|
131
|
+
licenses:
|
132
|
+
- MIT
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.2.2
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Mothra, a FreeBSD send-pr tool for bugzilla
|
154
|
+
test_files: []
|
155
|
+
has_rdoc:
|