Skip to content

Commit

Permalink
Making RevsInPath
Browse files Browse the repository at this point in the history
  • Loading branch information
kimseokjin committed Jan 28, 2020
1 parent 1e8d589 commit 6c57df5
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
connection.project.dir=
eclipse.preferences.version=1
gradle.user.home=
java.home=
jvm.arguments=
offline.mode=false
override.workspace.settings=true
show.console.view=true
show.executions.view=true
104 changes: 104 additions & 0 deletions src/main/java/hgu/csee/isel/alinew/szz/AgSZZ.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package hgu.csee.isel.alinew.szz;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevTree;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.treewalk.filter.PathSuffixFilter;

import hgu.csee.isel.alinew.szz.model.RevsInPath;

public class AgSZZ {
private final String GIT_DIR = "/Users/kimseokjin/git/PLOP2";
//private final String FIX_COMMIT = "768b0df07b2722db926e99a8f917deeb5b55d628";

private static Git git;
private Repository repo;

public static void main(String[] args) {
new AgSZZ().run();
}

private void run() {
try {
git = Git.open(new File(GIT_DIR));
repo = git.getRepository();

List<RevCommit> commits = getCommits(git);

// TODO make RevsInPath
RevsInPath revsInPath = configureRevsInPath(repo, commits);



} catch (IOException e) {

e.printStackTrace();
}
}

private RevsInPath configureRevsInPath(Repository repo, List<RevCommit> commits) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException {
RevsInPath revsInPath = new RevsInPath();

for(RevCommit commit : commits) {
List<String> paths = new ArrayList<>();
RevTree tree = commit.getTree();

TreeWalk treeWalk = new TreeWalk(repo);
treeWalk.addTree(tree);
treeWalk.setRecursive(true);
treeWalk.setFilter(PathSuffixFilter.create(".java"));

//TEST
System.out.println("\nRev : " + commit.getName() + "\n");

while(treeWalk.next()) {
String path = treeWalk.getPathString();

//TEST
System.out.println("found: " + path);

paths.add(path);



}

//put
}

return revsInPath;
}

private List<RevCommit> getCommits(Git git) {
List<RevCommit> commits = new ArrayList<>();

Iterable<RevCommit> logs;

try {
logs = git.log().call();

for(RevCommit rev:logs) {
commits.add(rev);
}
} catch (GitAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return commits;
}

}
10 changes: 0 additions & 10 deletions src/main/java/hgu/csee/isel/alinew/szz/SZZRunner.java

This file was deleted.

10 changes: 10 additions & 0 deletions src/main/java/hgu/csee/isel/alinew/szz/model/RevsInPath.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package hgu.csee.isel.alinew.szz.model;

import java.util.HashMap;
import java.util.List;

import org.eclipse.jgit.revwalk.RevCommit;

public class RevsInPath extends HashMap<String, List<RevCommit>>{

}

0 comments on commit 6c57df5

Please sign in to comment.