From 996683657578757cf42ef7478a5c3b9874b312f0 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 27 Apr 2023 09:27:52 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- tooling/bin/find_only_allowed_files_changes | 12 ++++++++++++ tooling/bin/find_only_js_changes | 12 ------------ tooling/lib/tooling/find_changes.rb | 6 ++++-- 3 files changed, 16 insertions(+), 14 deletions(-) create mode 100755 tooling/bin/find_only_allowed_files_changes delete mode 100755 tooling/bin/find_only_js_changes (limited to 'tooling') diff --git a/tooling/bin/find_only_allowed_files_changes b/tooling/bin/find_only_allowed_files_changes new file mode 100755 index 00000000000..c40048c66fa --- /dev/null +++ b/tooling/bin/find_only_allowed_files_changes @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require_relative '../lib/tooling/find_changes' + +if Tooling::FindChanges.new(from: :api).only_allowed_files_changed + puts "Only files with extensions #{ALLOWED_FILE_TYPES.join(', ')} were changed" + exit 0 +else + puts "Changes were made to files with extensions other than #{ALLOWED_FILE_TYPES.join(', ')}" + exit 1 +end diff --git a/tooling/bin/find_only_js_changes b/tooling/bin/find_only_js_changes deleted file mode 100755 index a69ee64fe14..00000000000 --- a/tooling/bin/find_only_js_changes +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -require_relative '../lib/tooling/find_changes' - -if Tooling::FindChanges.new(from: :api).only_js_files_changed - puts "Only JS files were changed" - exit 0 -else - puts "Changes were made to files other than JS files" - exit 1 -end diff --git a/tooling/lib/tooling/find_changes.rb b/tooling/lib/tooling/find_changes.rb index 25381e1a894..c498c83d24b 100755 --- a/tooling/lib/tooling/find_changes.rb +++ b/tooling/lib/tooling/find_changes.rb @@ -8,6 +8,8 @@ module Tooling class FindChanges include Helpers::PredictiveTestsHelper + ALLOWED_FILE_TYPES = ['.js', '.vue', '.md', '.scss'].freeze + def initialize( from:, changed_files_pathname: nil, @@ -41,8 +43,8 @@ module Tooling end end - def only_js_files_changed - file_changes.any? && file_changes.all? { |file| file.end_with?('.js') } + def only_allowed_files_changed + file_changes.any? && file_changes.all? { |file| ALLOWED_FILE_TYPES.include?(File.extname(file)) } end private -- cgit v1.2.1