Skip to content

Commit 95f63d3

Browse files
committed
update from sydi
1 parent f54b2f1 commit 95f63d3

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

Diff for: lib/utils/DiffUtil.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,10 @@ public static Integer getChangedLineCount(String diffStr, String mode) {
5454
return count;
5555
}
5656

57-
public static List<Integer> getChangedLineNumListInNewVersion(String diffFilePath) {
58-
57+
public static List<Integer> getChangedLineNumListInNewVersion(String diffStr) {
5958
List<Integer> changedLineNumList = new ArrayList<>();
6059
try {
61-
List<String> diffFileStrList = FileUtil.readFileToLineList(diffFilePath);
62-
for (String line : diffFileStrList) {
60+
for (String line : diffStr.split("\n")) {
6361
if (line.startsWith("@@")) {
6462
for (String tmp : line.split(" ")) {
6563
if (tmp.trim().startsWith("+")) {
@@ -74,7 +72,6 @@ public static List<Integer> getChangedLineNumListInNewVersion(String diffFilePat
7472
}
7573
} catch (Exception e) {
7674
// TODO: handle exception
77-
System.out.println(diffFilePath);
7875
e.printStackTrace();
7976
}
8077
return changedLineNumList;

Diff for: lib/utils/SRCUtil.java

+19
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@ public static void changePackage(String oriSRCPath, String dstSRCPath, String ne
2121
FileUtil.writeStringToFile(dstSRCPath, wrtStr);
2222

2323
}
24+
25+
26+
public static void changePackage(String srcPath, String newPackName) {
27+
List<String> srcStrList = FileUtil.readFileToLineList(srcPath);
28+
29+
Boolean ifchanged = false;
30+
String wrtStr = "";
31+
for (int i = 0; i < srcStrList.size(); i++) {
32+
String line = srcStrList.get(i);
33+
if (line.trim().startsWith("package ") && !ifchanged) {
34+
line = "package " + newPackName + ";";
35+
ifchanged = true;
36+
}
37+
wrtStr += (line + "\n");
38+
}
39+
40+
FileUtil.writeStringToFile(srcPath, wrtStr);
41+
42+
}
2443

2544
public static void main(String[] args) {
2645
/*

0 commit comments

Comments
 (0)