danger-regexp 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer/.gitignore +1 -0
- data/.devcontainer/Dockerfile +22 -0
- data/.devcontainer/app.env.example +1 -0
- data/.devcontainer/devcontainer.json +10 -0
- data/.devcontainer/docker-compose.yml +18 -0
- data/.github/workflows/publish.yml +17 -0
- data/.github/workflows/test.yml +21 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +113 -0
- data/README.md +11 -7
- data/danger-regexp.gemspec +5 -5
- data/lib/danger/regexp/version.rb +1 -1
- data/lib/danger_plugin.rb +27 -7
- metadata +31 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9f7dc7e2b183a72f4798e7c6fd5bf8b1f87d7ea5f53d8dc205cc89912c207ac
|
4
|
+
data.tar.gz: 3e3318da2e098ff341a3e3956480c6694707c77a57c45e25741edc5cdd53ed48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18e3e3d615dd520d6ea81c81425a1f02fbd0a255908751ff9f929ebeb27174f73e1b34690961ee29922af9ed8e09bff2fc1024ce8426a3288b1fc69f6a66bfa5
|
7
|
+
data.tar.gz: e25c43249d26c57abcf50de63dd6f8b0bec799316a1d44bb72ffec98e542cbe397a7a37b551126fbe9818367f22887ad9579a7d776a2dff181d8d05da08d33cc
|
@@ -0,0 +1 @@
|
|
1
|
+
*.env
|
@@ -0,0 +1,22 @@
|
|
1
|
+
FROM ruby:3.0.2
|
2
|
+
|
3
|
+
ARG USERNAME=app
|
4
|
+
ARG USER_UID=1000
|
5
|
+
ARG USER_GID=$USER_UID
|
6
|
+
|
7
|
+
RUN groupadd --gid $USER_GID $USERNAME \
|
8
|
+
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
|
9
|
+
&& apt-get update \
|
10
|
+
&& apt-get install -y sudo \
|
11
|
+
&& echo "$USERNAME ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \
|
12
|
+
&& chmod 0440 /etc/sudoers.d/$USERNAME
|
13
|
+
|
14
|
+
ENV BUNDLE_PATH=/vendor/bundle
|
15
|
+
RUN mkdir -p /app $BUNDLE_PATH /home/$USERNAME/.config
|
16
|
+
RUN chown -R $USERNAME /app $BUNDLE_PATH /home
|
17
|
+
|
18
|
+
USER $USERNAME
|
19
|
+
|
20
|
+
ENV SHELL=/bin/bash
|
21
|
+
|
22
|
+
WORKDIR /app
|
@@ -0,0 +1 @@
|
|
1
|
+
#SHELL=/usr/bin/zsh
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{
|
2
|
+
"dockerComposeFile": "./docker-compose.yml",
|
3
|
+
"service": "app",
|
4
|
+
"workspaceFolder": "/app",
|
5
|
+
"initializeCommand": "cp -n .devcontainer/app.env.example .devcontainer/app.env",
|
6
|
+
"name": "${localWorkspaceFolderBasename}",
|
7
|
+
"extensions": [
|
8
|
+
"esbenp.prettier-vscode",
|
9
|
+
]
|
10
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
version: "3.8"
|
2
|
+
services:
|
3
|
+
app:
|
4
|
+
init: true
|
5
|
+
build:
|
6
|
+
context: .
|
7
|
+
command: sleep infinity
|
8
|
+
env_file:
|
9
|
+
- app.env
|
10
|
+
volumes:
|
11
|
+
- ..:/app:cached
|
12
|
+
- dotconfig:/home/app/.config
|
13
|
+
- vendor:/vendor
|
14
|
+
|
15
|
+
volumes:
|
16
|
+
app:
|
17
|
+
vendor:
|
18
|
+
dotconfig:
|
@@ -0,0 +1,17 @@
|
|
1
|
+
on:
|
2
|
+
push:
|
3
|
+
tags:
|
4
|
+
- "v*"
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
publish:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v2
|
11
|
+
- uses: ruby/setup-ruby@v1
|
12
|
+
with:
|
13
|
+
ruby-version: "3.0"
|
14
|
+
bundler-cache: true
|
15
|
+
- run: bundle exec rake release
|
16
|
+
env:
|
17
|
+
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
on:
|
2
|
+
push:
|
3
|
+
branches:
|
4
|
+
- main
|
5
|
+
pull_request:
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
fail-fast: false
|
12
|
+
matrix:
|
13
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
14
|
+
ruby: [2.6, 2.7, "3.0"]
|
15
|
+
steps:
|
16
|
+
- uses: actions/checkout@v2
|
17
|
+
- uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
|
+
bundler-cache: true
|
21
|
+
- run: bundle exec rspec
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
danger-regexp (1.0.0)
|
5
|
+
danger
|
6
|
+
git_diff_parser (~> 3.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
addressable (2.8.0)
|
12
|
+
public_suffix (>= 2.0.2, < 5.0)
|
13
|
+
byebug (11.1.3)
|
14
|
+
claide (1.0.3)
|
15
|
+
claide-plugins (0.9.2)
|
16
|
+
cork
|
17
|
+
nap
|
18
|
+
open4 (~> 1.3)
|
19
|
+
coderay (1.1.3)
|
20
|
+
colored2 (3.1.2)
|
21
|
+
cork (0.3.0)
|
22
|
+
colored2 (~> 3.1)
|
23
|
+
danger (8.3.1)
|
24
|
+
claide (~> 1.0)
|
25
|
+
claide-plugins (>= 0.9.2)
|
26
|
+
colored2 (~> 3.1)
|
27
|
+
cork (~> 0.1)
|
28
|
+
faraday (>= 0.9.0, < 2.0)
|
29
|
+
faraday-http-cache (~> 2.0)
|
30
|
+
git (~> 1.7)
|
31
|
+
kramdown (~> 2.3)
|
32
|
+
kramdown-parser-gfm (~> 1.0)
|
33
|
+
no_proxy_fix
|
34
|
+
octokit (~> 4.7)
|
35
|
+
terminal-table (>= 1, < 4)
|
36
|
+
diff-lcs (1.4.4)
|
37
|
+
faraday (1.5.1)
|
38
|
+
faraday-em_http (~> 1.0)
|
39
|
+
faraday-em_synchrony (~> 1.0)
|
40
|
+
faraday-excon (~> 1.1)
|
41
|
+
faraday-httpclient (~> 1.0.1)
|
42
|
+
faraday-net_http (~> 1.0)
|
43
|
+
faraday-net_http_persistent (~> 1.1)
|
44
|
+
faraday-patron (~> 1.0)
|
45
|
+
multipart-post (>= 1.2, < 3)
|
46
|
+
ruby2_keywords (>= 0.0.4)
|
47
|
+
faraday-em_http (1.0.0)
|
48
|
+
faraday-em_synchrony (1.0.0)
|
49
|
+
faraday-excon (1.1.0)
|
50
|
+
faraday-http-cache (2.2.0)
|
51
|
+
faraday (>= 0.8)
|
52
|
+
faraday-httpclient (1.0.1)
|
53
|
+
faraday-net_http (1.0.1)
|
54
|
+
faraday-net_http_persistent (1.2.0)
|
55
|
+
faraday-patron (1.0.0)
|
56
|
+
git (1.9.1)
|
57
|
+
rchardet (~> 1.8)
|
58
|
+
git_diff_parser (3.2.0)
|
59
|
+
kramdown (2.3.1)
|
60
|
+
rexml
|
61
|
+
kramdown-parser-gfm (1.1.0)
|
62
|
+
kramdown (~> 2.0)
|
63
|
+
method_source (1.0.0)
|
64
|
+
multipart-post (2.1.1)
|
65
|
+
nap (1.1.0)
|
66
|
+
no_proxy_fix (0.1.2)
|
67
|
+
octokit (4.21.0)
|
68
|
+
faraday (>= 0.9)
|
69
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
70
|
+
open4 (1.3.4)
|
71
|
+
pry (0.13.1)
|
72
|
+
coderay (~> 1.1)
|
73
|
+
method_source (~> 1.0)
|
74
|
+
pry-byebug (3.9.0)
|
75
|
+
byebug (~> 11.0)
|
76
|
+
pry (~> 0.13.0)
|
77
|
+
public_suffix (4.0.6)
|
78
|
+
rake (13.0.6)
|
79
|
+
rchardet (1.8.0)
|
80
|
+
rexml (3.2.5)
|
81
|
+
rspec (3.10.0)
|
82
|
+
rspec-core (~> 3.10.0)
|
83
|
+
rspec-expectations (~> 3.10.0)
|
84
|
+
rspec-mocks (~> 3.10.0)
|
85
|
+
rspec-core (3.10.1)
|
86
|
+
rspec-support (~> 3.10.0)
|
87
|
+
rspec-expectations (3.10.1)
|
88
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
89
|
+
rspec-support (~> 3.10.0)
|
90
|
+
rspec-mocks (3.10.2)
|
91
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
92
|
+
rspec-support (~> 3.10.0)
|
93
|
+
rspec-support (3.10.2)
|
94
|
+
ruby2_keywords (0.0.5)
|
95
|
+
sawyer (0.8.2)
|
96
|
+
addressable (>= 2.3.5)
|
97
|
+
faraday (> 0.8, < 2.0)
|
98
|
+
terminal-table (3.0.1)
|
99
|
+
unicode-display_width (>= 1.1.1, < 3)
|
100
|
+
unicode-display_width (2.0.0)
|
101
|
+
|
102
|
+
PLATFORMS
|
103
|
+
x86_64-linux
|
104
|
+
|
105
|
+
DEPENDENCIES
|
106
|
+
bundler (>= 2.2.10)
|
107
|
+
danger-regexp!
|
108
|
+
pry-byebug
|
109
|
+
rake (>= 12.3.3)
|
110
|
+
rspec
|
111
|
+
|
112
|
+
BUNDLED WITH
|
113
|
+
2.2.22
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
# Danger
|
1
|
+
# Danger Regexp
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
A danger plugin to add a comment based on regexp.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,13 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
```ruby
|
24
|
+
regexp.lint to
|
25
|
+
match(/hello world/, <<~MESSAGE)
|
26
|
+
Don't use hello world, just use hello instead.
|
27
|
+
MESSAGE
|
28
|
+
end
|
29
|
+
```
|
26
30
|
|
27
31
|
## Development
|
28
32
|
|
@@ -32,7 +36,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
36
|
|
33
37
|
## Contributing
|
34
38
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mtsmfm/danger-regexp. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
40
|
|
37
41
|
## License
|
38
42
|
|
@@ -40,4 +44,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
40
44
|
|
41
45
|
## Code of Conduct
|
42
46
|
|
43
|
-
Everyone interacting in the Danger::Regexp project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
47
|
+
Everyone interacting in the Danger::Regexp project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mtsmfm/danger-regexp/blob/master/CODE_OF_CONDUCT.md).
|
data/danger-regexp.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Fumiaki MATSUSHIMA"]
|
10
10
|
spec.email = ["mtsmfm@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{}
|
13
|
-
spec.description = %q{}
|
12
|
+
spec.summary = %q{A danger plugin to add a comment based on regexp}
|
13
|
+
spec.description = %q{A danger plugin to add a comment based on regexp}
|
14
14
|
spec.homepage = "https://github.com/mtsmfm/danger-regexp"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -24,8 +24,8 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
26
|
spec.add_dependency "git_diff_parser", "~> 3.1"
|
27
|
+
spec.add_dependency "danger"
|
27
28
|
|
28
|
-
spec.add_development_dependency "bundler", "
|
29
|
-
spec.add_development_dependency "rake", "
|
30
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
29
|
+
spec.add_development_dependency "bundler", ">= 2.2.10"
|
30
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
31
31
|
end
|
data/lib/danger_plugin.rb
CHANGED
@@ -2,18 +2,30 @@ require 'git_diff_parser'
|
|
2
2
|
|
3
3
|
module Danger
|
4
4
|
class DangerRegexp < Plugin
|
5
|
+
MAX_COMMENT_COUNT = 5
|
6
|
+
|
7
|
+
ChangedLine = Struct.new(:file, :number, :content, keyword_init: true)
|
8
|
+
|
5
9
|
def lint(&block)
|
6
10
|
@map = {}
|
7
11
|
|
8
12
|
instance_eval(&block)
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
@map.each do |regexp, message|
|
15
|
+
count = 0
|
16
|
+
|
17
|
+
target_lines = changed_lines.select do |line|
|
18
|
+
line.content.match?(regexp)
|
19
|
+
end
|
20
|
+
|
21
|
+
target_lines.first(MAX_COMMENT_COUNT).each do |line|
|
22
|
+
markdown(message, file: line.file, line: line.number)
|
23
|
+
end
|
24
|
+
|
25
|
+
if target_lines.size > MAX_COMMENT_COUNT
|
26
|
+
warn <<~MSG
|
27
|
+
Regexp #{regexp.inspect} matched too many lines (#{target_lines.size} lines). Only first #{MAX_COMMENT_COUNT} comments are posted.
|
28
|
+
MSG
|
17
29
|
end
|
18
30
|
end
|
19
31
|
end
|
@@ -25,5 +37,13 @@ module Danger
|
|
25
37
|
@map[regexp] = message
|
26
38
|
end
|
27
39
|
end
|
40
|
+
|
41
|
+
def changed_lines
|
42
|
+
@changed_lines ||= git.diff.flat_map do |diff|
|
43
|
+
GitDiffParser::Patch.new(diff.patch).changed_lines.map do |line|
|
44
|
+
ChangedLine.new(file: diff.path, number: line.number, content: line.content)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
28
48
|
end
|
29
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-regexp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fumiaki MATSUSHIMA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git_diff_parser
|
@@ -25,58 +25,68 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: danger
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.2.10
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.2.10
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 12.3.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
description:
|
68
|
+
version: 12.3.3
|
69
|
+
description: A danger plugin to add a comment based on regexp
|
70
70
|
email:
|
71
71
|
- mtsmfm@gmail.com
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- ".devcontainer/.gitignore"
|
77
|
+
- ".devcontainer/Dockerfile"
|
78
|
+
- ".devcontainer/app.env.example"
|
79
|
+
- ".devcontainer/devcontainer.json"
|
80
|
+
- ".devcontainer/docker-compose.yml"
|
81
|
+
- ".github/workflows/publish.yml"
|
82
|
+
- ".github/workflows/test.yml"
|
76
83
|
- ".gitignore"
|
84
|
+
- ".rspec"
|
77
85
|
- ".travis.yml"
|
86
|
+
- CHANGELOG.md
|
78
87
|
- CODE_OF_CONDUCT.md
|
79
88
|
- Gemfile
|
89
|
+
- Gemfile.lock
|
80
90
|
- LICENSE.txt
|
81
91
|
- README.md
|
82
92
|
- Rakefile
|
@@ -105,9 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
115
|
- !ruby/object:Gem::Version
|
106
116
|
version: '0'
|
107
117
|
requirements: []
|
108
|
-
|
109
|
-
rubygems_version: 2.7.7
|
118
|
+
rubygems_version: 3.2.22
|
110
119
|
signing_key:
|
111
120
|
specification_version: 4
|
112
|
-
summary:
|
121
|
+
summary: A danger plugin to add a comment based on regexp
|
113
122
|
test_files: []
|