5
5
6
6
7
7
class InactiveMemberSearch
8
- attr_accessor :organization , :members , :repositories , :date
8
+ attr_accessor :organization , :members , :repositories , :date , :unrecognized_authors
9
9
10
10
SCOPES = [ "read:org" , "read:user" , "repo" , "user:email" ]
11
11
@@ -26,6 +26,7 @@ def initialize(options={})
26
26
@date = options [ :date ]
27
27
@organization = options [ :organization ]
28
28
@email = options [ :email ]
29
+ @unrecognized_authors = [ ]
29
30
30
31
organization_members
31
32
organization_repositories
@@ -101,6 +102,10 @@ def organization_repositories
101
102
info "#{ @repositories . length } repositories discovered\n "
102
103
end
103
104
105
+ def add_unrecognized_author ( author )
106
+ @unrecognized_authors << author
107
+ end
108
+
104
109
# method to switch member status to active
105
110
def make_active ( login )
106
111
hsh = @members . find { |member | member [ :login ] == login }
@@ -112,6 +117,10 @@ def commit_activity(repo)
112
117
info "...commits"
113
118
@client . commits_since ( repo , @date ) . each do |commit |
114
119
# if commmitter is a member of the org and not active, make active
120
+ if commit [ "author" ] . nil?
121
+ add_unrecognized_author ( commit [ :commit ] [ :author ] )
122
+ next
123
+ end
115
124
if t = @members . find { |member | member [ :login ] == commit [ "author" ] [ "login" ] && member [ :active ] == false }
116
125
make_active ( t [ :login ] )
117
126
end
@@ -188,12 +197,20 @@ def member_activity
188
197
# iterate and print inactive members
189
198
@members . each do |member |
190
199
if member [ :active ] == false
191
- member_detail = "#{ member [ :login ] } < #{ member [ :email ] unless member [ :email ] . nil? } > "
200
+ member_detail = "#{ member [ :login ] } , #{ member [ :email ] unless member [ :email ] . nil? } "
192
201
info "#{ member_detail } is inactive\n "
193
202
csv << [ member_detail ]
194
203
end
195
204
end
196
205
end
206
+
207
+ CSV . open ( "unrecognized_authors.csv" , "wb" ) do |csv |
208
+ @unrecognized_authors . each do |author |
209
+ author_detail = "#{ author [ :name ] } ,#{ author [ :email ] } "
210
+ info "#{ author_detail } is unrecognized\n "
211
+ csv << [ author_detail ]
212
+ end
213
+ end
197
214
end
198
215
end
199
216
0 commit comments