Fix diff parsing and run unit tests (#1190)

Closes https://codeberg.org/gitnex/GitNex/issues/1167

The regex didn't match if the raw string starts with a `+` or `-`.

Co-authored-by: qwerty287 <ndev@web.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1190
Reviewed-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
qwerty287 2022-08-20 10:30:15 +02:00 committed by M M Arif
parent a7d9918b67
commit f310f9f8e6
2 changed files with 11 additions and 0 deletions

View File

@ -13,3 +13,8 @@ pipeline:
settings:
file_pattern: "*.java"
path: "app/"
test:
image: alvrme/alpine-android:android-31-jdk11
commands:
- ./gradlew test

View File

@ -43,6 +43,12 @@ public class ParseDiff {
Matcher rmMatcher = rmPattern.matcher(raw);
Matcher addMatcher = addPattern.matcher(raw);
if(raw.startsWith("+")) {
add++;
}
else if(raw.startsWith("-")) {
rm++;
}
while(rmMatcher.find())
rm++;
while(addMatcher.find())