pr-daikou 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/pr-daikou.rb +13 -6
- data/lib/pr-daikou/cli.rb +3 -1
- data/lib/pr-daikou/host/github.rb +11 -1
- data/lib/pr-daikou/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e0c76dd51e728fa960e9b8f21242638b6c5f5cf9f46489a1dd088ecec263f34
|
4
|
+
data.tar.gz: 857f2a0fbeb3242664b8d9cea8417fcab648862975b77b58fdd98cf93509ee52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4fd6ead491ae0626f91941187a9f6e5e4fadaf1622a3216781349ea3838659fa851af0e47553aebd6f470b358a8f0524c3045577037dd6ca2676ab7fb7a0c39
|
7
|
+
data.tar.gz: 7985e540a5992e51288a941918ae53244ffd4cdeda26dc2b8584d24e3953bd1f337d0bfbdbcf75b09b802893021e25cfe6004adad1914e56cbcc8f75781ca2a5
|
data/README.md
CHANGED
@@ -82,6 +82,7 @@ Usage: pr-daikou [options]
|
|
82
82
|
-m, --commit MESSAGE add git commit message, default: :robot: PR daikou
|
83
83
|
-b, --base BRANCH pull request base branch, default: master
|
84
84
|
-t, --topic BRANCH create new branch, default: ci/pr-daikou_[20170101123456.000]
|
85
|
+
-L, --labels LABELS add labels, which should be separated with comma, default: ""
|
85
86
|
```
|
86
87
|
|
87
88
|
## Contributing
|
data/lib/pr-daikou.rb
CHANGED
@@ -20,12 +20,19 @@ module PRDaikou
|
|
20
20
|
topic_branch(options[:topic], current_time),
|
21
21
|
options[:commit]
|
22
22
|
)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
pullrequest_number =
|
24
|
+
PRDaikou::Host::Github.create_pullrequest(
|
25
|
+
pullrequest_title(options[:title]),
|
26
|
+
pullrequest_description(options[:description]),
|
27
|
+
options[:base],
|
28
|
+
topic_branch(options[:topic], current_time)
|
29
|
+
)
|
30
|
+
unless options[:labels].empty?
|
31
|
+
PRDaikou::Host::Github.add_labels_to_pullrequest(
|
32
|
+
pullrequest_number,
|
33
|
+
options[:labels].split(',').map(&:strip)
|
34
|
+
)
|
35
|
+
end
|
29
36
|
|
30
37
|
true
|
31
38
|
end
|
data/lib/pr-daikou/cli.rb
CHANGED
@@ -17,7 +17,8 @@ module PRDaikou
|
|
17
17
|
email: 'pr_daikou@example.com',
|
18
18
|
name: 'pr_daikou',
|
19
19
|
base: 'master',
|
20
|
-
topic: 'ci/pr-daikou'
|
20
|
+
topic: 'ci/pr-daikou',
|
21
|
+
labels: ''
|
21
22
|
}
|
22
23
|
end
|
23
24
|
|
@@ -39,6 +40,7 @@ module PRDaikou
|
|
39
40
|
opt.on('-m', '--commit MESSAGE', "add git commit message, default: #{@options[:commit]}") {|v| @options[:commit] = v }
|
40
41
|
opt.on('-b', '--base BRANCH', "pull request base branch, default: #{@options[:base]}") {|v| @options[:base] = v }
|
41
42
|
opt.on('-t', '--topic BRANCH', "create new branch, default: #{@options[:topic]}_[20170101123456.000]") {|v| @options[:topic] = v }
|
43
|
+
opt.on('-L', '--labels LABELS', "add labels, which should be separated by comma, default: #{@options[:labels]}") {|v| @options[:labels] = v }
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
@@ -20,7 +20,17 @@ module PRDaikou
|
|
20
20
|
--data #{Shellwords.escape({title: title, body: description, head: new_branch, base: base_branch}.to_json)}
|
21
21
|
OPTIONS
|
22
22
|
|
23
|
-
`curl #{options} https://api.github.com/repos/#{repository_name}/pulls`
|
23
|
+
response = `curl #{options} https://api.github.com/repos/#{repository_name}/pulls`
|
24
|
+
JSON.parse(response)['number']
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_labels_to_pullrequest(pullrequest_number, labels)
|
28
|
+
options = <<~OPTIONS.strip
|
29
|
+
-X POST -H "Authorization: token #{ENV['GITHUB_ACCESS_TOKEN']}" \
|
30
|
+
--data #{Shellwords.escape(labels.to_json)}
|
31
|
+
OPTIONS
|
32
|
+
|
33
|
+
`curl #{options} https://api.github.com/repos/#{repository_name}/issues/#{pullrequest_number}/labels`
|
24
34
|
end
|
25
35
|
|
26
36
|
def repository_url
|
data/lib/pr-daikou/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pr-daikou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rvillage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|