1 # frozen_string_literal: true
 
   4 pr_number = github.pr_json["number"]
 
   6 # Report if number of changed lines is > 500
 
   7 if git.lines_of_code > 500
 
   8   warn("Number of updated lines of code is too large to be in one PR. Perhaps it should be separated into two or more?")
 
   9   auto_label.set(pr_number, "big-pr", "FBCA04")
 
  11   auto_label.remove("big-pr")
 
  14 # Get list of translation files (except en.yml) which are modified
 
  15 modified_yml_files = git.modified_files.select do |file|
 
  16   file.start_with?("config/locales") && File.extname(file) == ".yml" && File.basename(file) != "en.yml"
 
  19 # Report if some translation file (except en.yml) is modified
 
  20 if modified_yml_files.empty?
 
  21   auto_label.remove("inappropriate-translations")
 
  23   modified_files_str = modified_yml_files.map { |file| "`#{file}`" }.join(", ")
 
  24   warn("The following YAML files other than `en.yml` have been modified: #{modified_files_str}. Only `en.yml` is allowed to be changed. Translations are updated via Translatewiki, see CONTRIBUTING.md.")
 
  25   auto_label.set(pr_number, "inappropriate-translations", "B60205")
 
  28 # Report if there are merge-commits in PR
 
  29 if git.commits.any? { |c| c.parents.count > 1 }
 
  30   warn("Merge commits are found in PR. Please rebase to get rid of the merge commits in this PR, see CONTRIBUTING.md.")
 
  31   auto_label.set(pr_number, "merge-commits", "D93F0B")
 
  33   auto_label.remove("merge-commits")
 
  36 # Check if Gemfile is modified but Gemfile.lock is not
 
  37 gemfile_modified = git.modified_files.include?("Gemfile")
 
  38 gemfile_lock_modified = git.modified_files.include?("Gemfile.lock")
 
  39 if gemfile_modified && !gemfile_lock_modified
 
  40   warn("Gemfile was updated, but Gemfile.lock wasn't updated. Usually, when Gemfile is updated, you should run `bundle install` to update Gemfile.lock.")
 
  41   auto_label.set(pr_number, "gemfile-lock-outdated", "F9D0C4")
 
  43   auto_label.remove("gemfile-lock-outdated")