summaryrefslogtreecommitdiff
path: root/danger/gemfile/Dangerfile
blob: 07c4c07cfe8eb838082fd2badb523a96155070b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
GEMFILE_LOCK_NOT_UPDATED_MESSAGE_SHORT = <<~MSG.freeze
%<gemfile>s was updated but %<gemfile_lock>s wasn't updated.
MSG

GEMFILE_LOCK_NOT_UPDATED_MESSAGE_FULL = <<~MSG.freeze
**#{GEMFILE_LOCK_NOT_UPDATED_MESSAGE_SHORT}**

Usually, when %<gemfile>s is updated, you should run
```
bundle install
```

or

```
bundle update <the-added-or-updated-gem>
```

and commit the %<gemfile_lock>s changes.
MSG

gemfile_modified = git.modified_files.include?("Gemfile")
gemfile_lock_modified = git.modified_files.include?("Gemfile.lock")

if gemfile_modified && !gemfile_lock_modified
  gitlab_danger = GitlabDanger.new(helper.gitlab_helper)

  format_str = gitlab_danger.ci? ? GEMFILE_LOCK_NOT_UPDATED_MESSAGE_FULL : GEMFILE_LOCK_NOT_UPDATED_MESSAGE_SHORT

  message = format(format_str,
    gemfile: gitlab_danger.html_link("Gemfile"),
    gemfile_lock: gitlab_danger.html_link("Gemfile.lock")
  )

  warn(message)
end