Module: Samsao::Helpers

Included in:
Danger::DangerSamsao
Defined in:
lib/samsao/helpers.rb

Overview

Helpers mixin module

Instance Method Summary collapse

Instance Method Details

#changelog_modified?(*changelogs) ⇒ Boolean

Check if any changelog were modified. When the helper receives nothing, changelogs defined by the config are used.

Returns:

  • (Boolean)

    True if any changelogs were modified in this commit



10
11
12
13
14
# File 'lib/samsao/helpers.rb', line 10

def changelog_modified?(*changelogs)
  changelogs = config.changelogs if changelogs.nil? || changelogs.empty?

  changelogs.any? { |changelog| git.modified_files.include?(changelog) }
end

#feature_branch?void

This method returns an undefined value.

Return true if the current PR branch is a feature branch



19
20
21
# File 'lib/samsao/helpers.rb', line 19

def feature_branch?
  git_branch.start_with?('feature/')
end

#fix_branch?void

This method returns an undefined value.

Return true if the current PR branch is a bug fix branch



26
27
28
# File 'lib/samsao/helpers.rb', line 26

def fix_branch?
  !(%r{^(bug|hot)?fix/} =~ git_branch).nil?
end

#has_app_changes?(*sources) ⇒ void

This method returns an undefined value.

Return true if any source files are in the git modified files list.



55
56
57
58
59
60
61
62
63
# File 'lib/samsao/helpers.rb', line 55

def has_app_changes?(*sources)
  sources = config.sources if sources.nil? || sources.empty?

  sources.any? do |source|
    pattern = Samsao::Regexp.from_matcher(source, when_string_pattern_prefix_with: '^')

    modified_file?(pattern)
  end
end

#release_branch?void

This method returns an undefined value.

Return true if the current PR branch is a release branch



33
34
35
# File 'lib/samsao/helpers.rb', line 33

def release_branch?
  git_branch.start_with?('release/')
end

#support_branch?void

This method returns an undefined value.

Return true if the current PR branch is a support branch



40
41
42
# File 'lib/samsao/helpers.rb', line 40

def support_branch?
  git_branch.start_with?('support/')
end

#trivial_change?void

This method returns an undefined value.

Return true if the current PR is a trivial change, i.e. if PR title contains #trivial or #typo markers.



48
49
50
# File 'lib/samsao/helpers.rb', line 48

def trivial_change?
  !(/#(trivial|typo(s)?)/ =~ github.pr_title).nil?
end