danger-samsao 0.1.1 → 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/CHANGELOG.md +41 -0
- data/Dangerfile +22 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +15 -14
- data/README.md +78 -23
- data/bitrise.yml +10 -0
- data/danger-samsao.gemspec +3 -1
- data/lib/samsao/actions.rb +3 -4
- data/lib/samsao/config.rb +24 -0
- data/lib/samsao/gem_version.rb +1 -1
- data/lib/samsao/helpers.rb +9 -9
- data/spec/samsao_branch_helper_spec.rb +6 -3
- data/spec/samsao_branching_model_spec.rb +3 -2
- data/spec/samsao_changelog_updated_spec.rb +35 -16
- data/spec/samsao_config_spec.rb +55 -1
- data/spec/samsao_trivial_change_spec.rb +5 -19
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17a57df336d68834fbc0789edfd27de8f66ad1b6
|
4
|
+
data.tar.gz: a1465dc66e0437c9659bbe61d4baae682133dc3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 942d127d15303f2a7fcf8fb1df32ba074e5c401e5e23b732646c3b12ca5130ac2ed6fa6a2d3d602614201935a1755186570b467cf17d37813e05b483298606c2
|
7
|
+
data.tar.gz: 7f7b39dc19d1a8fbc998e2afc17191043b16947a61a61636576159b400a78f2a33635d89a1c95856959ae3547b46fe47917bb9851c50afb77a3d9b1cddf6e8dd
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,50 @@
|
|
1
|
+
## 0.2.0 (May 9, 2017)
|
2
|
+
|
3
|
+
#### Breaking Changes
|
4
|
+
|
5
|
+
* Changed `trivial_change?` logic by only flagging PR as trivial using
|
6
|
+
the PR title and not the branch name anymore.
|
7
|
+
|
8
|
+
* Removed `trivial_branch?` support. It was replaced by `support_branch?`
|
9
|
+
instead to more closely follow git flow branching model.
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* Enhanced the changelog missing action to not fail when changelog is
|
14
|
+
not updated, project is of type `:application` and PR is on a support
|
15
|
+
branch.
|
16
|
+
|
17
|
+
* Added config option `project_type` which can be one of `:application`
|
18
|
+
or `:library` and defaults to `:application`.
|
19
|
+
|
20
|
+
* Enhanced `fix_branch?` to support `hotfix/` and `bugfix/` prefixes.
|
21
|
+
|
22
|
+
* Added `support_branch?` support.
|
23
|
+
|
24
|
+
* Updated `trivial_change?` helper to support variations in marker
|
25
|
+
for `#typo` marker, now supports `#typos`.
|
26
|
+
|
27
|
+
#### Fixes
|
28
|
+
|
29
|
+
* Fixed branching model to fully support git flow branching model which
|
30
|
+
is the branching model we use.
|
31
|
+
|
32
|
+
#### Support
|
33
|
+
|
34
|
+
* Added `Danger` to project, eating our own dog food.
|
35
|
+
|
36
|
+
* Reformatted `CHANGELOG.md` a bit to split by sections.
|
37
|
+
|
1
38
|
## 0.1.1 (May 4, 2017)
|
2
39
|
|
40
|
+
#### Features
|
41
|
+
|
3
42
|
* Open source to MIT.
|
4
43
|
|
5
44
|
## 0.1.0 (May 1, 2017)
|
6
45
|
|
46
|
+
#### Features
|
47
|
+
|
7
48
|
* Added `fail_when_merge_commit_detected` action.
|
8
49
|
|
9
50
|
* Added `warn_when_work_in_progess_pr` action.
|
data/Dangerfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# rubocop:disable Style/FileName
|
2
|
+
|
3
|
+
## Config
|
4
|
+
samsao.config do
|
5
|
+
project_type :library
|
6
|
+
sources '.*'
|
7
|
+
end
|
8
|
+
|
9
|
+
## Errors
|
10
|
+
samsao.fail_when_changelog_update_missing
|
11
|
+
samsao.fail_when_merge_commit_detected
|
12
|
+
samsao.fail_when_non_single_commit_feature
|
13
|
+
samsao.fail_when_wrong_branching_model
|
14
|
+
|
15
|
+
## Warnings
|
16
|
+
samsao.warn_when_work_in_progess_pr
|
17
|
+
|
18
|
+
## Messages
|
19
|
+
unless status_report[:errors].empty?
|
20
|
+
message 'If this was a trivial change, typo fix or tooling related, ' \
|
21
|
+
'you can add #trivial, #typo or #tool respectively in your PR title.'
|
22
|
+
end
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-samsao (0.
|
4
|
+
danger-samsao (0.2.0)
|
5
5
|
danger-plugin-api (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -19,7 +19,7 @@ GEM
|
|
19
19
|
colored2 (3.1.2)
|
20
20
|
cork (0.3.0)
|
21
21
|
colored2 (~> 3.1)
|
22
|
-
danger (5.
|
22
|
+
danger (5.2.1)
|
23
23
|
claide (~> 1.0)
|
24
24
|
claide-plugins (>= 0.9.2)
|
25
25
|
colored2 (~> 3.1)
|
@@ -86,19 +86,19 @@ GEM
|
|
86
86
|
rb-fsevent (0.9.8)
|
87
87
|
rb-inotify (0.9.8)
|
88
88
|
ffi (>= 0.5.0)
|
89
|
-
rspec (3.
|
90
|
-
rspec-core (~> 3.
|
91
|
-
rspec-expectations (~> 3.
|
92
|
-
rspec-mocks (~> 3.
|
93
|
-
rspec-core (3.
|
94
|
-
rspec-support (~> 3.
|
95
|
-
rspec-expectations (3.
|
89
|
+
rspec (3.6.0)
|
90
|
+
rspec-core (~> 3.6.0)
|
91
|
+
rspec-expectations (~> 3.6.0)
|
92
|
+
rspec-mocks (~> 3.6.0)
|
93
|
+
rspec-core (3.6.0)
|
94
|
+
rspec-support (~> 3.6.0)
|
95
|
+
rspec-expectations (3.6.0)
|
96
96
|
diff-lcs (>= 1.2.0, < 2.0)
|
97
|
-
rspec-support (~> 3.
|
98
|
-
rspec-mocks (3.
|
97
|
+
rspec-support (~> 3.6.0)
|
98
|
+
rspec-mocks (3.6.0)
|
99
99
|
diff-lcs (>= 1.2.0, < 2.0)
|
100
|
-
rspec-support (~> 3.
|
101
|
-
rspec-support (3.
|
100
|
+
rspec-support (~> 3.6.0)
|
101
|
+
rspec-support (3.6.0)
|
102
102
|
rubocop (0.48.1)
|
103
103
|
parser (>= 2.3.3.1, < 3.0)
|
104
104
|
powerpack (~> 0.1)
|
@@ -122,6 +122,7 @@ PLATFORMS
|
|
122
122
|
|
123
123
|
DEPENDENCIES
|
124
124
|
bundler (~> 1.3)
|
125
|
+
danger (~> 5.1)
|
125
126
|
danger-samsao!
|
126
127
|
guard (~> 2.14)
|
127
128
|
guard-rspec (~> 4.7)
|
@@ -129,7 +130,7 @@ DEPENDENCIES
|
|
129
130
|
pry (~> 0.11.0.pre2)
|
130
131
|
rake (~> 10.0)
|
131
132
|
rspec (~> 3.4)
|
132
|
-
rubocop (~> 0.
|
133
|
+
rubocop (~> 0.48)
|
133
134
|
yard (~> 0.8)
|
134
135
|
|
135
136
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -7,6 +7,32 @@ A Danger plugin bringing Samsao's PR guideline into code.
|
|
7
7
|
Simply add `danger-samsao` to your `Gemfile` and configure your `Dangerfile`
|
8
8
|
using all the nice goodies.
|
9
9
|
|
10
|
+
## Quick Start
|
11
|
+
|
12
|
+
Here a sample `Dangerfile` that you can use to bootstrap your project:
|
13
|
+
|
14
|
+
```
|
15
|
+
## Config
|
16
|
+
samsao.config do
|
17
|
+
sources '.*'
|
18
|
+
end
|
19
|
+
|
20
|
+
## Errors
|
21
|
+
samsao.fail_when_changelog_update_missing
|
22
|
+
samsao.fail_when_merge_commit_detected
|
23
|
+
samsao.fail_when_non_single_commit_feature
|
24
|
+
samsao.fail_when_wrong_branching_model
|
25
|
+
|
26
|
+
## Warnings
|
27
|
+
samsao.warn_when_work_in_progess_pr
|
28
|
+
|
29
|
+
## Messages
|
30
|
+
unless status_report[:errors].empty?
|
31
|
+
message 'If this was a trivial change, typo fix or tooling related, ' \
|
32
|
+
'you can add #trivial, #typo or #tool respectively in your PR title.'
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
10
36
|
## Usage
|
11
37
|
|
12
38
|
Methods and attributes from this plugin are available in
|
@@ -22,13 +48,13 @@ your `Dangerfile` under the `samsao` namespace.
|
|
22
48
|
* [samsao.fail_when_wrong_branching_model](#branching-model)
|
23
49
|
* [samsao.warn_when_work_in_progess_pr](#when-work-in-progess-pr)
|
24
50
|
* [Helpers](#helpers)
|
25
|
-
* [samsao.changelog_modified?](#changelog-modified
|
26
|
-
* [samsao.feature_branch?](#feature-branch
|
27
|
-
* [samsao.fix_branch?](#fix-branch
|
28
|
-
* [samsao.has_app_changes?](#has-app-changes
|
29
|
-
* [samsao.release_branch?](#release-branch
|
30
|
-
* [samsao.
|
31
|
-
* [samsao.trivial_change?](#trivial-change
|
51
|
+
* [samsao.changelog_modified?](#changelog-modified)
|
52
|
+
* [samsao.feature_branch?](#feature-branch)
|
53
|
+
* [samsao.fix_branch?](#fix-branch)
|
54
|
+
* [samsao.has_app_changes?](#has-app-changes)
|
55
|
+
* [samsao.release_branch?](#release-branch)
|
56
|
+
* [samsao.support_branch?](#support-branch)
|
57
|
+
* [samsao.trivial_change?](#trivial-change)
|
32
58
|
|
33
59
|
### Config
|
34
60
|
|
@@ -38,20 +64,32 @@ easier. This is done by using the `config` attributes the plugin:
|
|
38
64
|
```
|
39
65
|
samsao.config do
|
40
66
|
changelogs 'CHANGELOG.yml'
|
67
|
+
project_type :library
|
41
68
|
sources 'app/src'
|
42
69
|
end
|
43
70
|
```
|
44
71
|
|
45
72
|
#### Changelogs
|
46
73
|
|
47
|
-
|
74
|
+
Defaults: `[CHANGELOG.md]`
|
48
75
|
|
49
76
|
Enable to change the CHANGELOG file paths looked upon when checking if
|
50
77
|
CHANGELOG file has been modified or not.
|
51
78
|
|
79
|
+
#### Project Type
|
80
|
+
|
81
|
+
Defaults: `:application`
|
82
|
+
|
83
|
+
Change the kind of project your are currently developing. This settings
|
84
|
+
affects these actions and helpers:
|
85
|
+
|
86
|
+
* [samsao.fail_when_changelog_update_missing](#changelog-update-missing)
|
87
|
+
|
88
|
+
See the exact actions or helpers for precise details about implications.
|
89
|
+
|
52
90
|
#### Sources
|
53
91
|
|
54
|
-
Default:
|
92
|
+
Default: `[]`
|
55
93
|
|
56
94
|
Enable to change which paths are considered has being source files of the
|
57
95
|
project. Multiple entries can be passed. Accepts multiple entries to be passed:
|
@@ -88,7 +126,15 @@ samsao.fail_when_wrong_branching_model
|
|
88
126
|
```
|
89
127
|
|
90
128
|
Going to make the PR fails when the branch does not respect the git branching
|
91
|
-
model.
|
129
|
+
model. We follow git flow branching model and failure will occurs if the branch
|
130
|
+
name does not start with one of the following prefixes:
|
131
|
+
|
132
|
+
* `fix/`
|
133
|
+
* `bugfix/`
|
134
|
+
* `hotfix/`
|
135
|
+
* `feature/`
|
136
|
+
* `release/`
|
137
|
+
* `support/`
|
92
138
|
|
93
139
|
#### CHANGELOG Update Missing
|
94
140
|
|
@@ -96,8 +142,13 @@ model.
|
|
96
142
|
samsao.fail_when_changelog_update_missing
|
97
143
|
```
|
98
144
|
|
99
|
-
|
100
|
-
|
145
|
+
This action reports a failure when a PR is made that is not flagged
|
146
|
+
as a [trivial change](#trivial-change) and the changelog (based on
|
147
|
+
`changelogs` config options) has not been modified.
|
148
|
+
|
149
|
+
When the project is of type `:application`, a change made to a [support
|
150
|
+
branch](#support-branch) will not trigger a failure even if the changelog
|
151
|
+
is not updated.
|
101
152
|
|
102
153
|
#### Feature Branch Multiple Commits
|
103
154
|
|
@@ -171,7 +222,7 @@ Returns true if the PR branch starts with `feature/`.
|
|
171
222
|
samsao.fix_branch?
|
172
223
|
```
|
173
224
|
|
174
|
-
Returns true if the PR branch starts with `fix/`.
|
225
|
+
Returns true if the PR branch starts with `fix/`, `bugfix/` or `hotfix/`.
|
175
226
|
|
176
227
|
#### Release Branch?
|
177
228
|
|
@@ -181,13 +232,13 @@ samsao.release_branch?
|
|
181
232
|
|
182
233
|
Returns true if the PR branch starts with `release/`.
|
183
234
|
|
184
|
-
####
|
235
|
+
#### Support Branch?
|
185
236
|
|
186
237
|
```
|
187
|
-
samsao.
|
238
|
+
samsao.support_branch?
|
188
239
|
```
|
189
240
|
|
190
|
-
Returns true if the PR branch starts with `
|
241
|
+
Returns true if the PR branch starts with `support/`.
|
191
242
|
|
192
243
|
#### Trivial Change?
|
193
244
|
|
@@ -195,8 +246,7 @@ Returns true if the PR branch starts with `trivial/`.
|
|
195
246
|
samsao.trivial_change?
|
196
247
|
```
|
197
248
|
|
198
|
-
Returns true if the PR title contains `#trivial
|
199
|
-
trivial branch ([trivial_branch?](#trivial-branch-) helper).
|
249
|
+
Returns true if the PR title contains `#trivial`, `#typo` or `#typos`.
|
200
250
|
|
201
251
|
## Development
|
202
252
|
|
@@ -232,11 +282,12 @@ Assume for the rest of this section that we are releasing version `0.1.0`
|
|
232
282
|
and today's date is `May 1st, 2017`. Terminal commands are given, but feel
|
233
283
|
free to use `SourceTree` or anything else.
|
234
284
|
|
235
|
-
Start by checking out the
|
236
|
-
|
285
|
+
Start by checking out the `develop` branch and ensure you are up-to-date
|
286
|
+
with remote
|
237
287
|
|
238
288
|
```
|
239
|
-
git checkout
|
289
|
+
git checkout develop
|
290
|
+
git pull
|
240
291
|
```
|
241
292
|
|
242
293
|
Once on the branch, modify `CHANGELOG.md` so that `In progress` is replaced by
|
@@ -256,17 +307,21 @@ Once the commit is done, simply run `bundle exec rake release`. This will
|
|
256
307
|
ask you for the Samsao's RubyGems credentials (only if it's your first
|
257
308
|
release, ask a system administrator to get them). It will create a tag
|
258
309
|
on the current commit of the current branch (should be the release commit
|
259
|
-
made earlier) named `v0.1.0`. And it will finally push the tag to the
|
310
|
+
made earlier) named `v0.1.0`. And it will finally push the branch & tag to the
|
260
311
|
repository as well as building and publishing the gem on RubyGems.
|
261
312
|
|
262
313
|
Last thing to do is bumping to next development version. Edit back
|
263
314
|
`CHANGELOG.md` so that `## In progress` is the new section header and
|
264
315
|
add a bunch of empty lines (around 10, only 2 shown in the example for
|
265
|
-
brevity)
|
316
|
+
brevity) into single `Features` section (add other sections when updating
|
317
|
+
the CHANGELOG). Each line should be starting with a **space** followed by
|
318
|
+
a **star**:
|
266
319
|
|
267
320
|
```
|
268
321
|
## In progress
|
269
322
|
|
323
|
+
#### Features
|
324
|
+
|
270
325
|
*
|
271
326
|
|
272
327
|
*
|
data/bitrise.yml
CHANGED
@@ -25,6 +25,7 @@ workflows:
|
|
25
25
|
before_run:
|
26
26
|
- _cache_pull
|
27
27
|
- _prepare
|
28
|
+
- _danger
|
28
29
|
- _lint
|
29
30
|
- _test
|
30
31
|
|
@@ -48,6 +49,15 @@ workflows:
|
|
48
49
|
- cache-pull@0.9.2:
|
49
50
|
title: Pull cache
|
50
51
|
|
52
|
+
_danger:
|
53
|
+
steps:
|
54
|
+
- script@1.1.3:
|
55
|
+
title: Danger
|
56
|
+
run_if: .IsPR
|
57
|
+
inputs:
|
58
|
+
- content: |-
|
59
|
+
bundle exec danger
|
60
|
+
|
51
61
|
_lint:
|
52
62
|
steps:
|
53
63
|
- script@1.1.3:
|
data/danger-samsao.gemspec
CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
+
spec.required_ruby_version = '~> 2.0'
|
23
|
+
|
22
24
|
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
23
25
|
|
24
26
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
@@ -27,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
27
29
|
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
28
30
|
spec.add_development_dependency 'pry', '~> 0.11.0.pre2'
|
29
31
|
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
32
|
+
spec.add_development_dependency 'rubocop', '~> 0.48'
|
31
33
|
spec.add_development_dependency 'rspec', '~> 3.4'
|
32
34
|
spec.add_development_dependency 'yard', '~> 0.8'
|
33
35
|
end
|
data/lib/samsao/actions.rb
CHANGED
@@ -5,7 +5,7 @@ module Samsao
|
|
5
5
|
#
|
6
6
|
# @return [void]
|
7
7
|
def fail_when_wrong_branching_model
|
8
|
-
message = 'Your branch should be prefixed with feature/, fix/,
|
8
|
+
message = 'Your branch should be prefixed with feature/, fix/, bugfix/, hotfix/, release/ or support/!'
|
9
9
|
|
10
10
|
fail message unless respects_branching_model
|
11
11
|
end
|
@@ -25,10 +25,9 @@ module Samsao
|
|
25
25
|
# @return [void]
|
26
26
|
def fail_when_changelog_update_missing
|
27
27
|
return if trivial_change?
|
28
|
+
return if support_branch? && config.project_type == :application
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
fail message unless changelog_modified?
|
30
|
+
fail 'You did a change without updating CHANGELOG file!' unless changelog_modified?
|
32
31
|
end
|
33
32
|
|
34
33
|
# Fails when one or more merge commit is detected.
|
data/lib/samsao/config.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module Danger
|
2
2
|
# Samsao's config class
|
3
3
|
class SamsaoConfig
|
4
|
+
PROJECT_TYPES = [:application, :library].freeze
|
5
|
+
|
4
6
|
def initialize
|
5
7
|
@changelogs = ['CHANGELOG.md']
|
6
8
|
@sources = []
|
9
|
+
@project_type = :application
|
7
10
|
end
|
8
11
|
|
9
12
|
def changelogs(*entries)
|
@@ -12,10 +15,31 @@ module Danger
|
|
12
15
|
@changelogs = entries
|
13
16
|
end
|
14
17
|
|
18
|
+
def project_type(type = nil)
|
19
|
+
return @project_type if type.nil?
|
20
|
+
|
21
|
+
@project_type = validate_project_type(type)
|
22
|
+
end
|
23
|
+
|
15
24
|
def sources(*entries)
|
16
25
|
return @sources if entries.nil? || entries.empty?
|
17
26
|
|
18
27
|
@sources = entries
|
19
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def validate_project_type(type)
|
33
|
+
return type if valid_project_type?(type)
|
34
|
+
|
35
|
+
actual_type = type.is_a?(Symbol) ? ":#{type}" : type.to_s
|
36
|
+
valid_types = PROJECT_TYPES.map { |valid_type| ":#{valid_type}" }.join(', ')
|
37
|
+
|
38
|
+
raise "Project type '#{actual_type}' is invalid, must be one of '#{valid_types}'"
|
39
|
+
end
|
40
|
+
|
41
|
+
def valid_project_type?(type)
|
42
|
+
PROJECT_TYPES.include?(type)
|
43
|
+
end
|
20
44
|
end
|
21
45
|
end
|
data/lib/samsao/gem_version.rb
CHANGED
data/lib/samsao/helpers.rb
CHANGED
@@ -20,11 +20,11 @@ module Samsao
|
|
20
20
|
git_branch.start_with?('feature/')
|
21
21
|
end
|
22
22
|
|
23
|
-
# Return true if the current PR branch is a
|
23
|
+
# Return true if the current PR branch is a bug fix branch
|
24
24
|
#
|
25
25
|
# @return [void]
|
26
26
|
def fix_branch?
|
27
|
-
|
27
|
+
!(%r{^(bug|hot)?fix/} =~ git_branch).nil?
|
28
28
|
end
|
29
29
|
|
30
30
|
# Return true if the current PR branch is a release branch
|
@@ -34,19 +34,19 @@ module Samsao
|
|
34
34
|
git_branch.start_with?('release/')
|
35
35
|
end
|
36
36
|
|
37
|
-
# Return true if the current PR branch is a
|
37
|
+
# Return true if the current PR branch is a support branch
|
38
38
|
#
|
39
39
|
# @return [void]
|
40
|
-
def
|
41
|
-
git_branch.start_with?('
|
40
|
+
def support_branch?
|
41
|
+
git_branch.start_with?('support/')
|
42
42
|
end
|
43
43
|
|
44
|
-
# Return true if the current PR is a trivial change
|
45
|
-
#
|
44
|
+
# Return true if the current PR is a trivial change, i.e. if
|
45
|
+
# PR title contains #trivial or #typo markers.
|
46
46
|
#
|
47
47
|
# @return [void]
|
48
48
|
def trivial_change?
|
49
|
-
|
49
|
+
!(/#(trivial|typo(s)?)/ =~ github.pr_title).nil?
|
50
50
|
end
|
51
51
|
|
52
52
|
# Return true if any source files are in the git modified files list.
|
@@ -73,7 +73,7 @@ module Samsao
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def respects_branching_model
|
76
|
-
feature_branch? || fix_branch? || release_branch? ||
|
76
|
+
feature_branch? || fix_branch? || release_branch? || support_branch?
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -26,6 +26,9 @@ module Danger
|
|
26
26
|
data_set = [
|
27
27
|
{ branch: 'feature/a', expected: false },
|
28
28
|
{ branch: 'fix/a', expected: true },
|
29
|
+
{ branch: 'bugfix/a', expected: true },
|
30
|
+
{ branch: 'hotfix/a', expected: true },
|
31
|
+
{ branch: 'otherfix/a', expected: false },
|
29
32
|
{ branch: 'random', expected: false },
|
30
33
|
]
|
31
34
|
|
@@ -48,16 +51,16 @@ module Danger
|
|
48
51
|
end
|
49
52
|
end
|
50
53
|
|
51
|
-
it 'supports
|
54
|
+
it 'supports support_branch? correctly' do
|
52
55
|
data_set = [
|
53
|
-
{ branch: '
|
56
|
+
{ branch: 'support/a', expected: true },
|
54
57
|
{ branch: 'fix/a', expected: false },
|
55
58
|
{ branch: 'random', expected: false },
|
56
59
|
]
|
57
60
|
|
58
61
|
data_set.each do |data|
|
59
62
|
allow(@plugin.github).to receive(:branch_for_head).and_return(data[:branch])
|
60
|
-
expect(@plugin.
|
63
|
+
expect(@plugin.support_branch?).to be(data[:expected])
|
61
64
|
end
|
62
65
|
end
|
63
66
|
end
|
@@ -6,11 +6,12 @@ module Danger
|
|
6
6
|
before do
|
7
7
|
@dangerfile = testing_dangerfile
|
8
8
|
@plugin = @dangerfile.samsao
|
9
|
-
@wrong_branching_model = 'Your branch should be prefixed with feature/, fix/,
|
9
|
+
@wrong_branching_model = 'Your branch should be prefixed with feature/, fix/, ' \
|
10
|
+
'bugfix/, hotfix/, release/ or support/!'
|
10
11
|
end
|
11
12
|
|
12
13
|
describe 'branching model' do
|
13
|
-
['fix', 'feature', 'release', '
|
14
|
+
['fix', 'bugfix', 'hotfix', 'feature', 'release', 'support'].each do |branch_prefix|
|
14
15
|
it "continues on #{branch_prefix}/ prefix" do
|
15
16
|
allow(@plugin.github).to receive(:branch_for_head).and_return("#{branch_prefix}/something")
|
16
17
|
|
@@ -6,36 +6,38 @@ module Danger
|
|
6
6
|
before do
|
7
7
|
@dangerfile = testing_dangerfile
|
8
8
|
@plugin = @dangerfile.samsao
|
9
|
-
@changelog_needs_update = 'You did a
|
9
|
+
@changelog_needs_update = 'You did a change without updating CHANGELOG file!'
|
10
10
|
|
11
11
|
allow(@plugin.github).to receive(:pr_title).and_return('Something')
|
12
12
|
end
|
13
13
|
|
14
14
|
describe 'changelog updated' do
|
15
|
-
it 'continues on
|
16
|
-
allow(@plugin.github).to receive(:branch_for_head).and_return('
|
15
|
+
it 'continues on support branch' do
|
16
|
+
allow(@plugin.github).to receive(:branch_for_head).and_return('support/a')
|
17
17
|
|
18
18
|
@plugin.fail_when_changelog_update_missing
|
19
19
|
|
20
20
|
expect(@dangerfile).to have_no_error
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
['fix', 'bugfix', 'hotfix', 'feature', 'release'].each do |branch|
|
24
|
+
it "continues on #{branch} branch and CHANGELOG updated" do
|
25
|
+
allow(@plugin.github).to receive(:branch_for_head).and_return("#{branch}/a")
|
26
|
+
allow(@plugin.git).to receive(:modified_files).and_return(['CHANGELOG.md'])
|
26
27
|
|
27
|
-
|
28
|
+
@plugin.fail_when_changelog_update_missing
|
28
29
|
|
29
|
-
|
30
|
-
|
30
|
+
expect(@dangerfile).to have_no_error
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
it "fails on #{branch} branch and CHANGELOG not updated" do
|
34
|
+
allow(@plugin.github).to receive(:branch_for_head).and_return("#{branch}/a")
|
35
|
+
allow(@plugin.git).to receive(:modified_files).and_return([])
|
35
36
|
|
36
|
-
|
37
|
+
@plugin.fail_when_changelog_update_missing
|
37
38
|
|
38
|
-
|
39
|
+
expect(@dangerfile).to have_error(@changelog_needs_update)
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
it 'accepts customized changelogs path' do
|
@@ -73,8 +75,25 @@ module Danger
|
|
73
75
|
expect(@dangerfile).to have_no_error
|
74
76
|
end
|
75
77
|
|
76
|
-
it '
|
77
|
-
|
78
|
+
it 'continues on support_branch within application project and CHANGELOG not updated' do
|
79
|
+
@plugin.config do
|
80
|
+
project_type :application
|
81
|
+
end
|
82
|
+
|
83
|
+
allow(@plugin).to receive(:support_branch?).and_return(true)
|
84
|
+
allow(@plugin.git).to receive(:modified_files).and_return([])
|
85
|
+
|
86
|
+
@plugin.fail_when_changelog_update_missing
|
87
|
+
|
88
|
+
expect(@dangerfile).to have_no_error
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'fails on support_branch within library project and CHANGELOG not updated' do
|
92
|
+
@plugin.config do
|
93
|
+
project_type :library
|
94
|
+
end
|
95
|
+
|
96
|
+
allow(@plugin).to receive(:support_branch?).and_return(true)
|
78
97
|
allow(@plugin.git).to receive(:modified_files).and_return([])
|
79
98
|
|
80
99
|
@plugin.fail_when_changelog_update_missing
|
data/spec/samsao_config_spec.rb
CHANGED
@@ -8,7 +8,11 @@ module Danger
|
|
8
8
|
@plugin = @dangerfile.samsao
|
9
9
|
end
|
10
10
|
|
11
|
-
describe '
|
11
|
+
describe 'config sources' do
|
12
|
+
it 'defaults to empty array when not set' do
|
13
|
+
expect(@plugin.config.sources).to eq([])
|
14
|
+
end
|
15
|
+
|
12
16
|
it 'can configure single source' do
|
13
17
|
@plugin.config do
|
14
18
|
sources 'app/src'
|
@@ -25,6 +29,56 @@ module Danger
|
|
25
29
|
expect(@plugin.config.sources).to eq(['app/src', 'lib/src'])
|
26
30
|
end
|
27
31
|
end
|
32
|
+
|
33
|
+
describe 'config changelogs' do
|
34
|
+
it 'defaults to [CHANGELOG.md] array when not set' do
|
35
|
+
expect(@plugin.config.changelogs).to eq(['CHANGELOG.md'])
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'can configure single changelog' do
|
39
|
+
@plugin.config do
|
40
|
+
changelogs 'a'
|
41
|
+
end
|
42
|
+
|
43
|
+
expect(@plugin.config.changelogs).to eq(['a'])
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'can configure multiple changelogs' do
|
47
|
+
@plugin.config do
|
48
|
+
changelogs 'a', 'b'
|
49
|
+
end
|
50
|
+
|
51
|
+
expect(@plugin.config.changelogs).to eq(['a', 'b'])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'config project_type' do
|
56
|
+
it 'defaults to :application when not set' do
|
57
|
+
expect(@plugin.config.project_type).to eq(:application)
|
58
|
+
end
|
59
|
+
|
60
|
+
[:application, :library].each do |type|
|
61
|
+
it "accepts :#{type} type" do
|
62
|
+
@plugin.config do
|
63
|
+
project_type type
|
64
|
+
end
|
65
|
+
|
66
|
+
expect(@plugin.config.project_type).to eq(type)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'rejects invalid types when wrong type is a symbol' do
|
71
|
+
message = "Project type ':custom' is invalid, must be one of ':application, :library'"
|
72
|
+
|
73
|
+
expect { @plugin.config { project_type :custom } }.to raise_error(message)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'rejects invalid types when wrong type is a string' do
|
77
|
+
message = "Project type 'custom' is invalid, must be one of ':application, :library'"
|
78
|
+
|
79
|
+
expect { @plugin.config { project_type 'custom' } }.to raise_error(message)
|
80
|
+
end
|
81
|
+
end
|
28
82
|
end
|
29
83
|
end
|
30
84
|
end
|
@@ -12,45 +12,31 @@ module Danger
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe 'trivial_change?' do
|
15
|
-
['#trivial', '#typo'].each do |marker|
|
15
|
+
['#trivial', '#typo', '#typos'].each do |marker|
|
16
16
|
it "returns true when PR title contains #{marker} at the end" do
|
17
|
-
allow(@plugin.github).to receive(:pr_title).and_return("
|
17
|
+
allow(@plugin.github).to receive(:pr_title).and_return("Marker at the end #{marker}")
|
18
18
|
|
19
19
|
expect(@plugin.trivial_change?).to be(true)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "returns true when PR title contains #{marker} at the start" do
|
23
|
-
allow(@plugin.github).to receive(:pr_title).and_return("#{marker}
|
23
|
+
allow(@plugin.github).to receive(:pr_title).and_return("#{marker} Marker at the start")
|
24
24
|
|
25
25
|
expect(@plugin.trivial_change?).to be(true)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "returns true when PR title contains #{marker} in the middle" do
|
29
|
-
allow(@plugin.github).to receive(:pr_title).and_return("
|
30
|
-
|
31
|
-
expect(@plugin.trivial_change?).to be(true)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns true when branch is a trivial branch and PR include #{marker}" do
|
35
|
-
allow(@plugin.github).to receive(:branch_for_head).and_return('trivial/a')
|
36
|
-
allow(@plugin.github).to receive(:pr_title).and_return("##{marker}")
|
29
|
+
allow(@plugin.github).to receive(:pr_title).and_return("Marker in #{marker} the middle")
|
37
30
|
|
38
31
|
expect(@plugin.trivial_change?).to be(true)
|
39
32
|
end
|
40
33
|
end
|
41
34
|
|
42
|
-
it 'returns false
|
43
|
-
allow(@plugin.github).to receive(:branch_for_head).and_return('feature/a')
|
35
|
+
it 'returns false no trivial marker(s) in PR title' do
|
44
36
|
allow(@plugin.github).to receive(:pr_title).and_return('Something')
|
45
37
|
|
46
38
|
expect(@plugin.trivial_change?).to be(false)
|
47
39
|
end
|
48
|
-
|
49
|
-
it 'returns true when branch is a trivial branch' do
|
50
|
-
allow(@plugin.github).to receive(:branch_for_head).and_return('trivial/a')
|
51
|
-
|
52
|
-
expect(@plugin.trivial_change?).to be(true)
|
53
|
-
end
|
54
40
|
end
|
55
41
|
end
|
56
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-samsao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samsao Development Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0.
|
117
|
+
version: '0.48'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0.
|
124
|
+
version: '0.48'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- ".rubocop.yml"
|
163
163
|
- ".travis.yml"
|
164
164
|
- CHANGELOG.md
|
165
|
+
- Dangerfile
|
165
166
|
- Gemfile
|
166
167
|
- Gemfile.lock
|
167
168
|
- Guardfile
|
@@ -206,9 +207,9 @@ require_paths:
|
|
206
207
|
- lib
|
207
208
|
required_ruby_version: !ruby/object:Gem::Requirement
|
208
209
|
requirements:
|
209
|
-
- - "
|
210
|
+
- - "~>"
|
210
211
|
- !ruby/object:Gem::Version
|
211
|
-
version: '0'
|
212
|
+
version: '2.0'
|
212
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
214
|
requirements:
|
214
215
|
- - ">="
|