@@ -58,9 +58,10 @@ def commit(argv)
58
58
end
59
59
60
60
config = read_pairs_config
61
- author_names , email_ids = extract_author_names_and_email_ids_from_config ( config , current_pair_initials )
61
+ author_details = extract_author_details_from_config ( config , current_pair_initials )
62
+ author_names = author_details . keys . map { |i | author_details [ i ] [ :name ] }
62
63
authors = pair_names ( author_names )
63
- author_email = random_author_email ( email_ids , config [ 'email' ] )
64
+ author_email = random_author_email ( author_details )
64
65
puts "Committing under #{ author_email } "
65
66
passthrough_args = argv . map { |arg | "'#{ arg } '" } . join ( ' ' )
66
67
env_variables = "GIT_AUTHOR_NAME='#{ authors } ' GIT_AUTHOR_EMAIL='#{ author_email } ' GIT_COMMITTER_NAME='#{ authors } ' GIT_COMMITTER_EMAIL='#{ author_email } '"
@@ -103,6 +104,9 @@ def parse_cli_options(argv)
103
104
domain: pivotallabs.com
104
105
# no_solo_prefix: true
105
106
#global: true
107
+ # include the following section to set custom email addresses for users
108
+ #email_addresses:
109
+ # zr: zach.robinson@example.com
106
110
107
111
108
112
By default this affects the current project (.git/config).<br/>
@@ -168,9 +172,9 @@ def build_email(emails, config)
168
172
end
169
173
end
170
174
171
- def random_author_email ( email_ids , config )
172
- author_id = email_ids . sample
173
- " #{ author_id } @ #{ config [ 'domain' ] } "
175
+ def random_author_email ( author_details )
176
+ author_id = author_details . keys . sample
177
+ author_details [ author_id ] [ :email ]
174
178
end
175
179
176
180
def set_git_config ( global , options )
@@ -205,6 +209,32 @@ def no_email(config)
205
209
!config . key? 'email'
206
210
end
207
211
212
+ def extract_author_details_from_config ( config , initials )
213
+ details = { }
214
+
215
+ initials . each do |i |
216
+ info = read_author_info_from_config ( config , [ i ] ) . first
217
+
218
+ full_name , email_id = info . split ( ";" ) . map ( &:strip )
219
+ email_id ||= full_name . split ( ' ' ) . first . downcase
220
+
221
+ email = read_custom_email_address_from_config ( config , i )
222
+ email ||= "#{ email_id } @#{ config [ 'email' ] [ 'domain' ] } "
223
+
224
+ details [ i ] = {
225
+ :name => full_name ,
226
+ :email => email
227
+ }
228
+ end
229
+
230
+ details
231
+ end
232
+
233
+ def read_custom_email_address_from_config ( config , initial )
234
+ return nil unless config [ 'email_addresses' ]
235
+ return config [ 'email_addresses' ] [ initial . downcase ]
236
+ end
237
+
208
238
private
209
239
210
240
def pair_names ( author_names )
0 commit comments