lib/circleci/bundle/update/pr.rb in circleci-bundle-update-pr-1.14.3 vs lib/circleci/bundle/update/pr.rb in circleci-bundle-update-pr-1.14.4

- old
+ new

@@ -14,11 +14,16 @@ if skip?(allow_dup_pr) puts 'Skip because it has already existed.' return end - unless need_to_commit?(git_branches) + unless target_branch?(running_branch: ENV['CIRCLE_BRANCH'], target_branches: git_branches) + puts "Skip because CIRCLE_BRANCH[#{ENV['CIRCLE_BRANCH']}] is not included in target branches[#{git_branches.join(',')}]." + return + end + + unless need_to_commit? puts 'No changes due to bundle update' return end git_username ||= client.user.login @@ -66,15 +71,23 @@ pr.title =~ /\A#{TITLE_PREFIX}/ && pr.head.ref =~ /\A#{BRANCH_PREFIX}\d+/ end != nil end private_class_method :exists_bundle_update_pr? + # Is running branch included in target_branches? + # + # @param running_branch [String] + # @param target_branches [Array<String>] + # @return [Boolean] + def self.target_branch?(running_branch:, target_branches:) + target_branches.include?(running_branch) + end + private_class_method :target_branch? + # Does it need to commit due to bundle update? # - # @param git_branches [Array<String>] # @return [Boolean] - def self.need_to_commit?(git_branches) - return false unless git_branches.include?(ENV['CIRCLE_BRANCH']) + def self.need_to_commit? unless system("bundle update && bundle update --ruby") raise "Unable to execute `bundle update && bundle update --ruby`" end `git status -sb 2> /dev/null`.include?("Gemfile.lock") end