8
8
public class GitUtil {
9
9
10
10
public static Boolean clone (String repoName , String usrName , Path targetDir ) {
11
-
12
- if (targetDir .toFile ().exists ()){
11
+
12
+ if (targetDir .toFile ().exists ()) {
13
13
FileUtil .deleteDirectory (targetDir .toFile ());
14
14
}
15
15
targetDir .toFile ().mkdirs ();
16
16
17
17
String cmd = "timeout 300 git clone https://github.com/" + repoName + "/" + usrName + " " + targetDir ;
18
-
19
- ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , targetDir );
18
+
19
+ ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , targetDir , 0 );
20
20
if (pr .exitCode == 0 ) {
21
21
return true ;
22
22
} else {
@@ -31,7 +31,7 @@ public static List<String> getAllCommitsSha(Path repoDir) {
31
31
32
32
String cmd = "timeout 60 git log --pretty=format:\" %H\" " ;
33
33
34
- ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , repoDir );
34
+ ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , repoDir , 0 );
35
35
if (pr .exitCode == 0 ) {
36
36
return Arrays .asList (pr .out .replace ("\" " , "" ).split ("\n " ));
37
37
} else {
@@ -45,7 +45,7 @@ public static String getCommitMsg(Path repoDir, String com) {
45
45
46
46
String cmd = "timeout 60 git log --format=%B -n 1 " + com ;
47
47
48
- ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , repoDir );
48
+ ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , repoDir , 0 );
49
49
if (pr .exitCode == 0 ) {
50
50
return pr .out .trim ();
51
51
} else {
@@ -59,7 +59,7 @@ public static String getParentCommit(Path repoDir, String com) {
59
59
60
60
String cmd = "timeout 60 git log --pretty=%P -n 1 " + com ;
61
61
62
- ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , repoDir );
62
+ ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , repoDir , 0 );
63
63
if (pr .exitCode == 0 ) {
64
64
return pr .out .replace ("\" " , "" ).trim ();
65
65
} else {
@@ -81,14 +81,14 @@ public static String getDiffBetween2Commits(Path repoDir, String oldCom, String
81
81
82
82
String cmd = null ;
83
83
if (diffMode != null ) {
84
- cmd = "timeout 60 git --git-dir " + repoDir .toString () + " /.git --work-tree " + repoDir .toString () + " diff "
85
- + diffMode + " --unified=0 " + oldCom + " " + newCom ;
84
+ cmd = "timeout 60 git --git-dir " + repoDir .toString () + " /.git --work-tree " + repoDir .toString ()
85
+ + " diff " + diffMode + " --unified=0 " + oldCom + " " + newCom ;
86
86
} else {
87
87
cmd = "timeout 60 git --git-dir " + repoDir .toString () + " /.git --work-tree " + repoDir .toString ()
88
88
+ " diff --unified=0 " + oldCom + " " + newCom ;
89
89
}
90
90
91
- ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , repoDir );
91
+ ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , repoDir , 0 );
92
92
if (pr .exitCode == 0 ) {
93
93
return pr .out .trim ();
94
94
} else {
@@ -102,7 +102,7 @@ public static List<String> getChangedFileList(Path repoDir, String com) {
102
102
103
103
String cmd = "timeout 30 git diff-tree --no-commit-id --name-only -r " + com ;
104
104
105
- ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , repoDir );
105
+ ProcessUtil .ProcessReporter pr = ProcessUtil .executeCMD (cmd , null , repoDir , 0 );
106
106
if (pr .exitCode == 0 ) {
107
107
return Arrays .asList (pr .out .split ("\n " ));
108
108
} else {
@@ -118,7 +118,7 @@ public static Boolean checkout(Path repoDir, String com, Boolean ifForce) {
118
118
119
119
if (ifForce ) {
120
120
String resetCMD = "timeout 60 git reset --hard" ;
121
- pr = ProcessUtil .executeCMD (resetCMD , null , repoDir );
121
+ pr = ProcessUtil .executeCMD (resetCMD , null , repoDir , 0 );
122
122
}
123
123
124
124
String checkoutCMD = null ;
@@ -127,18 +127,18 @@ public static Boolean checkout(Path repoDir, String com, Boolean ifForce) {
127
127
} else {
128
128
checkoutCMD = "timeout 60 git checkout " + com ;
129
129
}
130
- pr = ProcessUtil .executeCMD (checkoutCMD , null , repoDir );
130
+ pr = ProcessUtil .executeCMD (checkoutCMD , null , repoDir , 0 );
131
131
132
132
if (pr .exitCode == 0 ) {
133
133
return true ;
134
134
} else {
135
- String cleanCMD = "timeout 60 git --git-dir " + repoDir .toString () + " /.git --work-tree " + repoDir . toString ()
136
- + " clean -dfx ." ;
137
- pr = ProcessUtil .executeCMD (cleanCMD , null , repoDir );
138
- String resetCMD = "timeout 60 git --git-dir " + repoDir .toString () + " /.git --work-tree " + repoDir . toString ()
139
- + " reset --hard" ;
140
- pr = ProcessUtil .executeCMD (resetCMD , null , repoDir );
141
- pr = ProcessUtil .executeCMD (checkoutCMD , null , repoDir );
135
+ String cleanCMD = "timeout 60 git --git-dir " + repoDir .toString () + " /.git --work-tree "
136
+ + repoDir . toString () + " clean -dfx ." ;
137
+ pr = ProcessUtil .executeCMD (cleanCMD , null , repoDir , 0 );
138
+ String resetCMD = "timeout 60 git --git-dir " + repoDir .toString () + " /.git --work-tree "
139
+ + repoDir . toString () + " reset --hard" ;
140
+ pr = ProcessUtil .executeCMD (resetCMD , null , repoDir , 0 );
141
+ pr = ProcessUtil .executeCMD (checkoutCMD , null , repoDir , 0 );
142
142
if (pr .exitCode == 0 ) {
143
143
return true ;
144
144
} else {
0 commit comments