Skip to content

Commit

Permalink
Change key and value
Browse files Browse the repository at this point in the history
  • Loading branch information
yoon committed Jan 28, 2020
1 parent 6c57df5 commit 9b2b71e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 34 deletions.
15 changes: 1 addition & 14 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,14 @@
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/main" path="src/main/resources">
<attributes>
<attribute name="gradle_scope" value="main"/>
<attribute name="gradle_used_by_scope" value="main,test"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/java">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="bin/test" path="src/test/resources">
<attributes>
<attribute name="gradle_scope" value="test"/>
<attribute name="gradle_used_by_scope" value="test"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-13/"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-12/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>
11 changes: 0 additions & 11 deletions .settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -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
32 changes: 23 additions & 9 deletions src/main/java/hgu/csee/isel/alinew/szz/AgSZZ.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -51,9 +53,10 @@ private void run() {

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

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

TreeWalk treeWalk = new TreeWalk(repo);
Expand All @@ -62,21 +65,32 @@ private RevsInPath configureRevsInPath(Repository repo, List<RevCommit> 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<RevCommit> lst = revsInPath.get(pr.getPath());
lst.add(pr.getCommit());
revsInPath.replace(pr.getPath(), lst);
}else{
List<RevCommit> lst = new ArrayList<>();
lst.add(pr.getCommit());
revsInPath.put(pr.getPath(), lst);
}
}



}

return revsInPath;
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/hgu/csee/isel/alinew/szz/model/PathRevision.java
Original file line number Diff line number Diff line change
@@ -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;
}

}

0 comments on commit 9b2b71e

Please sign in to comment.