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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a828cfb269e3369109142bc49697240bb9695aee9b7c7d078a49162d5f37bfc
4
- data.tar.gz: d63c404811c00cab36fb9b23adaee885e31b0cf84312d129b126293118414ad3
3
+ metadata.gz: 2e0c76dd51e728fa960e9b8f21242638b6c5f5cf9f46489a1dd088ecec263f34
4
+ data.tar.gz: 857f2a0fbeb3242664b8d9cea8417fcab648862975b77b58fdd98cf93509ee52
5
5
  SHA512:
6
- metadata.gz: f01e9120952b6c4da84158b8f8d05b87617a486fed70c2d2d40d1c0679d41ca9ba5ddba67c69d57c1d97c42b8cc879127db803274362fae1aff72a247cf2b50b
7
- data.tar.gz: ccb734f0a70c1f48792f83855b0d62fb484f32d8933bc1026fd44a073a46e9d029240e84906066671d065c450b4caf14dd5a67edefc19ba36644f02d61373a63
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
@@ -20,12 +20,19 @@ module PRDaikou
20
20
  topic_branch(options[:topic], current_time),
21
21
  options[:commit]
22
22
  )
23
- PRDaikou::Host::Github.create_pullrequest(
24
- pullrequest_title(options[:title]),
25
- pullrequest_description(options[:description]),
26
- options[:base],
27
- topic_branch(options[:topic], current_time)
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module PRDaikou
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
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.1.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-06-01 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler