diff --git a/.classpath b/.classpath index ea80fa8..736f5a7 100644 --- a/.classpath +++ b/.classpath @@ -6,12 +6,6 @@ - - - - - - @@ -19,14 +13,7 @@ - - - - - - - - + diff --git a/.settings/org.eclipse.buildship.core.prefs b/.settings/org.eclipse.buildship.core.prefs index 98b2934..e889521 100644 --- a/.settings/org.eclipse.buildship.core.prefs +++ b/.settings/org.eclipse.buildship.core.prefs @@ -1,13 +1,2 @@ -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 diff --git a/src/main/java/hgu/csee/isel/alinew/szz/AgSZZ.java b/src/main/java/hgu/csee/isel/alinew/szz/AgSZZ.java index 56661f5..9a2d13d 100644 --- a/src/main/java/hgu/csee/isel/alinew/szz/AgSZZ.java +++ b/src/main/java/hgu/csee/isel/alinew/szz/AgSZZ.java @@ -19,14 +19,16 @@ import org.eclipse.jgit.treewalk.filter.PathSuffixFilter; import hgu.csee.isel.alinew.szz.model.RevsInPath; +import hgu.csee.isel.alinew.szz.model.PathRevision; public class AgSZZ { - private final String GIT_DIR = "/Users/kimseokjin/git/PLOP2"; + private final String GIT_DIR = "/Users/yoon/git/BugPatchCollector"; //private final String FIX_COMMIT = "768b0df07b2722db926e99a8f917deeb5b55d628"; private static Git git; private Repository repo; + public static void main(String[] args) { new AgSZZ().run(); } @@ -51,9 +53,10 @@ private void run() { private RevsInPath configureRevsInPath(Repository repo, List commits) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { RevsInPath revsInPath = new RevsInPath(); + List paths = new ArrayList<>(); for(RevCommit commit : commits) { - List paths = new ArrayList<>(); +// List paths = new ArrayList<>(); RevTree tree = commit.getTree(); TreeWalk treeWalk = new TreeWalk(repo); @@ -62,21 +65,32 @@ private RevsInPath configureRevsInPath(Repository repo, List commits) treeWalk.setFilter(PathSuffixFilter.create(".java")); //TEST - System.out.println("\nRev : " + commit.getName() + "\n"); +// System.out.println("\nRev : " + commit.getName() + "\n"); + while(treeWalk.next()) { String path = treeWalk.getPathString(); //TEST - System.out.println("found: " + path); - - paths.add(path); - - +// System.out.println("found: " + path); + paths.add(new PathRevision(path, commit)); } - //put + for(PathRevision pr : paths) { + if(revsInPath.containsKey(pr.getPath())) { + List lst = revsInPath.get(pr.getPath()); + lst.add(pr.getCommit()); + revsInPath.replace(pr.getPath(), lst); + }else{ + List lst = new ArrayList<>(); + lst.add(pr.getCommit()); + revsInPath.put(pr.getPath(), lst); + } + } + + + } return revsInPath; diff --git a/src/main/java/hgu/csee/isel/alinew/szz/model/PathRevision.java b/src/main/java/hgu/csee/isel/alinew/szz/model/PathRevision.java new file mode 100644 index 0000000..b0d4a1b --- /dev/null +++ b/src/main/java/hgu/csee/isel/alinew/szz/model/PathRevision.java @@ -0,0 +1,28 @@ +package hgu.csee.isel.alinew.szz.model; + +import org.eclipse.jgit.revwalk.RevCommit; + +public class PathRevision { + private String path; + private RevCommit commit; + + public PathRevision(String path, RevCommit commit) { + super(); + this.path = path; + this.commit = commit; + } + + public String getPath() { + return path; + } + public void setPath(String path) { + this.path = path; + } + public RevCommit getCommit() { + return commit; + } + public void setCommit(RevCommit commit) { + this.commit = commit; + } + +}