pr_comet 0.1.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +137 -108
- data/.dependabot/config.yml +18 -0
- data/.gem_comet.yml +15 -0
- data/.rubocop.yml +1 -1
- data/.rubocop_challenge.yml +3 -0
- data/.rubocop_todo.yml +25 -1
- data/CHANGELOG.md +93 -0
- data/Gemfile.lock +66 -55
- data/README.md +73 -5
- data/bin/release +7 -5
- data/lib/pr_comet.rb +52 -12
- data/lib/pr_comet/command_line.rb +2 -12
- data/lib/pr_comet/errors.rb +5 -1
- data/lib/pr_comet/github/client.rb +63 -1
- data/lib/pr_comet/rspec.rb +8 -0
- data/lib/pr_comet/rspec/stub.rb +13 -0
- data/lib/pr_comet/version.rb +1 -1
- data/pr_comet.gemspec +3 -2
- data/renovate.json +5 -0
- metadata +30 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2c18979cdb1bc3c50a7857c4a8e8bf9c06c56afab11da16fda57d163a83478b6
|
|
4
|
+
data.tar.gz: 2d4b3bf12b05fff708ebc295fd93245c07b7d4cd8362232af622e4eb1e5ff0b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f99d97208f8ba85fc29f16fa2f4b27f52608c7ad2887d39038d0ddc3f40887622ca9ece63555f8d620e239aa81f67020d460eac8dcf434b462753ecc548b4d9
|
|
7
|
+
data.tar.gz: 3cb935b033e6f0e9149fb07110d7176bc2195a5ec6c53e0dde9f5a3cd8419332d40a028fc70e3e6bd9466cfe746653839e83864fbcec3ea08930f46d0726c822
|
data/.circleci/config.yml
CHANGED
|
@@ -2,136 +2,88 @@
|
|
|
2
2
|
#
|
|
3
3
|
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
|
4
4
|
#
|
|
5
|
-
version: 2
|
|
5
|
+
version: 2.1
|
|
6
|
+
|
|
7
|
+
orbs:
|
|
8
|
+
ruby-orbs: sue445/ruby-orbs@1.6.1
|
|
9
|
+
code-climate: rvla/code-climate@0.0.2
|
|
6
10
|
|
|
7
11
|
references:
|
|
8
|
-
- &
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
|
|
14
|
-
chmod +x ./tmp/cc-test-reporter
|
|
15
|
-
- &restore_bundle_install_cache
|
|
16
|
-
restore_cache:
|
|
17
|
-
keys:
|
|
18
|
-
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
|
19
|
-
- v1-dependencies-
|
|
20
|
-
- &bundle_install
|
|
21
|
-
run:
|
|
22
|
-
name: Bundle Install
|
|
23
|
-
command: |
|
|
24
|
-
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
|
25
|
-
- &save_bundle_install_cache
|
|
26
|
-
save_cache:
|
|
27
|
-
paths:
|
|
28
|
-
- ./vendor/bundle
|
|
29
|
-
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
|
30
|
-
- &run_rspec
|
|
31
|
-
run:
|
|
32
|
-
name: Run Rspec
|
|
33
|
-
command: |
|
|
34
|
-
mkdir /tmp/test-results
|
|
35
|
-
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
|
36
|
-
./tmp/cc-test-reporter before-build
|
|
37
|
-
bundle exec rspec --format documentation \
|
|
38
|
-
--color \
|
|
39
|
-
--format RspecJunitFormatter \
|
|
40
|
-
--out /tmp/test-results/rspec.xml \
|
|
41
|
-
$TEST_FILES
|
|
42
|
-
./tmp/cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
|
|
12
|
+
- &ruby_version
|
|
13
|
+
ruby_version:
|
|
14
|
+
type: enum
|
|
15
|
+
enum: ['2.5', '2.6', '2.7', '3.0', 'latest']
|
|
16
|
+
default: '3.0'
|
|
43
17
|
|
|
44
|
-
|
|
18
|
+
executors:
|
|
19
|
+
default:
|
|
20
|
+
parameters:
|
|
21
|
+
<<: *ruby_version
|
|
22
|
+
docker:
|
|
23
|
+
- image: circleci/ruby:<< parameters.ruby_version >>
|
|
45
24
|
working_directory: ~/repo
|
|
25
|
+
|
|
26
|
+
commands:
|
|
27
|
+
run_rspec:
|
|
28
|
+
description: Run RSpec
|
|
46
29
|
steps:
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
30
|
+
- code-climate/install
|
|
31
|
+
- run:
|
|
32
|
+
name: Execute RSpec
|
|
33
|
+
command: |
|
|
34
|
+
mkdir /tmp/test-results
|
|
35
|
+
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
|
|
36
|
+
cc-test-reporter before-build
|
|
37
|
+
bundle exec rspec --format documentation \
|
|
38
|
+
--color \
|
|
39
|
+
--format RspecJunitFormatter \
|
|
40
|
+
--out /tmp/test-results/rspec.xml \
|
|
41
|
+
$TEST_FILES
|
|
42
|
+
- code-climate/format-coverage:
|
|
43
|
+
input-type: simplecov
|
|
44
|
+
prefix: $(readlink -f .)
|
|
45
|
+
coverage-file: coverage/.resultset.json
|
|
46
|
+
output: coverage/codeclimate.$CIRCLE_BUILD_NUM.json
|
|
47
|
+
- persist_to_workspace:
|
|
48
|
+
root: coverage
|
|
49
|
+
paths:
|
|
50
|
+
- codeclimate.*.json
|
|
53
51
|
- store_test_results:
|
|
54
52
|
path: /tmp/test-results
|
|
55
53
|
- store_artifacts:
|
|
56
54
|
path: /tmp/test-results
|
|
57
55
|
destination: test-results
|
|
58
|
-
|
|
59
|
-
name: Rake Build
|
|
60
|
-
command: |
|
|
61
|
-
bundle exec rake build
|
|
62
|
-
|
|
63
|
-
- &rubocop
|
|
64
|
-
working_directory: ~/repo
|
|
56
|
+
rubocop:
|
|
65
57
|
steps:
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
- &yardoc
|
|
73
|
-
working_directory: ~/repo
|
|
58
|
+
- run:
|
|
59
|
+
name: Run RuboCop
|
|
60
|
+
command: bundle exec rubocop
|
|
61
|
+
yardoc:
|
|
62
|
+
description: 'Generate YARDoc'
|
|
74
63
|
steps:
|
|
75
|
-
-
|
|
76
|
-
- *restore_bundle_install_cache
|
|
77
|
-
- *bundle_install
|
|
78
|
-
- *save_bundle_install_cache
|
|
79
|
-
- run: bundle exec yardoc -o ./yardoc
|
|
64
|
+
- run: bundle exec yardoc -o ./yardoc
|
|
80
65
|
- store_artifacts:
|
|
81
66
|
path: ./yardoc
|
|
82
67
|
destination: yardoc
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
<<: *build
|
|
89
|
-
build_on_ruby_2.5:
|
|
90
|
-
docker:
|
|
91
|
-
- image: circleci/ruby:2.5-node-browsers
|
|
92
|
-
<<: *build
|
|
93
|
-
build_on_ruby_2.6:
|
|
94
|
-
docker:
|
|
95
|
-
- image: circleci/ruby:2.6-node-browsers
|
|
96
|
-
<<: *build
|
|
97
|
-
build_on_ruby_latest:
|
|
98
|
-
docker:
|
|
99
|
-
- image: circleci/ruby:latest-node-browsers-legacy
|
|
100
|
-
<<: *build
|
|
101
|
-
rubocop:
|
|
102
|
-
docker:
|
|
103
|
-
- image: circleci/ruby:2.4-node-browsers
|
|
104
|
-
<<: *rubocop
|
|
105
|
-
yardoc:
|
|
106
|
-
docker:
|
|
107
|
-
- image: circleci/ruby:2.4-node-browsers
|
|
108
|
-
<<: *yardoc
|
|
109
|
-
|
|
68
|
+
rake_build:
|
|
69
|
+
steps:
|
|
70
|
+
- run:
|
|
71
|
+
name: Rake Build
|
|
72
|
+
command: bundle exec rake build
|
|
110
73
|
rubocop_challenge:
|
|
111
|
-
docker:
|
|
112
|
-
- image: circleci/ruby:2.4-node-browsers
|
|
113
|
-
working_directory: ~/repo
|
|
114
74
|
steps:
|
|
115
|
-
- checkout
|
|
116
75
|
- run:
|
|
117
76
|
name: Rubocop Challenge
|
|
118
77
|
command: |
|
|
119
78
|
gem install rubocop_challenger --pre
|
|
120
79
|
rubocop_challenger go --email=ryz310@gmail.com --name=ryz310
|
|
121
|
-
|
|
122
80
|
release:
|
|
123
|
-
|
|
124
|
-
- image: circleci/ruby:2.4-node-browsers
|
|
125
|
-
working_directory: ~/repo
|
|
81
|
+
description: Release to RubyGems.org
|
|
126
82
|
steps:
|
|
127
|
-
- checkout
|
|
128
|
-
- *restore_bundle_install_cache
|
|
129
|
-
- *bundle_install
|
|
130
|
-
- *save_bundle_install_cache
|
|
131
83
|
- run:
|
|
132
84
|
name: Create Rubygems Credentials
|
|
133
85
|
command: |
|
|
134
|
-
mkdir ~/.gem
|
|
86
|
+
mkdir ~/.gem || true
|
|
135
87
|
echo -e "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}" > ~/.gem/credentials
|
|
136
88
|
chmod 0600 ~/.gem/credentials
|
|
137
89
|
- run:
|
|
@@ -139,24 +91,101 @@ jobs:
|
|
|
139
91
|
command: |
|
|
140
92
|
git push --set-upstream origin ${CIRCLE_BRANCH}
|
|
141
93
|
bundle exec rake release --trace
|
|
94
|
+
setup:
|
|
95
|
+
description: Setup for Job Working
|
|
96
|
+
parameters:
|
|
97
|
+
<<: *ruby_version
|
|
98
|
+
steps:
|
|
99
|
+
- checkout
|
|
100
|
+
- run:
|
|
101
|
+
name: Install bundler v1.x for ruby 2.7
|
|
102
|
+
command: gem install bundler:1.17.3
|
|
103
|
+
- ruby-orbs/bundle-install:
|
|
104
|
+
cache_key_prefix: v1-dependencies-<< parameters.ruby_version >>
|
|
105
|
+
test_and_build:
|
|
106
|
+
description: Build the RubyGem
|
|
107
|
+
steps:
|
|
108
|
+
- run_rspec
|
|
109
|
+
- rake_build
|
|
110
|
+
|
|
111
|
+
jobs:
|
|
112
|
+
build:
|
|
113
|
+
parameters:
|
|
114
|
+
<<: *ruby_version
|
|
115
|
+
executor:
|
|
116
|
+
name: default
|
|
117
|
+
ruby_version: << parameters.ruby_version >>
|
|
118
|
+
steps:
|
|
119
|
+
- setup:
|
|
120
|
+
ruby_version: << parameters.ruby_version >>
|
|
121
|
+
- test_and_build
|
|
122
|
+
upload-coverage:
|
|
123
|
+
executor: default
|
|
124
|
+
steps:
|
|
125
|
+
- attach_workspace:
|
|
126
|
+
at: ~/repo
|
|
127
|
+
- code-climate/install
|
|
128
|
+
- code-climate/sum-coverage:
|
|
129
|
+
input: codeclimate.*.json
|
|
130
|
+
parts: 5
|
|
131
|
+
- code-climate/upload-coverage
|
|
132
|
+
rubocop:
|
|
133
|
+
executor: default
|
|
134
|
+
steps:
|
|
135
|
+
- setup
|
|
136
|
+
- rubocop
|
|
137
|
+
yardoc:
|
|
138
|
+
executor: default
|
|
139
|
+
steps:
|
|
140
|
+
- setup
|
|
141
|
+
- yardoc
|
|
142
|
+
rubocop_challenge:
|
|
143
|
+
executor: default
|
|
144
|
+
steps:
|
|
145
|
+
- checkout
|
|
146
|
+
- rubocop_challenge
|
|
147
|
+
release:
|
|
148
|
+
executor: default
|
|
149
|
+
steps:
|
|
150
|
+
- setup
|
|
151
|
+
- release
|
|
142
152
|
|
|
143
153
|
workflows:
|
|
144
154
|
version: 2
|
|
145
155
|
|
|
146
156
|
commit:
|
|
147
157
|
jobs:
|
|
148
|
-
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
-
|
|
158
|
+
- build:
|
|
159
|
+
name: build_on_ruby_2.5
|
|
160
|
+
ruby_version: '2.5'
|
|
161
|
+
- build:
|
|
162
|
+
name: build_on_ruby_2.6
|
|
163
|
+
ruby_version: '2.6'
|
|
164
|
+
- build:
|
|
165
|
+
name: build_on_ruby_2.7
|
|
166
|
+
ruby_version: '2.7'
|
|
167
|
+
- build:
|
|
168
|
+
name: build_on_ruby_3.0
|
|
169
|
+
ruby_version: '3.0'
|
|
170
|
+
- build:
|
|
171
|
+
name: build_on_ruby_latest
|
|
172
|
+
ruby_version: 'latest'
|
|
152
173
|
- rubocop
|
|
153
174
|
- yardoc
|
|
175
|
+
- upload-coverage:
|
|
176
|
+
requires:
|
|
177
|
+
- build_on_ruby_2.5
|
|
178
|
+
- build_on_ruby_2.6
|
|
179
|
+
- build_on_ruby_2.7
|
|
180
|
+
- build_on_ruby_3.0
|
|
181
|
+
- build_on_ruby_latest
|
|
154
182
|
- release:
|
|
155
183
|
context: RubyGems API Key
|
|
156
184
|
requires:
|
|
157
|
-
- build_on_ruby_2.4
|
|
158
185
|
- build_on_ruby_2.5
|
|
159
186
|
- build_on_ruby_2.6
|
|
187
|
+
- build_on_ruby_2.7
|
|
188
|
+
- build_on_ruby_3.0
|
|
160
189
|
- build_on_ruby_latest
|
|
161
190
|
- rubocop
|
|
162
191
|
filters:
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
update_configs:
|
|
3
|
+
- package_manager: "ruby:bundler"
|
|
4
|
+
directory: "/"
|
|
5
|
+
update_schedule: "live"
|
|
6
|
+
default_reviewers:
|
|
7
|
+
- "ryz310"
|
|
8
|
+
default_assignees:
|
|
9
|
+
- "ryz310"
|
|
10
|
+
default_labels:
|
|
11
|
+
- "dependabot"
|
|
12
|
+
automerged_updates:
|
|
13
|
+
- match:
|
|
14
|
+
dependency_type: "development"
|
|
15
|
+
update_type: "all"
|
|
16
|
+
- match:
|
|
17
|
+
dependency_type: "production"
|
|
18
|
+
update_type: "semver:patch"
|
data/.gem_comet.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# [Usage]
|
|
2
|
+
#
|
|
3
|
+
# $ gem install gem_comet
|
|
4
|
+
# $ gem_comet init
|
|
5
|
+
# $ gem_comet release {version number, like as "1.2.3"}
|
|
6
|
+
# $ gem_comet changelog
|
|
7
|
+
# $ gem_comet versions
|
|
8
|
+
|
|
9
|
+
version: 1.1
|
|
10
|
+
|
|
11
|
+
release:
|
|
12
|
+
base_branch: master
|
|
13
|
+
release_branch: production
|
|
14
|
+
version_file_path: lib/pr_comet/version.rb
|
|
15
|
+
changelog_file_path: CHANGELOG.md
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2020-12-25 23:31:12 UTC using RuboCop version 1.7.0.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 1
|
|
10
|
+
# Configuration parameters: Include.
|
|
11
|
+
# Include: **/*.gemspec
|
|
12
|
+
Gemspec/RequiredRubyVersion:
|
|
13
|
+
Exclude:
|
|
14
|
+
- 'pr_comet.gemspec'
|
|
15
|
+
|
|
16
|
+
# Offense count: 1
|
|
17
|
+
# Configuration parameters: AllowedMethods.
|
|
18
|
+
# AllowedMethods: enums
|
|
19
|
+
Lint/ConstantDefinitionInBlock:
|
|
20
|
+
Exclude:
|
|
21
|
+
- 'spec/pr_comet/command_line_spec.rb'
|
|
22
|
+
|
|
23
|
+
# Offense count: 1
|
|
24
|
+
RSpec/LeakyConstantDeclaration:
|
|
25
|
+
Exclude:
|
|
26
|
+
- 'spec/pr_comet/command_line_spec.rb'
|
|
27
|
+
|
|
28
|
+
# Offense count: 15
|
|
29
|
+
# Configuration parameters: AllowSubject.
|
|
30
|
+
RSpec/MultipleMemoizedHelpers:
|
|
31
|
+
Max: 9
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Change log
|
|
2
|
+
|
|
3
|
+
## v0.4.0 (Jan 04, 2021)
|
|
4
|
+
|
|
5
|
+
### Breaking Change
|
|
6
|
+
|
|
7
|
+
* [#176](https://github.com/ryz310/pr_comet/pull/176) End of support for Ruby 2.4 ([@ryz310](https://github.com/ryz310))
|
|
8
|
+
* [#210](https://github.com/ryz310/pr_comet/pull/210) Support ruby 3.0 ([@ryz310](https://github.com/ryz310))
|
|
9
|
+
|
|
10
|
+
### Rubocop Challenge
|
|
11
|
+
|
|
12
|
+
* [#127](https://github.com/ryz310/pr_comet/pull/127) Style/IfUnlessModifier-20200523233029 ([@ryz310](https://github.com/ryz310))
|
|
13
|
+
* [#129](https://github.com/ryz310/pr_comet/pull/129) Performance/StartWith-20200525233033 ([@ryz310](https://github.com/ryz310))
|
|
14
|
+
* [#204](https://github.com/ryz310/pr_comet/pull/204) Re-generate .rubocop_todo.yml with RuboCop v1.7.0 ([@ryz310](https://github.com/ryz310))
|
|
15
|
+
|
|
16
|
+
### Dependabot
|
|
17
|
+
|
|
18
|
+
* [#110](https://github.com/ryz310/pr_comet/pull/110) ryz310/dependabot/bundler/pry-byebug-3.9.0 ([@ryz310](https://github.com/ryz310))
|
|
19
|
+
* [#174](https://github.com/ryz310/pr_comet/pull/174) ryz310/dependabot/bundler/rspec-3.10.0 ([@ryz310](https://github.com/ryz310))
|
|
20
|
+
* [#198](https://github.com/ryz310/pr_comet/pull/198) ryz310/dependabot/bundler/rubocop-1.6.1 ([@ryz310](https://github.com/ryz310))
|
|
21
|
+
* [#201](https://github.com/ryz310/pr_comet/pull/201) ryz310/dependabot/bundler/rubocop-rspec-2.1.0 ([@ryz310](https://github.com/ryz310))
|
|
22
|
+
* [#202](https://github.com/ryz310/pr_comet/pull/202) ryz310/dependabot/bundler/rake-13.0.2 ([@ryz310](https://github.com/ryz310))
|
|
23
|
+
* [#205](https://github.com/ryz310/pr_comet/pull/205) ryz310/dependabot/bundler/yard-0.9.26 ([@ryz310](https://github.com/ryz310))
|
|
24
|
+
* [#206](https://github.com/ryz310/pr_comet/pull/206) ryz310/dependabot/bundler/octokit-4.20.0 ([@ryz310](https://github.com/ryz310))
|
|
25
|
+
* [#209](https://github.com/ryz310/pr_comet/pull/209) ryz310/dependabot/bundler/rubocop-performance-1.9.2 ([@ryz310](https://github.com/ryz310))
|
|
26
|
+
|
|
27
|
+
### Misc
|
|
28
|
+
|
|
29
|
+
* [#91](https://github.com/ryz310/pr_comet/pull/91) Update ruby-orbs orb to v1.6.0 ([@ryz310](https://github.com/ryz310))
|
|
30
|
+
* [#111](https://github.com/ryz310/pr_comet/pull/111) Edit dependabot configuration ([@ryz310](https://github.com/ryz310))
|
|
31
|
+
|
|
32
|
+
## v0.3.1 (Nov 02, 2019)
|
|
33
|
+
|
|
34
|
+
### Feature
|
|
35
|
+
|
|
36
|
+
* [#60](https://github.com/ryz310/pr_comet/pull/60) Stub pr comet ([@ryz310](https://github.com/ryz310))
|
|
37
|
+
|
|
38
|
+
### Rubocop Challenge
|
|
39
|
+
|
|
40
|
+
* [#37](https://github.com/ryz310/pr_comet/pull/37) Re-generate .rubocop_todo.yml with RuboCop v0.73.0 ([@ryz310](https://github.com/ryz310))
|
|
41
|
+
* [#38](https://github.com/ryz310/pr_comet/pull/38) Performance/RegexpMatch-20190729233036 ([@ryz310](https://github.com/ryz310))
|
|
42
|
+
* [#39](https://github.com/ryz310/pr_comet/pull/39) Re-generate .rubocop_todo.yml with RuboCop v0.74.0 ([@ryz310](https://github.com/ryz310))
|
|
43
|
+
* [#45](https://github.com/ryz310/pr_comet/pull/45) Re-generate .rubocop_todo.yml with RuboCop v0.75.0 ([@ryz310](https://github.com/ryz310))
|
|
44
|
+
* [#50](https://github.com/ryz310/pr_comet/pull/50) Re-generate .rubocop_todo.yml with RuboCop v0.75.1 ([@ryz310](https://github.com/ryz310))
|
|
45
|
+
* [#55](https://github.com/ryz310/pr_comet/pull/55) Re-generate .rubocop_todo.yml with RuboCop v0.76.0 ([@ryz310](https://github.com/ryz310))
|
|
46
|
+
|
|
47
|
+
### Misc
|
|
48
|
+
|
|
49
|
+
* [#44](https://github.com/ryz310/pr_comet/pull/44) Bump rubocop-rspec from 1.34.1 to 1.36.0 ([@ryz310](https://github.com/ryz310))
|
|
50
|
+
* [#40](https://github.com/ryz310/pr_comet/pull/40) ryz310/dependabot/bundler/simplecov-0.17.1 ([@ryz310](https://github.com/ryz310))
|
|
51
|
+
* [#43](https://github.com/ryz310/pr_comet/pull/43) ryz310/dependabot/bundler/rake-tw-13.0 ([@ryz310](https://github.com/ryz310))
|
|
52
|
+
* [#48](https://github.com/ryz310/pr_comet/pull/48) ryz310/dependabot/bundler/rspec-3.9.0 ([@ryz310](https://github.com/ryz310))
|
|
53
|
+
* [#47](https://github.com/ryz310/pr_comet/pull/47) ryz310/dependabot/bundler/rubocop-performance-1.5.0 ([@ryz310](https://github.com/ryz310))
|
|
54
|
+
* [#53](https://github.com/ryz310/pr_comet/pull/53) Configure Renovate ([@ryz310](https://github.com/ryz310))
|
|
55
|
+
* [#56](https://github.com/ryz310/pr_comet/pull/56) Update ruby-orbs orb to v1.4.4 ([@ryz310](https://github.com/ryz310))
|
|
56
|
+
* [#61](https://github.com/ryz310/pr_comet/pull/61) Install gem_comet :comet: ([@ryz310](https://github.com/ryz310))
|
|
57
|
+
|
|
58
|
+
## v0.3.0 (Jul 12, 2019)
|
|
59
|
+
|
|
60
|
+
### Feature
|
|
61
|
+
|
|
62
|
+
* [#34](https://github.com/ryz310/pr_comet/pull/34) Support blank PR creation ([@ryz310](https://github.com/ryz310))
|
|
63
|
+
|
|
64
|
+
## v0.2.1 (Jul 12, 2019)
|
|
65
|
+
|
|
66
|
+
### Misc
|
|
67
|
+
|
|
68
|
+
* [#28](https://github.com/ryz310/pr_comet/pull/28) Re-generate .rubocop_todo.yml with RuboCop v0.72.0 ([@ryz310](https://github.com/ryz310))
|
|
69
|
+
* [#29](https://github.com/ryz310/pr_comet/pull/29) Migrate cirecle ci config to v2.1 ([@ryz310](https://github.com/ryz310))
|
|
70
|
+
* [#30](https://github.com/ryz310/pr_comet/pull/30) Improvement of the test coverage ([@ryz310](https://github.com/ryz310))
|
|
71
|
+
|
|
72
|
+
## v0.2.0 (Jun 09, 2019)
|
|
73
|
+
|
|
74
|
+
### Feature
|
|
75
|
+
|
|
76
|
+
* [#16](https://github.com/ryz310/pr_comet/pull/16) Use rainbow gem ([@ryz310](https://github.com/ryz310))
|
|
77
|
+
* [#18](https://github.com/ryz310/pr_comet/pull/18) Support GitHub project ([@ryz310](https://github.com/ryz310))
|
|
78
|
+
|
|
79
|
+
### Misc
|
|
80
|
+
|
|
81
|
+
* [#5](https://github.com/ryz310/pr_comet/pull/5) Re-generate .rubocop_todo.yml with RuboCop v0.68.0 ([@ryz310](https://github.com/ryz310))
|
|
82
|
+
* [#12](https://github.com/ryz310/pr_comet/pull/12) Re-generate .rubocop_todo.yml with RuboCop v0.68.1 ([@ryz310](https://github.com/ryz310))
|
|
83
|
+
* [#13](https://github.com/ryz310/pr_comet/pull/13) Re-generate .rubocop_todo.yml with RuboCop v0.69.0 ([@ryz310](https://github.com/ryz310))
|
|
84
|
+
* [#15](https://github.com/ryz310/pr_comet/pull/15) Re-generate .rubocop_todo.yml with RuboCop v0.70.0 ([@ryz310](https://github.com/ryz310))
|
|
85
|
+
* [#17](https://github.com/ryz310/pr_comet/pull/17) Re-generate .rubocop_todo.yml with RuboCop v0.71.0 ([@ryz310](https://github.com/ryz310))
|
|
86
|
+
|
|
87
|
+
## v0.1.1 (Apr 08, 2019)
|
|
88
|
+
|
|
89
|
+
Fix bugs.
|
|
90
|
+
|
|
91
|
+
## v0.1.0 (Apr 08, 2019)
|
|
92
|
+
|
|
93
|
+
Initial release! :rocket:
|
data/Gemfile.lock
CHANGED
|
@@ -1,78 +1,89 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
pr_comet (0.
|
|
4
|
+
pr_comet (0.4.0)
|
|
5
5
|
octokit
|
|
6
|
+
rainbow
|
|
6
7
|
|
|
7
8
|
GEM
|
|
8
9
|
remote: https://rubygems.org/
|
|
9
10
|
specs:
|
|
10
|
-
addressable (2.
|
|
11
|
-
public_suffix (>= 2.0.2, <
|
|
12
|
-
ast (2.4.
|
|
13
|
-
byebug (11.
|
|
14
|
-
coderay (1.1.
|
|
15
|
-
diff-lcs (1.
|
|
16
|
-
docile (1.3.
|
|
17
|
-
faraday (
|
|
11
|
+
addressable (2.7.0)
|
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
|
13
|
+
ast (2.4.1)
|
|
14
|
+
byebug (11.1.3)
|
|
15
|
+
coderay (1.1.3)
|
|
16
|
+
diff-lcs (1.4.4)
|
|
17
|
+
docile (1.3.4)
|
|
18
|
+
faraday (1.3.0)
|
|
19
|
+
faraday-net_http (~> 1.0)
|
|
18
20
|
multipart-post (>= 1.2, < 3)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
ruby2_keywords
|
|
22
|
+
faraday-net_http (1.0.0)
|
|
23
|
+
json (2.5.1)
|
|
24
|
+
method_source (1.0.0)
|
|
25
|
+
multipart-post (2.1.1)
|
|
26
|
+
octokit (4.20.0)
|
|
27
|
+
faraday (>= 0.9)
|
|
24
28
|
sawyer (~> 0.8.0, >= 0.5.3)
|
|
25
|
-
parallel (1.
|
|
26
|
-
parser (
|
|
27
|
-
ast (~> 2.4.
|
|
28
|
-
pry (0.
|
|
29
|
-
coderay (~> 1.1
|
|
30
|
-
method_source (~>
|
|
31
|
-
pry-byebug (3.
|
|
29
|
+
parallel (1.20.1)
|
|
30
|
+
parser (3.0.0.0)
|
|
31
|
+
ast (~> 2.4.1)
|
|
32
|
+
pry (0.13.1)
|
|
33
|
+
coderay (~> 1.1)
|
|
34
|
+
method_source (~> 1.0)
|
|
35
|
+
pry-byebug (3.9.0)
|
|
32
36
|
byebug (~> 11.0)
|
|
33
|
-
pry (~> 0.
|
|
34
|
-
|
|
35
|
-
public_suffix (3.0.3)
|
|
37
|
+
pry (~> 0.13.0)
|
|
38
|
+
public_suffix (4.0.6)
|
|
36
39
|
rainbow (3.0.0)
|
|
37
|
-
rake (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
rspec-
|
|
42
|
-
|
|
43
|
-
rspec-
|
|
44
|
-
rspec-
|
|
40
|
+
rake (13.0.3)
|
|
41
|
+
regexp_parser (2.0.3)
|
|
42
|
+
rexml (3.2.4)
|
|
43
|
+
rspec (3.10.0)
|
|
44
|
+
rspec-core (~> 3.10.0)
|
|
45
|
+
rspec-expectations (~> 3.10.0)
|
|
46
|
+
rspec-mocks (~> 3.10.0)
|
|
47
|
+
rspec-core (3.10.1)
|
|
48
|
+
rspec-support (~> 3.10.0)
|
|
49
|
+
rspec-expectations (3.10.1)
|
|
45
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
46
|
-
rspec-support (~> 3.
|
|
47
|
-
rspec-mocks (3.
|
|
51
|
+
rspec-support (~> 3.10.0)
|
|
52
|
+
rspec-mocks (3.10.1)
|
|
48
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
49
|
-
rspec-support (~> 3.
|
|
50
|
-
rspec-support (3.
|
|
54
|
+
rspec-support (~> 3.10.0)
|
|
55
|
+
rspec-support (3.10.1)
|
|
51
56
|
rspec_junit_formatter (0.4.1)
|
|
52
57
|
rspec-core (>= 2, < 4, != 2.12.0)
|
|
53
|
-
rubocop (
|
|
54
|
-
jaro_winkler (~> 1.5.1)
|
|
58
|
+
rubocop (1.7.0)
|
|
55
59
|
parallel (~> 1.10)
|
|
56
|
-
parser (>= 2.
|
|
57
|
-
psych (>= 3.1.0)
|
|
60
|
+
parser (>= 2.7.1.5)
|
|
58
61
|
rainbow (>= 2.2.2, < 4.0)
|
|
62
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
63
|
+
rexml
|
|
64
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
|
59
65
|
ruby-progressbar (~> 1.7)
|
|
60
|
-
unicode-display_width (>= 1.4.0, <
|
|
61
|
-
rubocop-
|
|
62
|
-
|
|
63
|
-
rubocop-
|
|
64
|
-
rubocop (>= 0.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
67
|
+
rubocop-ast (1.4.0)
|
|
68
|
+
parser (>= 2.7.1.5)
|
|
69
|
+
rubocop-performance (1.9.2)
|
|
70
|
+
rubocop (>= 0.90.0, < 2.0)
|
|
71
|
+
rubocop-ast (>= 0.4.0)
|
|
72
|
+
rubocop-rspec (2.1.0)
|
|
73
|
+
rubocop (~> 1.0)
|
|
74
|
+
rubocop-ast (>= 1.1.0)
|
|
75
|
+
ruby-progressbar (1.11.0)
|
|
76
|
+
ruby2_keywords (0.0.2)
|
|
77
|
+
sawyer (0.8.2)
|
|
78
|
+
addressable (>= 2.3.5)
|
|
79
|
+
faraday (> 0.8, < 2.0)
|
|
80
|
+
simplecov (0.17.1)
|
|
70
81
|
docile (~> 1.1)
|
|
71
82
|
json (>= 1.8, < 3)
|
|
72
83
|
simplecov-html (~> 0.10.0)
|
|
73
84
|
simplecov-html (0.10.2)
|
|
74
|
-
unicode-display_width (1.
|
|
75
|
-
yard (0.9.
|
|
85
|
+
unicode-display_width (1.7.0)
|
|
86
|
+
yard (0.9.26)
|
|
76
87
|
|
|
77
88
|
PLATFORMS
|
|
78
89
|
ruby
|
|
@@ -81,14 +92,14 @@ DEPENDENCIES
|
|
|
81
92
|
bundler (~> 1.16)
|
|
82
93
|
pr_comet!
|
|
83
94
|
pry-byebug
|
|
84
|
-
rake (~>
|
|
95
|
+
rake (~> 13.0)
|
|
85
96
|
rspec
|
|
86
97
|
rspec_junit_formatter
|
|
87
98
|
rubocop
|
|
88
99
|
rubocop-performance
|
|
89
100
|
rubocop-rspec
|
|
90
|
-
simplecov
|
|
101
|
+
simplecov (= 0.17.1)
|
|
91
102
|
yard
|
|
92
103
|
|
|
93
104
|
BUNDLED WITH
|
|
94
|
-
1.
|
|
105
|
+
1.17.3
|
data/README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# PrComet
|
|
2
2
|
|
|
3
|
-
[](https://circleci.com/gh/ryz310/pr_comet) [](https://codeclimate.com/github/ryz310/pr_comet/maintainability) [](https://codeclimate.com/github/ryz310/pr_comet/test_coverage)
|
|
3
|
+
[](https://circleci.com/gh/ryz310/pr_comet) [](https://badge.fury.io/rb/pr_comet) [](https://codeclimate.com/github/ryz310/pr_comet/maintainability) [](https://codeclimate.com/github/ryz310/pr_comet/test_coverage)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
TODO: Delete this and the text above, and describe your gem
|
|
5
|
+
A helper library that makes it easy to create pull requests.
|
|
8
6
|
|
|
9
7
|
## Installation
|
|
10
8
|
|
|
@@ -24,7 +22,77 @@ Or install it yourself as:
|
|
|
24
22
|
|
|
25
23
|
## Usage
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
```ruby
|
|
26
|
+
# Initialize.
|
|
27
|
+
pr_comet = PrComet.new(base: 'master', branch: '{branch name}')
|
|
28
|
+
|
|
29
|
+
# Modify arbitrary files and commit into the block.
|
|
30
|
+
pr_comet.commit '{commit message}' do
|
|
31
|
+
file = File.read('path/to/file')
|
|
32
|
+
file.sub!('hoge', 'fuga')
|
|
33
|
+
File.write('path/to/file', file)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# You can also change files outer the block.
|
|
37
|
+
`bundle update`
|
|
38
|
+
pr_comet.commit '$ bundle update'
|
|
39
|
+
|
|
40
|
+
# Create a new pull request.
|
|
41
|
+
pr_comet.create!(
|
|
42
|
+
title: 'New pull request',
|
|
43
|
+
body: '{New pull request body}',
|
|
44
|
+
labels: ['label 1', 'label 2'] # optional
|
|
45
|
+
)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Rspec
|
|
49
|
+
|
|
50
|
+
### Testing
|
|
51
|
+
|
|
52
|
+
You can stub `PrComet` class for testing.
|
|
53
|
+
Add the following code to `spec/spec_helper`:
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
require 'pr_comet/rspec'
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Then you can use `#stub_pr_comet!`.
|
|
60
|
+
It makes `PrComet` class to stubbing and `PrComet.new` will return stubbed `PrComet` instance.
|
|
61
|
+
The stubbed `PrComet#commit` does not execute `$ git commit`, but it executes given block code.
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
def create_pr
|
|
65
|
+
pr_comet = PrComet.new(base: 'master', branch: 'any-branch') # stubbed.
|
|
66
|
+
pr_comet.commit 'Hello world.' do # stubbed.
|
|
67
|
+
File.write('path/to/file.txt', 'Hello world.') # not stubbed.
|
|
68
|
+
end
|
|
69
|
+
pr_comet.create!(title: 'New pull request') # stubbed.
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
stub_pr_comet!
|
|
73
|
+
allow(File).to receive(:write)
|
|
74
|
+
create_pr
|
|
75
|
+
expect(File).to have_received(:write).with('path/to/file.txt', 'Hello world.')
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
If you want to test about `PrComet`, you can use `#stub_pr_comet!` return value.
|
|
79
|
+
It returns any instance of `PrComet`.
|
|
80
|
+
|
|
81
|
+
```ruby
|
|
82
|
+
def create_pr
|
|
83
|
+
pr_comet = PrComet.new(base: 'master', branch: 'any-branch')
|
|
84
|
+
pr_comet.commit 'commit message' do
|
|
85
|
+
# ...
|
|
86
|
+
end
|
|
87
|
+
pr_comet.create!(title: 'New pull request')
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
pr_comet = stub_pr_comet!
|
|
91
|
+
create_pr
|
|
92
|
+
expect(PrComet).to have_received(:new).with(base: 'master', branch: 'any-branch')
|
|
93
|
+
expect(pr_comet).to have_received(:commit).with('commit message')
|
|
94
|
+
expect(pr_comet).to have_received(:create!).with(title: 'New pull request')
|
|
95
|
+
```
|
|
28
96
|
|
|
29
97
|
## Development
|
|
30
98
|
|
data/bin/release
CHANGED
|
@@ -8,14 +8,15 @@ require 'pr_comet'
|
|
|
8
8
|
|
|
9
9
|
VERSION_FORMAT = /\A\d+\.\d+\.\d+(\.(pre|beta|rc)\d?)?\z/.freeze
|
|
10
10
|
version = ARGV[0]
|
|
11
|
-
|
|
11
|
+
update_pr = PrComet.new(base: 'master', branch: "update/v#{version}")
|
|
12
|
+
release_pr = PrComet.new(base: 'production', branch: 'master')
|
|
12
13
|
|
|
13
14
|
# Verifying
|
|
14
15
|
abort 'usage: bin/release VERSION' if version.nil?
|
|
15
|
-
abort 'A version must be like a `1.2.3`' unless version
|
|
16
|
+
abort 'A version must be like a `1.2.3`' unless VERSION_FORMAT.match?(version)
|
|
16
17
|
|
|
17
18
|
# Modify a version file
|
|
18
|
-
|
|
19
|
+
update_pr.commit ':comet: Update version' do
|
|
19
20
|
File.write('lib/pr_comet/version.rb', <<~VERSION)
|
|
20
21
|
# frozen_string_literal: true
|
|
21
22
|
|
|
@@ -26,9 +27,10 @@ pr_comet.commit ':comet: Update version' do
|
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
# Bundle Update
|
|
29
|
-
|
|
30
|
+
update_pr.commit ':comet: Run $ bundle update' do
|
|
30
31
|
`bundle update`
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
# Create a pull request
|
|
34
|
-
|
|
35
|
+
update_pr.create!(title: "Update v#{version}", body: '')
|
|
36
|
+
release_pr.create!(title: "Release v#{version}", body: '', validate: false)
|
data/lib/pr_comet.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'English'
|
|
4
4
|
require 'octokit'
|
|
5
|
+
require 'rainbow'
|
|
5
6
|
require 'pr_comet/version'
|
|
6
7
|
require 'pr_comet/errors'
|
|
7
8
|
require 'pr_comet/command_line'
|
|
@@ -41,28 +42,67 @@ class PrComet
|
|
|
41
42
|
result
|
|
42
43
|
end
|
|
43
44
|
|
|
44
|
-
# Create a pull request
|
|
45
|
-
#
|
|
45
|
+
# Create a pull request. You should call #commit before calling this method.
|
|
46
|
+
# If you want to create a blank PR, you can do it with `validate: false`
|
|
47
|
+
# option.
|
|
46
48
|
#
|
|
47
|
-
# @param
|
|
48
|
-
#
|
|
49
|
-
# @
|
|
50
|
-
#
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
# @param options [Hash]
|
|
50
|
+
# Options for the PR creation.
|
|
51
|
+
# @option title [String]
|
|
52
|
+
# The title for the pull request
|
|
53
|
+
# @option body [String]
|
|
54
|
+
# The body for the pull request
|
|
55
|
+
# @option labels [Array<String>]
|
|
56
|
+
# List of labels. It is a optional parameter. You can add labels to the
|
|
57
|
+
# created PR.
|
|
58
|
+
# @option project_column_name [String]
|
|
59
|
+
# A project column name. It is a optional parameter. You can add the created
|
|
60
|
+
# PR to the GitHub project.
|
|
61
|
+
# @option project_id [Integer]
|
|
62
|
+
# A target project ID. It is a optional parameter. If does not supplied,
|
|
63
|
+
# this method will find a project which associated the repository.
|
|
64
|
+
# When the repository is associated with multiple projects, you should
|
|
65
|
+
# supply this.
|
|
66
|
+
# @option validate [Boolean]
|
|
67
|
+
# Verifies the branch has commits and checkout to the topic branch. If you
|
|
68
|
+
# want to create a blank PR, set "false" to this option. default: true.
|
|
69
|
+
# @return [Boolean]
|
|
70
|
+
# Return true if it is successed.
|
|
71
|
+
# rubocop:disable Metrics/AbcSize
|
|
72
|
+
def create!(**options)
|
|
73
|
+
options[:validate] = true if options[:validate].nil?
|
|
74
|
+
return false if options[:validate] && !git_condition_valid?
|
|
53
75
|
|
|
54
76
|
git.push(github_token_url, topic_branch)
|
|
55
|
-
pr_number = github.create_pull_request(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
77
|
+
pr_number = github.create_pull_request(**generate_create_pr_options(**options))
|
|
78
|
+
github.add_labels(pr_number, *options[:labels]) unless options[:labels].nil?
|
|
79
|
+
unless options[:project_column_name].nil?
|
|
80
|
+
github.add_to_project(pr_number, **generate_add_to_project_options(**options))
|
|
81
|
+
end
|
|
59
82
|
true
|
|
60
83
|
end
|
|
84
|
+
# rubocop:enable Metrics/AbcSize
|
|
61
85
|
|
|
62
86
|
private
|
|
63
87
|
|
|
64
88
|
attr_reader :git, :github, :base_branch, :topic_branch, :initial_sha1
|
|
65
89
|
|
|
90
|
+
def generate_create_pr_options(**options)
|
|
91
|
+
{
|
|
92
|
+
base: base_branch,
|
|
93
|
+
head: topic_branch,
|
|
94
|
+
title: options[:title],
|
|
95
|
+
body: options[:body]
|
|
96
|
+
}
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def generate_add_to_project_options(**options)
|
|
100
|
+
{
|
|
101
|
+
column_name: options[:project_column_name],
|
|
102
|
+
project_id: options[:project_id]
|
|
103
|
+
}
|
|
104
|
+
end
|
|
105
|
+
|
|
66
106
|
def git_condition_valid?
|
|
67
107
|
!git.current_sha1?(initial_sha1) && git.current_branch?(topic_branch)
|
|
68
108
|
end
|
|
@@ -12,19 +12,9 @@ class PrComet
|
|
|
12
12
|
def execute(command)
|
|
13
13
|
puts "$ #{command}"
|
|
14
14
|
`#{command}`.chomp.tap do |result|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
color = $CHILD_STATUS.success? ? :green : :red
|
|
16
|
+
puts Rainbow(result).color(color)
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
RED = 31
|
|
21
|
-
GREEN = 32
|
|
22
|
-
YELLOW = 33
|
|
23
|
-
BLUE = 34
|
|
24
|
-
PING = 35
|
|
25
|
-
|
|
26
|
-
def color_puts(string, color_code)
|
|
27
|
-
puts "\e[#{color_code}m#{string}\e[0m"
|
|
28
|
-
end
|
|
29
19
|
end
|
|
30
20
|
end
|
data/lib/pr_comet/errors.rb
CHANGED
|
@@ -18,25 +18,87 @@ class PrComet
|
|
|
18
18
|
# @param title [String] Title for the pull request
|
|
19
19
|
# @param body [String] The body for the pull request
|
|
20
20
|
# @return [Integer] Created pull request number
|
|
21
|
+
# @see http://octokit.github.io/octokit.rb/Octokit/Client/PullRequests.html#create_pull_request-instance_method
|
|
21
22
|
def create_pull_request(base:, head:, title:, body:)
|
|
22
23
|
response =
|
|
23
24
|
client.create_pull_request(repository, base, head, title, body)
|
|
24
25
|
response.number
|
|
25
26
|
end
|
|
26
27
|
|
|
27
|
-
#
|
|
28
|
+
# Add labels to the issue.
|
|
28
29
|
#
|
|
29
30
|
# @param issue_number [Integer] Number ID of the issue (or pull request)
|
|
30
31
|
# @param labels [Array<String>] An array of labels to apply to this Issue
|
|
32
|
+
# @see http://octokit.github.io/octokit.rb/Octokit/Client/Labels.html#add_labels_to_an_issue-instance_method
|
|
31
33
|
def add_labels(issue_number, *labels)
|
|
32
34
|
client.add_labels_to_an_issue(repository, issue_number, labels)
|
|
33
35
|
end
|
|
34
36
|
|
|
37
|
+
# Adds supplied issue (or pull request) to the GitHub project
|
|
38
|
+
#
|
|
39
|
+
# @param issue_number [Integer] Number ID of the issue (or pull request)
|
|
40
|
+
# @param column_name [String] A target column name
|
|
41
|
+
# @param project_id [Integer]
|
|
42
|
+
# A target project ID. It is a optional parameter. If does not supplied,
|
|
43
|
+
# this method will find a project which associated the repository.
|
|
44
|
+
# When the repository has multiple projects, you should supply this.
|
|
45
|
+
# @see http://octokit.github.io/octokit.rb/Octokit/Client/Projects.html#create_project_card-instance_method
|
|
46
|
+
def add_to_project(issue_number, column_name:, project_id: nil)
|
|
47
|
+
project_id ||= default_project_id
|
|
48
|
+
column_id = get_project_column_id(project_id, column_name)
|
|
49
|
+
issue_id = get_issue_id(issue_number)
|
|
50
|
+
client.create_project_card(
|
|
51
|
+
column_id,
|
|
52
|
+
content_id: issue_id,
|
|
53
|
+
content_type: 'PullRequest'
|
|
54
|
+
)
|
|
55
|
+
rescue Octokit::Error => e
|
|
56
|
+
raise "Failed to add a pull request to the project: #{e.message}"
|
|
57
|
+
end
|
|
58
|
+
|
|
35
59
|
private
|
|
36
60
|
|
|
37
61
|
REPOSITORY_MATCHER = %r{github\.com[:/](?<repository>.+)\.git}.freeze
|
|
38
62
|
|
|
39
63
|
attr_reader :client
|
|
64
|
+
|
|
65
|
+
# Returns a GitHub project column id which associated with supplied
|
|
66
|
+
# project ID and which matched with supplied column name. If does not
|
|
67
|
+
# found column, it returns nil.
|
|
68
|
+
#
|
|
69
|
+
# @param project_id [Integer] A target project ID
|
|
70
|
+
# @param column_name [String] A target column name
|
|
71
|
+
# @return [Integer, nil] Project column ID
|
|
72
|
+
def get_project_column_id(project_id, column_name)
|
|
73
|
+
find_project_columns(project_id).find { |c| c.name == column_name }.id
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Returns the issue (or pull request) ID
|
|
77
|
+
#
|
|
78
|
+
# @param issue_number [Integer] A target issue number
|
|
79
|
+
# @return [Integer] Issue ID
|
|
80
|
+
def get_issue_id(issue_number)
|
|
81
|
+
client.pull_request(repository, issue_number).id
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Finds a project id which associate with this repository.
|
|
85
|
+
# If found multiple projects it returns first one.
|
|
86
|
+
#
|
|
87
|
+
# @return [Integer] Project ID
|
|
88
|
+
# @raise [StandardError] Raises error when does not found a project.
|
|
89
|
+
# @see http://octokit.github.io/octokit.rb/Octokit/Client/Projects.html#projects-instance_method
|
|
90
|
+
def default_project_id
|
|
91
|
+
client.projects(repository).first.id
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Finds project columns with supplied project ID.
|
|
95
|
+
#
|
|
96
|
+
# @param project_id [Integer] A target project ID
|
|
97
|
+
# @return [Array<Sawyer::Resource>] List of project columns
|
|
98
|
+
# @see http://octokit.github.io/octokit.rb/Octokit/Client/Projects.html#project_columns-instance_method
|
|
99
|
+
def find_project_columns(project_id)
|
|
100
|
+
client.project_columns(project_id)
|
|
101
|
+
end
|
|
40
102
|
end
|
|
41
103
|
end
|
|
42
104
|
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class PrComet
|
|
4
|
+
# Test helper module for RSpec
|
|
5
|
+
module Stub
|
|
6
|
+
def stub_pr_comet!
|
|
7
|
+
instance_double(PrComet, create!: true).tap do |pr_comet|
|
|
8
|
+
allow(pr_comet).to receive(:commit) { |_message, &block| block&.call }
|
|
9
|
+
allow(PrComet).to receive(:new).and_return(pr_comet)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/pr_comet/version.rb
CHANGED
data/pr_comet.gemspec
CHANGED
|
@@ -23,15 +23,16 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.require_paths = ['lib']
|
|
24
24
|
|
|
25
25
|
spec.add_runtime_dependency 'octokit'
|
|
26
|
+
spec.add_runtime_dependency 'rainbow'
|
|
26
27
|
|
|
27
28
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
|
28
29
|
spec.add_development_dependency 'pry-byebug'
|
|
29
|
-
spec.add_development_dependency 'rake', '~>
|
|
30
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
30
31
|
spec.add_development_dependency 'rspec'
|
|
31
32
|
spec.add_development_dependency 'rspec_junit_formatter'
|
|
32
33
|
spec.add_development_dependency 'rubocop'
|
|
33
34
|
spec.add_development_dependency 'rubocop-performance'
|
|
34
35
|
spec.add_development_dependency 'rubocop-rspec'
|
|
35
|
-
spec.add_development_dependency 'simplecov'
|
|
36
|
+
spec.add_development_dependency 'simplecov', '0.17.1'
|
|
36
37
|
spec.add_development_dependency 'yard'
|
|
37
38
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pr_comet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ryz310
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-01-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: octokit
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rainbow
|
|
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'
|
|
27
41
|
- !ruby/object:Gem::Dependency
|
|
28
42
|
name: bundler
|
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,14 +72,14 @@ dependencies:
|
|
|
58
72
|
requirements:
|
|
59
73
|
- - "~>"
|
|
60
74
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
75
|
+
version: '13.0'
|
|
62
76
|
type: :development
|
|
63
77
|
prerelease: false
|
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
79
|
requirements:
|
|
66
80
|
- - "~>"
|
|
67
81
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
82
|
+
version: '13.0'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: rspec
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -140,16 +154,16 @@ dependencies:
|
|
|
140
154
|
name: simplecov
|
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
|
142
156
|
requirements:
|
|
143
|
-
- -
|
|
157
|
+
- - '='
|
|
144
158
|
- !ruby/object:Gem::Version
|
|
145
|
-
version:
|
|
159
|
+
version: 0.17.1
|
|
146
160
|
type: :development
|
|
147
161
|
prerelease: false
|
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
163
|
requirements:
|
|
150
|
-
- -
|
|
164
|
+
- - '='
|
|
151
165
|
- !ruby/object:Gem::Version
|
|
152
|
-
version:
|
|
166
|
+
version: 0.17.1
|
|
153
167
|
- !ruby/object:Gem::Dependency
|
|
154
168
|
name: yard
|
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -172,11 +186,15 @@ extensions: []
|
|
|
172
186
|
extra_rdoc_files: []
|
|
173
187
|
files:
|
|
174
188
|
- ".circleci/config.yml"
|
|
189
|
+
- ".dependabot/config.yml"
|
|
175
190
|
- ".envrc.skeleton"
|
|
191
|
+
- ".gem_comet.yml"
|
|
176
192
|
- ".gitignore"
|
|
177
193
|
- ".rspec"
|
|
178
194
|
- ".rubocop.yml"
|
|
195
|
+
- ".rubocop_challenge.yml"
|
|
179
196
|
- ".rubocop_todo.yml"
|
|
197
|
+
- CHANGELOG.md
|
|
180
198
|
- CODE_OF_CONDUCT.md
|
|
181
199
|
- Gemfile
|
|
182
200
|
- Gemfile.lock
|
|
@@ -191,8 +209,11 @@ files:
|
|
|
191
209
|
- lib/pr_comet/errors.rb
|
|
192
210
|
- lib/pr_comet/git/command.rb
|
|
193
211
|
- lib/pr_comet/github/client.rb
|
|
212
|
+
- lib/pr_comet/rspec.rb
|
|
213
|
+
- lib/pr_comet/rspec/stub.rb
|
|
194
214
|
- lib/pr_comet/version.rb
|
|
195
215
|
- pr_comet.gemspec
|
|
216
|
+
- renovate.json
|
|
196
217
|
homepage: https://github.com/ryz310/pr_comet
|
|
197
218
|
licenses:
|
|
198
219
|
- MIT
|
|
@@ -212,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
212
233
|
- !ruby/object:Gem::Version
|
|
213
234
|
version: '0'
|
|
214
235
|
requirements: []
|
|
215
|
-
rubygems_version: 3.
|
|
236
|
+
rubygems_version: 3.2.3
|
|
216
237
|
signing_key:
|
|
217
238
|
specification_version: 4
|
|
218
239
|
summary: Create a lots of pull request like comets
|