浏览代码

Fix mixed case names and emails

Vadim Markovtsev 7 年之前
父节点
当前提交
e3705de41d
共有 2 个文件被更改,包括 17 次插入14 次删除
  1. 3 2
      analyser.go
  2. 14 12
      cmd/hercules/main.go

+ 3 - 2
analyser.go

@@ -8,6 +8,7 @@ import (
 	"io"
 	"os"
 	"sort"
+	"strings"
 	"time"
 	"unicode/utf8"
 
@@ -223,9 +224,9 @@ func (analyser *Analyser) newFile(
 }
 
 func (analyser *Analyser) getAuthorId(signature object.Signature) int {
-	id, exists := analyser.PeopleDict[signature.Email]
+	id, exists := analyser.PeopleDict[strings.ToLower(signature.Email)]
 	if !exists {
-		id, exists = analyser.PeopleDict[signature.Name]
+		id, exists = analyser.PeopleDict[strings.ToLower(signature.Name)]
 		if !exists {
 			id = MISSING_AUTHOR
 		}

+ 14 - 12
cmd/hercules/main.go

@@ -47,7 +47,7 @@ func loadPeopleDict(path string) (map[string]int, map[int]string, int) {
 	reverse_dict := make(map[int]string)
 	size := 0
 	for scanner.Scan() {
-		for _, id := range strings.Split(scanner.Text(), "|") {
+		for _, id := range strings.Split(strings.ToLower(scanner.Text()), "|") {
 			dict[id] = size
 		}
 		reverse_dict[size] = scanner.Text()
@@ -62,25 +62,27 @@ func generatePeopleDict(commits []*object.Commit) (map[string]int, map[int]strin
 	names := make(map[int][]string)
 	size := 0
 	for _, commit := range commits {
-		id, exists := dict[commit.Author.Email]
+		email := strings.ToLower(commit.Author.Email)
+		name := strings.ToLower(commit.Author.Name)
+		id, exists := dict[email]
 		if exists {
-			_, exists := dict[commit.Author.Name]
+			_, exists := dict[name]
 			if !exists {
-				dict[commit.Author.Name] = id
-			  names[id] = append(names[id], commit.Author.Name)
+				dict[name] = id
+			  names[id] = append(names[id], name)
 			}
 			continue
 		}
-		id, exists = dict[commit.Author.Name]
+		id, exists = dict[name]
 		if exists {
-			dict[commit.Author.Email] = id
-			emails[id] = append(emails[id], commit.Author.Email)
+			dict[email] = id
+			emails[id] = append(emails[id], email)
 			continue
 		}
-		dict[commit.Author.Email] = size
-		dict[commit.Author.Name] = size
-		emails[size] = append(emails[size], commit.Author.Email)
-		names[size] = append(names[size], commit.Author.Name)
+		dict[email] = size
+		dict[name] = size
+		emails[size] = append(emails[size], email)
+		names[size] = append(names[size], name)
 		size += 1
 	}
 	reverse_dict := make(map[int]string)