Module: Samsao::Actions

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

Overview

Actions mixin module

Instance Method Summary collapse

Instance Method Details

#fail_when_changelog_update_missingvoid

This method returns an undefined value.

Fails when CHANGELOG is not updated on feature or fix branches



26
27
28
29
30
31
# File 'lib/samsao/actions.rb', line 26

def fail_when_changelog_update_missing
  return if trivial_change?
  return if support_branch? && config.project_type == :application

  fail 'You did a change without updating CHANGELOG file!' unless changelog_modified?
end

#fail_when_merge_commit_detectedvoid

This method returns an undefined value.

Fails when one or more merge commit is detected.



36
37
38
39
40
41
# File 'lib/samsao/actions.rb', line 36

def fail_when_merge_commit_detected
  message = 'Some merge commits were detected, you must use rebase to sync with base branch.'
  merge_commit_detector = /^Merge branch '#{github.branch_for_base}'/

  fail message if git.commits.any? { |commit| commit.message =~ merge_commit_detector }
end

#fail_when_non_single_commit_featurevoid

This method returns an undefined value.

Fails when a feature branch have than one commit



16
17
18
19
20
21
# File 'lib/samsao/actions.rb', line 16

def fail_when_non_single_commit_feature
  commit_count = git.commits.size
  message = "Your feature branch should have a single commit but found #{commit_count}, squash them together!"

  fail message if feature_branch? && commit_count > 1
end

#fail_when_wrong_branching_modelvoid

This method returns an undefined value.

Fails when git branching model is not respected for PR branch name.



7
8
9
10
11
# File 'lib/samsao/actions.rb', line 7

def fail_when_wrong_branching_model
  message = 'Your branch should be prefixed with feature/, fix/, bugfix/, hotfix/, release/ or support/!'

  fail message unless respects_branching_model
end

#warn_when_work_in_progess_prvoid

This method returns an undefined value.

Fails when CHANGELOG is not updated on feature or fix branches



46
47
48
49
50
# File 'lib/samsao/actions.rb', line 46

def warn_when_work_in_progess_pr
  message = 'Do not merge, PR is a work in progess [WIP]!'

  warn message if github.pr_title.include?('[WIP]')
end