Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only auto approve or set auto complete when a PR is created or is update #1101

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions updater/bin/update_script.rb
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ def show_diff(original_file, updated_file)
end

pull_request_id = nil
created_or_updated = false
if conflict_pull_request_commit && conflict_pull_request_id
##############################################
# Update pull request with conflict resolved #
Expand All @@ -799,6 +800,8 @@ def show_diff(original_file, updated_file)
pr_updater.update
pull_request = existing_pull_request
pull_request_id = conflict_pull_request_id

created_or_updated = true
elsif !existing_pull_request # Only create PR if there is none existing
########################################
# Create a pull request for the update #
Expand Down Expand Up @@ -844,6 +847,8 @@ def show_diff(original_file, updated_file)
else
puts "Seems PR is already present."
end

created_or_updated = true
else
pull_request = existing_pull_request # One already existed
pull_request_id = pull_request["pullRequestId"]
Expand All @@ -854,7 +859,7 @@ def show_diff(original_file, updated_file)
next unless pull_request_id

# Auto approve this Pull Request
if $options[:auto_approve_pr]
if $options[:auto_approve_pr] && created_or_updated
puts "Auto Approving PR #{pull_request_id}"

azure_client.pull_request_approve(
Expand All @@ -878,7 +883,7 @@ def show_diff(original_file, updated_file)
# - [Changelog](....)
# - [Commits](....)
merge_commit_message = "Merged PR #{pull_request_id}: #{msg.pr_name}\n\n#{msg.commit_message}"
if $options[:set_auto_complete]
if $options[:set_auto_complete] && created_or_updated
auto_complete_user_id = pull_request["createdBy"]["id"]
puts "Setting auto complete on ##{pull_request_id}."
azure_client.autocomplete_pull_request(
Expand Down