Skip to content

Commit b7dd592

Browse files
authored
fix(github_hooks): return null if commit author is nil (#195)
1 parent 2da8239 commit b7dd592

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

github_hooks/lib/repo_host/bitbucket/payload.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ def head_commit_message
9797

9898
# ✔️
9999
def commit_author
100-
if @commits.present? && @commits.last.present?
101-
@commits.last["author"]["user"]["nickname"]
102-
end
100+
@commits.last&.dig("author", "user", "nickname") || ""
103101
end
104102

105103
# ✔️

github_hooks/spec/lib/repo_host/bitbucket/payload_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ def build_payload(string)
115115
expect(payload_for_branch_deletion.author_email).to eq ""
116116
expect(payload_for_new_branch_with_new_commits.author_email).to eq ""
117117
expect(payload_for_new_branch_without_new_commits.author_email).to eq ""
118+
expect(payload_for_branch_deletion.commit_author).to eq ""
119+
expect(payload_for_new_branch_with_new_commits.commit_author).to eq "milana_stojadinov"
120+
expect(payload_for_new_branch_without_new_commits.commit_author).to eq "milana_stojadinov"
118121
end
119122
end
120123

0 commit comments

Comments
 (0)