ruboty-qiita-github 0.3.3 → 0.3.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 428947cc3bc45e068621e716700bfdd3794c4d5bea4e3953484c1fdda04d9c1f
4
- data.tar.gz: c5c4a90307f58c85f84b1d27cb087761a9cb195db61b361e006626ebe10cb13c
3
+ metadata.gz: 883d462281fcd9a4e984d543aa30a52ff3d826c2cadd5bfe0c09c7c8363532b6
4
+ data.tar.gz: 6d8d9f28e5e09744a29a6a1346be35c104ff885ff74ce6f21b4aec5b8e271eed
5
5
  SHA512:
6
- metadata.gz: b6290a0ec069f6adc266ddbfeb0a163f14c879174a9d025c02be06a939fc1fef750be03b59aaef7d5192481b6272f22e4fc3699de6f84df8f4904859e2fa64f1
7
- data.tar.gz: 0f8306a079bd04e0a92845f661d9ae2509d22a43a15dc8675f0e799579c20f3512d8295121641ef47418760aa70bd1d1de4eb19590dfbac284d93cc2e7e6425c
6
+ metadata.gz: a06ca29fccd9584d78ddcae8cf08f36556a78873a5106fd2a301ce0b90319547e958c632ecdabbb69147f5922b5d891fb489bd356c0ceb0f4bffc6df95eb65a0
7
+ data.tar.gz: 21ee13914d6b464d4f81cfb6858141cced3803613e28a0a1d6864a92d1fde42aadf8ac92c79bc54df5a848f9a914b40c87d20eddeb843a55b1ef31ece02e2123
@@ -0,0 +1,6 @@
1
+ # package-ecosystem: bundler, directories: /
2
+ /*.gemspec @increments/shared-dev-group
3
+ /Gemfile @increments/shared-dev-group
4
+
5
+ # package-ecosystem: github-actions, directories: /
6
+ /.github/workflows @increments/shared-dev-group
@@ -5,7 +5,11 @@ updates:
5
5
  directory: "/"
6
6
  schedule:
7
7
  interval: "weekly"
8
+ cooldown:
9
+ default-days: 7
8
10
  - package-ecosystem: "bundler"
9
11
  directory: "/"
10
12
  schedule:
11
13
  interval: "weekly"
14
+ cooldown:
15
+ default-days: 7
@@ -0,0 +1,22 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ release:
8
+ runs-on: ubuntu-latest
9
+
10
+ environment: release
11
+
12
+ permissions:
13
+ id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
14
+ contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
15
+
16
+ steps:
17
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18
+ - uses: ruby/setup-ruby@bb6434c747fa7022e12fa1cae2a0951fcffcff26 # v1.253.0
19
+ with:
20
+ ruby-version: "3.4"
21
+ bundler-cache: true
22
+ - uses: rubygems/release-gem@6317d8d1f7e28c24d28f6eff169ea854948bd9f7 # v1.2.0
@@ -15,12 +15,12 @@ jobs:
15
15
  strategy:
16
16
  fail-fast: false
17
17
  matrix:
18
- ruby: ["2.7", "3.0", "3.1"]
18
+ ruby: ["3.2", "3.3", "3.4"]
19
19
  runs-on: "ubuntu-latest"
20
20
  continue-on-error: false
21
21
  steps:
22
- - uses: actions/checkout@v4
23
- - uses: ruby/setup-ruby@v1
22
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
23
+ - uses: ruby/setup-ruby@9eb537ca036ebaed86729dcb9309076e4c5c3b74 # v1.314.0
24
24
  with:
25
25
  ruby-version: ${{ matrix.ruby }}
26
26
  bundler-cache: true
@@ -29,9 +29,24 @@ jobs:
29
29
  rubocop:
30
30
  runs-on: "ubuntu-latest"
31
31
  steps:
32
- - uses: actions/checkout@v4
33
- - uses: ruby/setup-ruby@v1
32
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
33
+ - uses: ruby/setup-ruby@9eb537ca036ebaed86729dcb9309076e4c5c3b74 # v1.314.0
34
34
  with:
35
- ruby-version: "3.1"
35
+ ruby-version: "3.2"
36
36
  bundler-cache: true
37
37
  - run: bundle exec rubocop
38
+
39
+ qlty:
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
43
+ - uses: ruby/setup-ruby@9eb537ca036ebaed86729dcb9309076e4c5c3b74 # v1.314.0
44
+ with:
45
+ ruby-version: '3.2'
46
+ bundler-cache: true
47
+ - name: Test
48
+ run: bundle exec rspec
49
+ - uses: qltysh/qlty-action/coverage@fd52dc852530a708d68c3b7342f8d33d1df4cd55 # v2.2.1
50
+ with:
51
+ token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
52
+ files: ./coverage/coverage.json
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 0.3.5
4
+ - Fix ISSUE_PATTERN to handle Slack app (Events API) URL formats
5
+ - Add GitHub Actions workflow for gem release via Trusted Publishing
6
+
7
+ ## 0.3.4
8
+ - Fix bug of v0.3.3
9
+
3
10
  ## 0.3.3
4
11
  - Bump actions/checkout from 3 to 4
5
12
  - Enable to change after merge custom message
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Ruboty::Github
2
- [![Gem Version](https://badge.fury.io/rb/ruboty-qiita-github.svg)](https://badge.fury.io/rb/ruboty-qiita-github) [![Test](https://github.com/increments/ruboty-qiita-github/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/increments/ruboty-qiita-github/actions/workflows/test.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/764bf9dc5796f0d3bef3/maintainability)](https://codeclimate.com/github/increments/ruboty-qiita-github/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/764bf9dc5796f0d3bef3/test_coverage)](https://codeclimate.com/github/increments/ruboty-qiita-github/test_coverage)
2
+ [![Gem Version](https://badge.fury.io/rb/ruboty-qiita-github.svg)](https://badge.fury.io/rb/ruboty-qiita-github)
3
+ [![Test](https://github.com/increments/ruboty-qiita-github/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/increments/ruboty-qiita-github/actions/workflows/test.yml)
4
+ [![Maintainability](https://qlty.sh/gh/increments/projects/ruboty-qiita-github/maintainability.svg)](https://qlty.sh/gh/increments/projects/ruboty-qiita-github)
5
+ [![Code Coverage](https://qlty.sh/gh/increments/projects/ruboty-qiita-github/coverage.svg)](https://qlty.sh/gh/increments/projects/ruboty-qiita-github)
3
6
 
4
7
  Manage GitHub via Ruboty.
5
8
  This gem adds `deploy pull request` command to original ruboty-github plugin.
@@ -21,7 +21,7 @@ module Ruboty
21
21
  custom_message = ENV.fetch('AFTER_MERGE_MESSAGE', nil)
22
22
  target_repository = ENV.fetch('AFTER_MERGE_MESSAGE_TARGET_REPOSITORY', '')
23
23
 
24
- return unless (repository == target_repository) && custom_message
24
+ return true unless (repository == target_repository) && custom_message
25
25
 
26
26
  message.reply(custom_message)
27
27
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ruboty
4
4
  module Github
5
- VERSION = '0.3.3'
5
+ VERSION = '0.3.5'
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@
3
3
  module Ruboty
4
4
  module Handlers
5
5
  class Github < Base
6
- ISSUE_PATTERN = %r{(?:https?://[^/]+/)?(?<repo>.+)(?:#|/pull/|/issues/)(?<number>\d+) ?}.freeze
6
+ ISSUE_PATTERN = %r{<?(?:https?://[^/]+/|[^/]+\.[^/]+/)?(?<repo>[^/]+/[^/]+)(?:#|/pull/|/issues/)(?<number>\d+)>? ?}.freeze
7
7
 
8
8
  env :GITHUB_BASE_URL, 'Pass GitHub URL if needed (e.g. https://github.example.com)', optional: true
9
9
 
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'rubocop-rake'
29
29
  spec.add_development_dependency 'rubocop-rspec'
30
30
  spec.add_development_dependency 'simplecov'
31
+ spec.add_development_dependency 'simplecov_json_formatter'
31
32
  spec.add_development_dependency 'webmock'
32
33
  spec.metadata['rubygems_mfa_required'] = 'true'
33
34
  end
@@ -81,7 +81,7 @@ describe Ruboty::Handlers::Github do
81
81
  %(ruboty create issue "#{title}" on #{user}/#{repository})
82
82
  end
83
83
 
84
- include_examples 'requires access token without access token'
84
+ it_behaves_like 'requires access token without access token'
85
85
 
86
86
  context 'with access token' do
87
87
  it 'creates a new issue with given title on given repository' do
@@ -115,7 +115,7 @@ describe Ruboty::Handlers::Github do
115
115
  %(ruboty search issues "#{query}")
116
116
  end
117
117
 
118
- include_examples 'requires access token without access token'
118
+ it_behaves_like 'requires access token without access token'
119
119
 
120
120
  context 'with access token' do
121
121
  it 'search an issue with given query' do
@@ -125,6 +125,55 @@ describe Ruboty::Handlers::Github do
125
125
  end
126
126
  end
127
127
 
128
+ describe 'ISSUE_PATTERN' do
129
+ subject(:match) { described_class::ISSUE_PATTERN.match(input) }
130
+
131
+ context 'with owner/repo#number format' do
132
+ let(:input) { 'alice/test#123' }
133
+
134
+ it 'extracts repo and number' do
135
+ expect(match[:repo]).to eq('alice/test')
136
+ expect(match[:number]).to eq('123')
137
+ end
138
+ end
139
+
140
+ context 'with full URL using /issues/' do
141
+ let(:input) { 'https://github.com/alice/test/issues/123' }
142
+
143
+ it 'extracts repo and number' do
144
+ expect(match[:repo]).to eq('alice/test')
145
+ expect(match[:number]).to eq('123')
146
+ end
147
+ end
148
+
149
+ context 'with full URL using /pull/' do
150
+ let(:input) { 'https://github.com/alice/test/pull/123' }
151
+
152
+ it 'extracts repo and number' do
153
+ expect(match[:repo]).to eq('alice/test')
154
+ expect(match[:number]).to eq('123')
155
+ end
156
+ end
157
+
158
+ context 'with protocol-stripped URL (Slack display text)' do
159
+ let(:input) { 'github.com/alice/test/pull/123' }
160
+
161
+ it 'extracts repo and number' do
162
+ expect(match[:repo]).to eq('alice/test')
163
+ expect(match[:number]).to eq('123')
164
+ end
165
+ end
166
+
167
+ context 'with angle-bracketed URL' do
168
+ let(:input) { '<https://github.com/alice/test/pull/123>' }
169
+
170
+ it 'extracts repo and number' do
171
+ expect(match[:repo]).to eq('alice/test')
172
+ expect(match[:number]).to eq('123')
173
+ end
174
+ end
175
+ end
176
+
128
177
  describe '#close_issue' do
129
178
  before do
130
179
  stub_request(:get, "https://api.github.com/repos/#{user}/#{repository}/issues/#{issue_number}")
@@ -169,7 +218,7 @@ describe Ruboty::Handlers::Github do
169
218
  1
170
219
  end
171
220
 
172
- include_examples 'requires access token without access token'
221
+ it_behaves_like 'requires access token without access token'
173
222
 
174
223
  context 'with closed issue' do
175
224
  it 'replies so' do
@@ -183,6 +232,39 @@ describe Ruboty::Handlers::Github do
183
232
  call
184
233
  end
185
234
  end
235
+
236
+ context 'with full URL format' do
237
+ let(:body) do
238
+ "@ruboty close https://github.com/#{user}/#{repository}/issues/#{issue_number}"
239
+ end
240
+
241
+ it 'closes specified issue' do
242
+ expect(robot).to receive(:say).with(hash_including(body: "Closed #{html_url}"))
243
+ call
244
+ end
245
+ end
246
+
247
+ context 'with protocol-stripped URL format (Slack display text)' do
248
+ let(:body) do
249
+ "@ruboty close github.com/#{user}/#{repository}/issues/#{issue_number}"
250
+ end
251
+
252
+ it 'closes specified issue' do
253
+ expect(robot).to receive(:say).with(hash_including(body: "Closed #{html_url}"))
254
+ call
255
+ end
256
+ end
257
+
258
+ context 'with angle-bracketed URL format' do
259
+ let(:body) do
260
+ "@ruboty close <https://github.com/#{user}/#{repository}/issues/#{issue_number}>"
261
+ end
262
+
263
+ it 'closes specified issue' do
264
+ expect(robot).to receive(:say).with(hash_including(body: "Closed #{html_url}"))
265
+ call
266
+ end
267
+ end
186
268
  end
187
269
 
188
270
  describe '#remember' do
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'simplecov'
4
- SimpleCov.start
4
+ require 'simplecov_json_formatter'
5
+
6
+ SimpleCov.start do
7
+ SimpleCov.formatters = [
8
+ SimpleCov::Formatter::JSONFormatter,
9
+ SimpleCov::Formatter::HTMLFormatter
10
+ ]
11
+
12
+ add_filter '/spec/'
13
+ end
5
14
 
6
15
  require 'ruboty/github'
7
16
  require 'webmock/rspec'
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-qiita-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
8
  - Seigo Uchida
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2023-12-20 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
@@ -165,6 +164,20 @@ dependencies:
165
164
  - - ">="
166
165
  - !ruby/object:Gem::Version
167
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov_json_formatter
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
168
181
  - !ruby/object:Gem::Dependency
169
182
  name: webmock
170
183
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +192,6 @@ dependencies:
179
192
  - - ">="
180
193
  - !ruby/object:Gem::Version
181
194
  version: '0'
182
- description:
183
195
  email:
184
196
  - r7kamura@gmail.com
185
197
  - spesnova@gmail.com
@@ -187,7 +199,9 @@ executables: []
187
199
  extensions: []
188
200
  extra_rdoc_files: []
189
201
  files:
202
+ - ".github/CODEOWNERS"
190
203
  - ".github/dependabot.yml"
204
+ - ".github/workflows/release.yml"
191
205
  - ".github/workflows/test.yml"
192
206
  - ".gitignore"
193
207
  - ".rubocop.yml"
@@ -217,7 +231,6 @@ licenses:
217
231
  - MIT
218
232
  metadata:
219
233
  rubygems_mfa_required: 'true'
220
- post_install_message:
221
234
  rdoc_options: []
222
235
  require_paths:
223
236
  - lib
@@ -232,8 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
245
  - !ruby/object:Gem::Version
233
246
  version: '0'
234
247
  requirements: []
235
- rubygems_version: 3.4.1
236
- signing_key:
248
+ rubygems_version: 3.6.9
237
249
  specification_version: 4
238
250
  summary: Manage GitHub via Ruboty.
239
251
  test_files: []