Skip to content

Commit 5ce85b3

Browse files
committed
Fallback to committer email if GitHub email is missing
1 parent 0b64500 commit 5ce85b3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

bin/notes-github-pr.rb

+17
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
require 'uri'
66
require 'tmpdir'
77
require 'json'
8+
require 'yaml'
9+
10+
# Conversion for people whose GitHub account name and SVN_ACCOUNT_NAME are different.
11+
GITHUB_TO_SVN = {
12+
'amatsuda' => 'a_matsuda',
13+
'matzbot' => 'git',
14+
'jeremyevans' => 'jeremy',
15+
'znz' => 'kazu',
16+
'k-tsj' => 'ktsj',
17+
'nurse' => 'naruse',
18+
'ioquatix' => 'samuel',
19+
'suketa' => 'suke',
20+
'unak' => 'usa',
21+
}
22+
23+
SVN_TO_EMAILS = YAML.safe_load(File.read(File.expand_path('../config/email.yml', __dir__)))
824

925
class GitHub
1026
ENDPOINT = URI.parse('https://api.github.com')
@@ -117,6 +133,7 @@ def git(*cmd, repo_path: nil)
117133
if Git.committer_name(sha) == 'GitHub' && Git.committer_email(sha) == '[email protected]'
118134
username = github.pull_request(owner: 'ruby', repo: 'ruby', number: number).fetch('merged_by').fetch('login')
119135
email = github.user(username: username).fetch('email')
136+
email ||= SVN_TO_EMAILS[GITHUB_TO_SVN.fetch(username, username)]&.first
120137
system('git', 'notes', 'append', '-m', "Merged-By: #{username}#{(" <#{email}>" if email)}", sha)
121138
updated = true
122139
end

0 commit comments

Comments
 (0)