Ejemplo n.º 1
0
 private Map<String, List<Integer>> getCommitsBetween(
     Map<String, List<VcsCommitInfo>> first, Map<String, List<VcsCommitInfo>> second) {
   Map<String, List<Integer>> result = new HashMap<>();
   for (String filename : first.keySet()) {
     //            System.out.println(filename+":");
     List<VcsCommitInfo> commitsFromFirst = first.get(filename);
     List<VcsCommitInfo> commitsFromSecond = second.get(filename);
     List<Integer> intervals = new ArrayList<>();
     if (commitsFromSecond == null) result.put(filename, Arrays.asList(-1));
     else {
       Iterator<VcsCommitInfo> firstIt = commitsFromFirst.iterator();
       Iterator<VcsCommitInfo> secondIt = commitsFromSecond.iterator();
       while (firstIt.hasNext() && secondIt.hasNext()) {
         VcsCommitInfo topCommit = firstIt.next();
         //                    System.out.println("top: "+topCommit);
         while (secondIt.hasNext()) {
           VcsCommitInfo bugCommit = secondIt.next();
           //                        System.out.println("bugfix: "+bugCommit);
           if (bugCommit.getDate().after(topCommit.getDate())) {
             intervals.add(
                 getNumberOfCommitsBetween(topCommit.getCommitId(), bugCommit.getCommitId()));
             break;
           }
         }
       }
       if (firstIt.hasNext() && !secondIt.hasNext()) intervals.add(-1);
     }
     result.put(filename, intervals);
   }
   return result;
 }
Ejemplo n.º 2
0
 private Map<String, List<Double>> getIntervals(
     Map<String, List<VcsCommitInfo>> first, Map<String, List<VcsCommitInfo>> second) {
   System.out.println("Processing intervals...");
   Map<String, List<Double>> result = new HashMap<>();
   for (String filename : first.keySet()) {
     //            System.out.println(filename+":");
     List<VcsCommitInfo> commitsFromFirst = first.get(filename);
     List<VcsCommitInfo> commitsFromSecond = second.get(filename);
     List<Double> intervals = new ArrayList<>();
     if (commitsFromSecond == null) result.put(filename, Arrays.asList(-1.0));
     else {
       Iterator<VcsCommitInfo> firstIt = commitsFromFirst.iterator();
       Iterator<VcsCommitInfo> secondIt = commitsFromSecond.iterator();
       while (firstIt.hasNext() && secondIt.hasNext()) {
         VcsCommitInfo topCommit = firstIt.next();
         //                    System.out.println("top: "+topCommit);
         while (secondIt.hasNext()) {
           VcsCommitInfo bugCommit = secondIt.next();
           //                        System.out.println("bugfix: "+bugCommit);
           if (bugCommit.getDate().after(topCommit.getDate())) {
             intervals.add(
                 1.0 / 86400000 * (bugCommit.getDate().getTime() - topCommit.getDate().getTime()));
             break;
           }
         }
       }
       if (firstIt.hasNext() && !secondIt.hasNext()) intervals.add(-1.0);
     }
     result.put(filename, intervals);
   }
   return result;
 }
Ejemplo n.º 3
0
 private List<Double> getBugFixTimes(String projectId, Date from, Date to) {
   List<Double> result = new ArrayList<>();
   Collection<VcsCommitInfo> commits = myVcsProvider.getHistoryChunk(projectId, from, to);
   Date start = commits.iterator().next().getDate();
   for (VcsCommitInfo commitInfo : commits) {
     if (VcsCommitInfoUtils.isRelatedToBugIssue(commitInfo)) {
       result.add(1.0 * (commitInfo.getDate().getTime() - start.getTime()) / (86400 * 1000));
     }
   }
   return result;
 }