danger-samsao 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03220a151b794360af987c44251ffd233e149fa6
4
- data.tar.gz: '081d457757e6ca7108968cbdf1c35656222e4b7e'
3
+ metadata.gz: 00e3c0540e9e427e75712e8754234cff10b9e55f
4
+ data.tar.gz: 9a4e3b0a4d167ac47b152332766bfd03d47fe067
5
5
  SHA512:
6
- metadata.gz: 7cce010f0f2cc393b5be15c1e509988724903093eb85fd4128a2c4a53bb566c654dd19e056bb7c309b9c20bb628873c76f13db3a826f5ac9f580253f43996d1c
7
- data.tar.gz: 931219f4890eaf3d817b1a29437987ed974c06dd3dcd6075ef8d10bc86a13b3d4c2d793a03e684f62b1b7591f5e74ff20a89926d60a055884664f4612ebe0d26
6
+ metadata.gz: 37811b9f3e6bef3802e7d2cc31bfc6348a8a410aff106f9278b6aca8785dccfc59136e0157500b47a481c88248dfc4615531ef0391dd12e70eef540ea9a7a42d
7
+ data.tar.gz: f0b3dae8c0544cf5ba28c3199b3fa9ba1d96d6727e38fd142585a71f4c8bd9929e04196db915cde5669497c29adf6db26f1860e2fef685ad15f72d6baa72cdda
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.3.1 (August 30, 2017)
2
+
3
+ #### Features
4
+
5
+ * Changed the following helpers to support `2.0.0/feature/a` and `other-app/feature/a` branch models:
6
+ * `feature_branch?`
7
+ * `fix_branch?`
8
+ * `release_branch?`
9
+ * `support_branch?`
10
+
11
+ * Added details to error messages to clarify them.
12
+
1
13
  ## 0.3.0 (August 23, 2017)
2
14
 
3
15
  ### Breaking Changes
@@ -32,16 +44,6 @@
32
44
 
33
45
  * Added `truncate` helper.
34
46
 
35
- *
36
-
37
- *
38
-
39
- *
40
-
41
- *
42
-
43
- *
44
-
45
47
  #### Support
46
48
 
47
49
  * Fixed grammatical errors in the `README.md`.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-samsao (0.3.0)
4
+ danger-samsao (0.3.1)
5
5
  danger-plugin-api (~> 1.0)
6
6
 
7
7
  GEM
@@ -72,7 +72,7 @@ module Samsao
72
72
  return if samsao.trivial_change? || !samsao.feature_branch?
73
73
  return report(:fail, 'Your Danger config is missing a `jira_project_key` value.') unless jira_project_key?
74
74
 
75
- message = 'The PR must starts with JIRA issue number between square brackets'\
75
+ message = 'The PR title must starts with JIRA issue number between square brackets'\
76
76
  " (i.e. [#{config.jira_project_key}-XXX])."
77
77
 
78
78
  report(level, message) unless contains_jira_issue_number?(github.pr_title)
@@ -102,7 +102,7 @@ module Samsao
102
102
  def check_acceptance_criteria(level = :warn)
103
103
  return unless samsao.feature_branch?
104
104
 
105
- message = 'The PR should have the acceptance criteria in the body.'
105
+ message = 'The PR description should have the acceptance criteria in the body.'
106
106
 
107
107
  report(level, message) if (/acceptance criteria/i =~ github.pr_body).nil?
108
108
  end
@@ -156,7 +156,7 @@ module Samsao
156
156
  def check_commit_contains_jira_issue_number(commit, type)
157
157
  commit_id = "#{shorten_sha(commit.sha)} ('#{truncate(commit.message)}')"
158
158
  jira_project_key = config.jira_project_key
159
- message = "The commit #{commit_id} should contain JIRA issue number" \
159
+ message = "The commit message #{commit_id} should contain JIRA issue number" \
160
160
  " between square brackets (i.e. [#{jira_project_key}-XXX]), multiple allowed" \
161
161
  " (i.e. [#{jira_project_key}-XXX, #{jira_project_key}-YYY, #{jira_project_key}-ZZZ])"
162
162
 
@@ -1,3 +1,3 @@
1
1
  module Samsao
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.3.1'.freeze
3
3
  end
@@ -20,15 +20,16 @@ module Samsao
20
20
  # @return [Bool]
21
21
  #
22
22
  def feature_branch?
23
- git_branch.start_with?('feature/')
23
+ !(%r{^#{GIT_BRANCH_PREFIX}feature/\w} =~ git_branch).nil?
24
24
  end
25
25
 
26
- # Return true if the current PR branch is a bug fix branch.
26
+ # Return true if the current PR branch is a bug fix branch. Accepts `fix`,
27
+ # `bugfix`, `hotfix`, `coldfix` and `warmfix`.
27
28
  #
28
29
  # @return [Bool]
29
30
  #
30
31
  def fix_branch?
31
- !(%r{^(bug|hot)?fix/} =~ git_branch).nil?
32
+ !(%r{^#{GIT_BRANCH_PREFIX}(bug|cold|warm|hot)?fix/\w} =~ git_branch).nil?
32
33
  end
33
34
 
34
35
  # Return true if the current PR branch is a release branch.
@@ -36,7 +37,7 @@ module Samsao
36
37
  # @return [Bool]
37
38
  #
38
39
  def release_branch?
39
- git_branch.start_with?('release/')
40
+ !(%r{^#{GIT_BRANCH_PREFIX}release/\w} =~ git_branch).nil?
40
41
  end
41
42
 
42
43
  # Return true if the current PR branch is a support branch.
@@ -44,7 +45,7 @@ module Samsao
44
45
  # @return [Bool]
45
46
  #
46
47
  def support_branch?
47
- git_branch.start_with?('support/')
48
+ !(%r{^#{GIT_BRANCH_PREFIX}support/\w} =~ git_branch).nil?
48
49
  end
49
50
 
50
51
  # Return true if the current PR is a trivial change, i.e. if PR title contains #trivial or #typo markers.
@@ -113,6 +114,8 @@ module Samsao
113
114
 
114
115
  private
115
116
 
117
+ GIT_BRANCH_PREFIX = '([-a-z0-9._]+/)?'.freeze
118
+
116
119
  def git_branch
117
120
  github.branch_for_head
118
121
  end
@@ -6,7 +6,7 @@ module Danger
6
6
  before do
7
7
  @dangerfile = testing_dangerfile
8
8
  @plugin = @dangerfile.samsao
9
- @message = 'The PR should have the acceptance criteria in the body.'
9
+ @message = 'The PR description should have the acceptance criteria in the body.'
10
10
  end
11
11
 
12
12
  describe 'check acceptance criteria' do
@@ -12,7 +12,11 @@ module Danger
12
12
  it 'supports feature_branch? correctly' do
13
13
  data_set = [
14
14
  { branch: 'feature/a', expected: true },
15
+ { branch: '2.0.0/feature/a', expected: true },
16
+ { branch: 'other_app-name/feature/a', expected: true },
17
+ { branch: 'something/something-else/feature/a', expected: false },
15
18
  { branch: 'fix/a', expected: false },
19
+ { branch: 'feature/', expected: false },
16
20
  { branch: 'random', expected: false },
17
21
  ]
18
22
 
@@ -28,7 +32,13 @@ module Danger
28
32
  { branch: 'fix/a', expected: true },
29
33
  { branch: 'bugfix/a', expected: true },
30
34
  { branch: 'hotfix/a', expected: true },
35
+ { branch: 'warmfix/a', expected: true },
36
+ { branch: 'coldfix/a', expected: true },
37
+ { branch: '2.0.0/fix/a', expected: true },
38
+ { branch: 'other_app-name/fix/a', expected: true },
39
+ { branch: 'something/something-else/fix/a', expected: false },
31
40
  { branch: 'otherfix/a', expected: false },
41
+ { branch: 'fix/', expected: false },
32
42
  { branch: 'random', expected: false },
33
43
  ]
34
44
 
@@ -41,7 +51,11 @@ module Danger
41
51
  it 'supports release_branch? correctly' do
42
52
  data_set = [
43
53
  { branch: 'release/a', expected: true },
54
+ { branch: '2.0.0/release/a', expected: true },
55
+ { branch: 'other_app-name/release/a', expected: true },
56
+ { branch: 'something/something-else/release/a', expected: false },
44
57
  { branch: 'fix/a', expected: false },
58
+ { branch: 'release/', expected: false },
45
59
  { branch: 'random', expected: false },
46
60
  ]
47
61
 
@@ -54,7 +68,11 @@ module Danger
54
68
  it 'supports support_branch? correctly' do
55
69
  data_set = [
56
70
  { branch: 'support/a', expected: true },
71
+ { branch: '2.0.0/support/a', expected: true },
72
+ { branch: 'other_app-name/support/a', expected: true },
73
+ { branch: 'something/something-else/support/a', expected: false },
57
74
  { branch: 'fix/a', expected: false },
75
+ { branch: 'support/', expected: false },
58
76
  { branch: 'random', expected: false },
59
77
  ]
60
78
 
@@ -52,7 +52,7 @@ module Danger
52
52
 
53
53
  it 'fails on branch with no issue number' do
54
54
  jira_project_key = 'VER'
55
- message = 'The PR must starts with JIRA issue number between square brackets'\
55
+ message = 'The PR title must starts with JIRA issue number between square brackets'\
56
56
  " (i.e. [#{jira_project_key}-XXX])."
57
57
 
58
58
  @plugin.config do
@@ -51,7 +51,7 @@ module Danger
51
51
 
52
52
  @plugin.check_fix_jira_issue_number
53
53
 
54
- message = "The commit #{commit_id} should contain JIRA issue number between square brackets"\
54
+ message = "The commit message #{commit_id} should contain JIRA issue number between square brackets"\
55
55
  " (i.e. [#{jira_project_key}-XXX]), multiple allowed (i.e. [#{jira_project_key}-XXX,"\
56
56
  " #{jira_project_key}-YYY, #{jira_project_key}-ZZZ])"
57
57
 
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.3.0
4
+ version: 0.3.1
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-08-23 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api