Skip to content

Commit 4bc6e94

Browse files
committed
Fix: gracefully ignore unverified commits when choosing deploy assignee
1 parent 8e8073c commit 4bc6e94

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/services/deploy_service.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def choose_assignee(pull_request)
9999
github_client
100100
.pull_request_commits(github_repo, pull_request.number)
101101
.flat_map { |c| [c.author, c.committer] }
102-
.reject { |c| c.type == 'Bot' || c.login == 'web-flow' || c.login == 'artsyit' || c.login[/\bbot\b/] }
102+
.reject { |c| c.nil? || c.type == 'Bot' || c.login == 'web-flow' || c.login == 'artsyit' || c.login[/\bbot\b/] }
103103
.group_by(&:login).map { |k, v| [v.size, k] }.sort.reverse.map(&:last)
104104
.detect { |l| github_client.check_assignee(github_repo, l) }
105105
end

spec/features/deploy_spec.rb

+15
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@
7979
DeployService.new(strategy).start
8080
end
8181

82+
it 'handles unsigned commits' do
83+
expect_any_instance_of(Octokit::Client).to receive(:create_pull_request)
84+
.with('artsy/candela', 'release', 'staging', anything, anything)
85+
.and_return(github_pull_request)
86+
allow_any_instance_of(Octokit::Client).to receive(:pull_request_commits)
87+
.with('artsy/candela', 42)
88+
.and_return([
89+
double(author: nil, committer: renovate),
90+
double(author: jane, committer: web_flow)
91+
])
92+
expect_any_instance_of(Octokit::Client).to receive(:check_assignee).and_return(true)
93+
expect_any_instance_of(Octokit::Client).to receive(:add_assignees).with('artsy/candela', 42, 'jane')
94+
DeployService.new(strategy).start
95+
end
96+
8297
it 'adds assignees to existing deploy PRs when unassigned' do
8398
expect_any_instance_of(Octokit::Client).to receive(:create_pull_request)
8499
.with('artsy/candela', 'release', 'staging', anything, anything)

0 commit comments

Comments
 (0)