lib/circleci/bundle/update/pr.rb in circleci-bundle-update-pr-1.12.0 vs lib/circleci/bundle/update/pr.rb in circleci-bundle-update-pr-1.13.0
- old
+ new
@@ -5,14 +5,14 @@
module Circleci
module Bundle
module Update
module Pr
def self.create_if_needed(git_username: nil, git_email: nil, git_branches: ["master"],
- assignees: nil, reviewers: nil, labels: nil)
+ assignees: nil, reviewers: nil, labels: nil, allow_dup_pr: false)
raise_if_env_unvalid!
- if skip?
+ if skip?(allow_dup_pr)
puts 'Skip because it has already existed.'
return
end
unless need_to_commit?(git_branches)
@@ -45,18 +45,28 @@
raise "$ENTERPRISE_OCTOKIT_ACCESS_TOKEN isn't set"
end
end
private_class_method :raise_if_env_unvalid!
+ # Should skip to make PR?
+ #
+ # @param allow_dup_pr [Boolean]
+ # @return [Boolean]
+ def self.skip?(allow_dup_pr)
+ return false if allow_dup_pr
+ exists_bundle_update_pr?
+ end
+ private_class_method :skip?
+
# Has 'bundle update PR' already existed?
#
# @return [Boolean]
- def self.skip?
+ def self.exists_bundle_update_pr?
client.pull_requests(repo_full_name).find do |pr|
pr.title =~ /\A#{TITLE_PREFIX}/ && pr.head.ref =~ /\A#{BRANCH_PREFIX}\d+/
end != nil
end
- private_class_method :skip?
+ private_class_method :exists_bundle_update_pr?
# Does it need to commit due to bundle update?
#
# @param git_branches [Array<String>]
# @return [Boolean]