|
10 | 10 |
|
11 | 11 | public class GitUtil {
|
12 | 12 |
|
13 |
| - public static void main(String[] args) { |
14 |
| - Path repoDir = Paths.get("/data/bowen/data/PTBench-Data/data/2019/quarkusio#gizmo/raw_github"); |
15 |
| - Set<String> mergeSet = new HashSet<>(); |
16 |
| - Set<String> bugComs = new HashSet<String>(getComsWithSingleWordMatch(repoDir, "bug")); |
17 |
| - System.out.println("# bug coms " + String.valueOf(bugComs.size())); |
18 |
| - mergeSet.addAll(bugComs); |
19 |
| - Set<String> BugComs = new HashSet<String>(getComsWithSingleWordMatch(repoDir, "Bug")); |
20 |
| - System.out.println("# Bug coms " + String.valueOf(BugComs.size())); |
21 |
| - mergeSet.addAll(BugComs); |
22 |
| - Set<String> fixComs = new HashSet<String>(getComsWithSingleWordMatch(repoDir, "fix")); |
23 |
| - System.out.println("# fix coms " + String.valueOf(fixComs.size())); |
24 |
| - mergeSet.addAll(fixComs); |
25 |
| - Set<String> FixComs = new HashSet<String>(getComsWithSingleWordMatch(repoDir, "Fix")); |
26 |
| - System.out.println("# Fix coms " + String.valueOf(FixComs.size())); |
27 |
| - mergeSet.addAll(FixComs); |
28 |
| - System.out.println("# merge coms " + String.valueOf(mergeSet.size())); |
29 |
| - } |
30 |
| - |
31 | 13 | public static Boolean clone(String repoName, String usrName, Path targetDir) {
|
32 | 14 |
|
33 | 15 | if (targetDir.toFile().exists()) {
|
@@ -85,6 +67,24 @@ public static List<String> getComsWithSingleWordMatch(Path repoDir, String word)
|
85 | 67 | }
|
86 | 68 | }
|
87 | 69 |
|
| 70 | + public static String getDiff4SingleFileNCommit(Path repoDir, String parCom, String curCom, String oldRelFilePath, |
| 71 | + String newRelFilePath) { |
| 72 | + |
| 73 | + String cmd = "timeout 300 git --no-pager diff --unified=0 " + parCom + ":" + oldRelFilePath + " " + curCom + ":" |
| 74 | + + newRelFilePath; |
| 75 | + |
| 76 | + ProcessUtil.ProcessReporter pr = ProcessUtil.executeCMD(cmd, null, repoDir, 0); |
| 77 | + if (pr.exitCode == 0) { |
| 78 | + return pr.out.trim(); |
| 79 | + } else { |
| 80 | + FileUtil.writeStr2File(pr.out, Paths.get(repoDir.toString(), "getDiff4SingleFileNCommit.txt")); |
| 81 | + FileUtil.writeStr2File(pr.err, Paths.get(repoDir.toString(), "getDiff4SingleFileNCommit.txt")); |
| 82 | + // System.out.println("cmd " + cmd + "\n"); |
| 83 | + // System.out.println("report \n" + pr.toString()); |
| 84 | + return null; |
| 85 | + } |
| 86 | + } |
| 87 | + |
88 | 88 | public static String getCommitMsg(Path repoDir, String com) {
|
89 | 89 |
|
90 | 90 | String cmd = "timeout 300 git log --format=%B -n 1 " + com;
|
|
0 commit comments