44package app.hashers
55
66import app.Logger
7+ import app.model.Author
78import app.model.Commit
89import app.model.DiffContent
910import app.model.DiffFile
@@ -49,8 +50,8 @@ object CommitCrawler {
4950 throw Exception (" No remote default or local master branch found" )
5051 }
5152
52- fun fetchRehashesAndEmails (git : Git ):
53- Pair <LinkedList <String >, HashSet <String >> {
53+ fun fetchRehashesAndAuthors (git : Git ):
54+ Pair <LinkedList <String >, HashSet <Author >> {
5455 val head: RevCommit = RevWalk (git.repository)
5556 .parseCommit(getDefaultBranchHead(git))
5657
@@ -59,17 +60,31 @@ object CommitCrawler {
5960
6061 val commitsRehashes = LinkedList <String >()
6162 val emails = hashSetOf<String >()
63+ val names = hashMapOf<String , String >()
6264
6365 var commit: RevCommit ? = revWalk.next()
6466 while (commit != null ) {
6567 commitsRehashes.add(DigestUtils .sha256Hex(commit.name))
66- emails.add(commit.authorIdent.emailAddress)
68+ val email = commit.authorIdent.emailAddress
69+ val name = commit.authorIdent.name
70+ if (! emails.contains(email)) {
71+ emails.add(email)
72+ names.put(email, name)
73+ } else {
74+ if (name.length > names[email]!! .length) {
75+ names[email] = name
76+ }
77+ }
78+
6779 commit.disposeBody()
6880 commit = revWalk.next()
6981 }
7082 revWalk.dispose()
7183
72- return Pair (commitsRehashes, emails)
84+ val authors = emails.map { email -> Author (names[email]!! , email) }
85+ .toHashSet()
86+
87+ return Pair (commitsRehashes, authors)
7388 }
7489
7590 fun getJGitObservable (git : Git ,
0 commit comments