use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.
the class AliasHandler method unifyUsernameByEmail.
/** Treat different names for the same e-mail case */
private void unifyUsernameByEmail(Map<String, List<LogCommitInfo>> usernameMap) {
for (Entry<String, List<LogCommitInfo>> entry : usernameMap.entrySet()) {
List<String> names = getNamesList(entry.getValue());
String newUserName = names.get(0);
if (names.size() > 1)
newUserName = getNewName(names);
for (LogCommitInfo commit : entry.getValue()) {
commit.setUserName(newUserName);
}
}
}
use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.
the class AliasHandler method execute.
public Map<String, LogCommitInfo> execute(String repositoryName, Map<String, LogCommitInfo> commits) {
Map<String, List<LogCommitInfo>> usernameMap = new HashMap<String, List<LogCommitInfo>>();
Set<String> devNames = new HashSet<String>();
for (LogCommitInfo commit : commits.values()) {
String commitUsername = commit.getUserName();
if (!usernameMap.containsKey(commitUsername))
usernameMap.put(commitUsername, new ArrayList<LogCommitInfo>());
usernameMap.get(commitUsername).add(commit);
}
unifyUsernameByEmail(usernameMap);
Map<String, List<LogCommitInfo>> namesMap = new HashMap<String, List<LogCommitInfo>>();
for (LogCommitInfo commit : commits.values()) {
devNames.add(commit.getMainName());
String commitDevName = commit.getNormMainName();
if (!namesMap.containsKey(commitDevName))
namesMap.put(commitDevName, new ArrayList<LogCommitInfo>());
namesMap.get(commitDevName).add(commit);
}
unifyUsernameByName(namesMap);
//printAliases(aliases);
return commits;
}
use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.
the class DOACalculator method setFileHistory.
private static boolean setFileHistory(File file, Repository repository, NewFileInfo fileInfo, Map<String, List<LogCommitFileInfo>> mapFiles) {
List<LogCommitFileInfo> fileCommits = mapFiles.get(fileInfo.getPath());
// Rarely, but some files do not have any commit. Should be verified each case to understand the impact. Normally is irrelevant.
if (fileCommits == null) {
LOGGER.warn("No commits for " + file);
return false;
}
List<LogCommitFileInfo> logFilesObjectInfo = expandCommitFileList(fileCommits, mapFiles);
String firstAuthor = null;
for (LogCommitFileInfo commitFile : logFilesObjectInfo) {
//ci.name, ci.email, lcfi.oldfilename, lcfi.newfilename, lcfi.status, lcfi.id, username
LogCommitInfo commitInfo = commitFile.getCommitInfo();
AuthorshipInfo authorshipInfo = repository.getAuthorshipInfo(commitInfo.getAuthorName(), commitInfo.getAuthorEmail(), commitInfo.getUserName(), file);
Status status = commitFile.getStatus();
if (status == Status.ADDED) {
if (firstAuthor == null) {
//FIRST ADD
firstAuthor = authorshipInfo.getDeveloper().getNewUserName();
authorshipInfo.setAsFirstAuthor();
} else if (!authorshipInfo.isFirstAuthor()) {
//New ADD made by a different developer of the first add
String debugStr = String.format("New add;%s;%s;%s;%s", repository.getFullName(), file.getPath(), firstAuthor, authorshipInfo.getDeveloper().getNewUserName());
LOGGER.debug(debugStr);
authorshipInfo.setAsSecondaryAuthor();
authorshipInfo.addNewAddDelivery();
} else {
//Treat as delivery if the extra add was made by the first author
authorshipInfo.addNewAddDelivery();
}
} else if (status == Status.MODIFIED) {
authorshipInfo.addNewDelivery();
//file.addNewChange();
} else if (status == Status.RENAMED_TREATED) {
// Considering a rename as a new delivery
authorshipInfo.addNewDelivery();
//file.addNewChange();
} else
System.err.println("Invalid Status: " + status);
}
double bestDoaValue = 0;
for (AuthorshipInfo authorshipInfo : file.getAuthorshipInfos()) {
double authorshipDoa = authorshipInfo.getDOA();
if (authorshipDoa > bestDoaValue) {
bestDoaValue = authorshipDoa;
file.setBestAuthorshipInfo(authorshipInfo);
}
}
double bestDoaValueMult = 0;
for (AuthorshipInfo authorshipInfo : file.getAuthorshipInfos()) {
double authorshipDoaMult = authorshipInfo.getDoaMultAuthor();
if (authorshipDoaMult > bestDoaValueMult) {
bestDoaValueMult = authorshipDoaMult;
file.setBestAuthorshipInfoMult(authorshipInfo);
}
}
double bestDoaValueAddDeliveries = 0;
for (AuthorshipInfo authorshipInfo : file.getAuthorshipInfos()) {
double authorshipDoaAddDeliveries = authorshipInfo.getDoaAddDeliveries();
if (authorshipDoaAddDeliveries > bestDoaValueAddDeliveries) {
bestDoaValueAddDeliveries = authorshipDoaAddDeliveries;
file.setBestAuthorshipAddDeliveries(authorshipInfo);
}
}
return true;
}
use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.
the class NewAliasHandler method getNamesList.
private List<String> getNamesList(Collection<LogCommitInfo> commits) {
HashSet<String> nameSet = new HashSet<String>();
List<String> names = new ArrayList<String>();
for (LogCommitInfo commit : commits) {
String simplifyedName = commit.getNormMainName().replace(" ", "");
if (!nameSet.contains(simplifyedName)) {
nameSet.add(simplifyedName);
names.add(commit.getMainName());
}
}
return names;
}
use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.
the class NewAliasHandler method setNewUsername.
private void setNewUsername(LogCommitInfo commit, String newUsername) {
List<LogCommitInfo> listCommits = devUsernameMap.get(commit.getUserName());
devUsernameMap.remove(commit.getUserName());
for (LogCommitInfo commitAux : listCommits) {
commitAux.setUserName(newUsername);
}
if (!devUsernameMap.containsKey(newUsername))
devUsernameMap.put(newUsername, listCommits);
else
devUsernameMap.get(newUsername).addAll(listCommits);
}
Aggregations