Skip to content

Commit 0d7c910

Browse files
committed
update
1 parent 07b19c0 commit 0d7c910

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

lib/utils/DiffUtil.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,26 @@ public static List<Integer> getChangedLineNumListInOldVersion(String diffStr) {
2929
return changedLineNumList;
3030
}
3131

32-
public static Integer getChangedLineCount(String diffStr, String mode) {
32+
33+
/**
34+
* the mode can only be "add" or "delete"
35+
* @param diffStr
36+
* @param mode
37+
* @return
38+
*/
39+
public static int getChangedLineCount(String diffStr, String mode) {
3340

3441
int count = 0;
3542
String symbol = null;
36-
try {
37-
if ("delete".equals(mode)) {
38-
symbol = "-";
39-
} else if ("add".equals(mode)) {
40-
symbol = "+";
41-
} else {
42-
throw new Exception("Only have delete or add mode!");
43-
}
44-
for (String line : diffStr.split("\n")) {
45-
if (line.startsWith(symbol) && !line.startsWith("---") && !line.startsWith("+++")) {
46-
count++;
47-
}
43+
if ("delete".equals(mode)) {
44+
symbol = "-";
45+
} else if ("add".equals(mode)) {
46+
symbol = "+";
47+
}
48+
for (String line : diffStr.split("\n")) {
49+
if (line.startsWith(symbol) && !line.startsWith("---") && !line.startsWith("+++")) {
50+
count++;
4851
}
49-
} catch (Exception e) {
50-
// TODO: handle exception
51-
e.printStackTrace();
52-
return null;
5352
}
5453
return count;
5554
}

lib/utils/FileUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static boolean deleteDirectory(String dirPath) {
166166
return directoryToBeDeleted.delete();
167167
}
168168

169-
public static void copyFolder(String srcDirStr, String destDirStr) {
169+
public static void copyDirectory(String srcDirStr, String destDirStr) {
170170
File source = new File(srcDirStr);
171171
File dest = new File(destDirStr);
172172
try {

0 commit comments

Comments
 (0)