Search in sources :

Example 11 with LogCommitInfo

use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.

the class NewAliasHandler method execute.

public Map<String, LogCommitInfo> execute(String repositoryName, Map<String, LogCommitInfo> commits) {
    setUsername(commits);
    devUsernameMap = new HashMap<String, List<LogCommitInfo>>();
    for (LogCommitInfo commit : commits.values()) {
        String commitUsername = commit.getUserName();
        if (!devUsernameMap.containsKey(commitUsername))
            devUsernameMap.put(commitUsername, new ArrayList<LogCommitInfo>());
        devUsernameMap.get(commitUsername).add(commit);
    }
    //Set<String> devNames = new HashSet<String>();
    devNameMap = new HashMap<String, List<LogCommitInfo>>();
    for (LogCommitInfo commit : commits.values()) {
        //devNames.add(commit.getMainName());
        String commitDevName = commit.getNormMainName();
        if (!devNameMap.containsKey(commitDevName))
            devNameMap.put(commitDevName, new ArrayList<LogCommitInfo>());
        devNameMap.get(commitDevName).add(commit);
    }
    unifyUsernameByName();
    if (fileAliases != null)
        treatFileAlias();
    return commits;
}
Also used : LogCommitInfo(aserg.gtf.model.LogCommitInfo) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) List(java.util.List) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 12 with LogCommitInfo

use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.

the class NewAliasHandler method treatFileAlias.

private void treatFileAlias() {
    for (LineInfo info : fileAliases) {
        String rep = info.getRepositoryName();
        String dev1 = info.getValues().get(0);
        String dev2 = info.getValues().get(1);
        String usernameDev1 = devNameMap.get(dev1.toUpperCase()).get(0).getUserName();
        String usernameDev2 = devNameMap.get(dev2.toUpperCase()).get(0).getUserName();
        String newUsername = usernameDev1.contains(usernameDev2) ? usernameDev1 : (usernameDev2.contains(usernameDev1) ? usernameDev2 : usernameDev1 + "$$" + usernameDev2);
        for (LogCommitInfo commit : devUsernameMap.get(usernameDev1)) {
            if (!commit.getUserName().equals(usernameDev2)) {
                setNewUsername(commit, newUsername);
            //commit.setUserName(newUsername);					
            }
        }
        for (LogCommitInfo commit : devUsernameMap.get(usernameDev2)) {
            if (!commit.getUserName().equals(usernameDev1)) {
                setNewUsername(commit, newUsername);
            //commit.setUserName(newUsername);					
            }
        }
    }
}
Also used : LogCommitInfo(aserg.gtf.model.LogCommitInfo) LineInfo(aserg.gtf.util.LineInfo)

Example 13 with LogCommitInfo

use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.

the class NewAliasHandler 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);
        }
    }
}
Also used : LogCommitInfo(aserg.gtf.model.LogCommitInfo) List(java.util.List) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 14 with LogCommitInfo

use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.

the class GitLogExtractor method execute.

public Map<String, LogCommitInfo> execute() throws Exception {
    Map<String, LogCommitInfo> mapCommits = new HashMap<String, LogCommitInfo>();
    int countcfs = 0;
    try {
        LOGGER.info("Extracting logCommits...  " + repositoryPath);
        BufferedReader br = new BufferedReader(new FileReader(repositoryPath + fileName));
        String sCurrentLine;
        String[] values;
        while ((sCurrentLine = br.readLine()) != null) {
            values = sCurrentLine.split(";");
            if (values.length < 7)
                LOGGER.error("Problem in line  " + countcfs + ". Too much columns.");
            Date authorDate = !values[3].isEmpty() ? new Timestamp(Long.parseLong(values[3]) * 1000L) : null;
            Date commiterDate = !values[6].isEmpty() ? new Timestamp(Long.parseLong(values[6]) * 1000L) : null;
            String msg = (values.length == 8) ? values[7] : "";
            mapCommits.put(values[0], new LogCommitInfo(repositoryName, values[0], values[1], values[2], authorDate, values[4], values[5], commiterDate, msg));
            countcfs++;
        }
        insertFiles(repositoryName, mapCommits);
        br.close();
    } catch (FileNotFoundException e) {
        throw new Exception("File not found: " + repositoryPath + fileName, e);
    } catch (Exception e) {
        throw new Exception(String.format("Error in file %s, line %d%", repositoryName, countcfs));
    }
    return mapCommits;
}
Also used : HashMap(java.util.HashMap) LogCommitInfo(aserg.gtf.model.LogCommitInfo) BufferedReader(java.io.BufferedReader) FileNotFoundException(java.io.FileNotFoundException) FileReader(java.io.FileReader) Timestamp(java.sql.Timestamp) Date(java.util.Date) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 15 with LogCommitInfo

use of aserg.gtf.model.LogCommitInfo in project Truck-Factor by aserg-ufmg.

the class AliasHandler 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;
}
Also used : LogCommitInfo(aserg.gtf.model.LogCommitInfo) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) HashSet(java.util.HashSet)

Aggregations

LogCommitInfo (aserg.gtf.model.LogCommitInfo)16 ArrayList (java.util.ArrayList)7 List (java.util.List)6 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)6 LogCommitFileInfo (aserg.gtf.model.LogCommitFileInfo)3 NewFileInfo (aserg.gtf.model.NewFileInfo)3 Repository (aserg.gtf.model.authorship.Repository)3 DOACalculator (aserg.gtf.task.DOACalculator)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 GreedyTruckFactor (aserg.gtf.truckfactor.GreedyTruckFactor)2 TFInfo (aserg.gtf.truckfactor.TFInfo)2 TruckFactor (aserg.gtf.truckfactor.TruckFactor)2 LineInfo (aserg.gtf.util.LineInfo)2 BufferedReader (java.io.BufferedReader)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 Date (java.util.Date)2 Status (aserg.gtf.model.Status)1 AuthorshipInfo (aserg.gtf.model.authorship.AuthorshipInfo)1