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

Remove label management from the legacy app #178

Merged
merged 1 commit into from Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 0 additions & 39 deletions app.rb
Expand Up @@ -36,48 +36,10 @@
halt if event_act == 'pull_request_review_comment/created'

if ENV['GITHUB_OAUTH_TOKEN']
if ENV['REDMINE_API_KEY'] && !repo.redmine_project.nil?
issues_valid = pull_request.issue_numbers.all? do |issue_number|
begin
issue = Issue.new(issue_number)
project = Project.new(issue.project)
repo.project_allowed?(project.identifier)
rescue RestClient::ResourceNotFound
false
end
end

if !issues_valid
pull_request.labels = ['Waiting on contributor']
end
end

if repo.link_to_redmine?
pull_request.add_issue_links
end

if event_act == 'pull_request/synchronize' && pull_request.waiting_for_contributor?
if pull_request.not_yet_reviewed?
pull_request.replace_labels(['Waiting on contributor'], [])
else
pull_request.replace_labels(['Waiting on contributor'], ['Needs re-review'])
end
end

if repo.redmine_required? && (event_act == 'pull_request/opened' || event_act == 'pull_request/synchronize')
pull_request.labels = ['Waiting on contributor'] unless pull_request.valid_commits_style
end

pull_request.labels = ["Not yet reviewed"] if event_act == 'pull_request/opened'

if event_act == 'pull_request_review/submitted'
if ['rejected', 'changes_requested'].include?(payload['review']['state'])
pull_request.replace_labels(['Not yet reviewed', 'Needs re-review'], ['Waiting on contributor'])
elsif payload['review']['state'] == 'approved'
pull_request.replace_labels(['Not yet reviewed', 'Needs re-review'], [])
end
end

if pull_request.dirty?
message = <<EOM
@#{pull_request.author}, this pull request is currently not mergeable. Please rebase against the #{pull_request.target_branch} branch and push again.
Expand All @@ -91,7 +53,6 @@
---------------------------------------
This message was auto-generated by Foreman's [prprocessor](https://projects.theforeman.org/projects/foreman/wiki/PrProcessor)
EOM
pull_request.replace_labels(['Needs testing', 'Needs re-review', 'Not yet reviewed'], ['Waiting on contributor'])
pull_request.add_comment(message)
end

Expand Down