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 # Get list of vendored files which are modified
29 modified_vendor_files = git.modified_files.select do |file|
30 file.start_with?("vendor")
33 # Report if some vendored file is modified
34 if modified_vendor_files.empty?
35 auto_label.remove("vendor-changes")
37 modified_files_str = modified_vendor_files.map { |file| "`#{file}`" }.join(", ")
38 warn("The following vendored files have been modified: #{modified_files_str}. Vendored files should be updated upstream.")
39 auto_label.set(pr_number, "vendor-changes", "B60205")
42 # Report if there are merge-commits in PR
43 if git.commits.any? { |c| c.parents.count > 1 }
44 warn("Merge commits are found in PR. Please rebase to get rid of the merge commits in this PR, see CONTRIBUTING.md.")
45 auto_label.set(pr_number, "merge-commits", "D93F0B")
47 auto_label.remove("merge-commits")
50 # Check if Gemfile is modified but Gemfile.lock is not
51 gemfile_modified = git.modified_files.include?("Gemfile")
52 gemfile_lock_modified = git.modified_files.include?("Gemfile.lock")
53 if gemfile_modified && !gemfile_lock_modified
54 warn("Gemfile was updated, but Gemfile.lock wasn't updated. Usually, when Gemfile is updated, you should run `bundle install` to update Gemfile.lock.")
55 auto_label.set(pr_number, "gemfile-lock-outdated", "F9D0C4")
57 auto_label.remove("gemfile-lock-outdated")