Skip to content

Commit

Permalink
Skip retrieving comments if unused
Browse files Browse the repository at this point in the history
Let's skip retrieving the list of issue comments if none of the options
requiring them will be used.

This restores a previous optimization that was removed.
  • Loading branch information
jeffreyguenther committed Oct 2, 2021
1 parent aec5cbe commit 9aac0ab
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,27 @@ else
pr_number = pr["number"]
end

comments = github.issue_comments(repo, pr_number)
if !duplicate_msg_pattern.empty? || !delete_prev_regex_msg.empty?
comments = github.issue_comments(repo, pr_number)

if check_duplicate_msg == "true"
if check_duplicate_msg == "true"
duplicate = if !duplicate_msg_pattern.empty?
comments.find { |c| c["body"].match(/#{duplicate_msg_pattern}/) }
else
comments.find { |c| c["body"] == message }
end
else
comments.find { |c| c["body"] == message }
end

if duplicate
puts "The PR already contains this message"
exit(0)
if duplicate
puts "The PR already contains this message"
exit(0)
end
end
end

if !delete_prev_regex_msg.empty?
comments.each do |comment|
if comment["body"].match(/#{delete_prev_regex_msg}/)
github.delete_comment(repo, comment["id"])
comments.each do |comment|
if comment["body"].match(/#{delete_prev_regex_msg}/)
github.delete_comment(repo, comment["id"])
end
end
end
end
Expand Down

0 comments on commit 9aac0ab

Please sign in to comment.