Merge branch '26-bug-with-line' into 'master'

Resolve "Bug: не фиксируются признаки удаления и добавления файлов и строк"

Closes #26

See merge request romanov73/git-extractor!24
This commit is contained in:
Anton Romanov 2021-04-27 12:20:11 +00:00
commit 07ec0e9d84
2 changed files with 18 additions and 7 deletions

View File

@ -10,9 +10,8 @@ import javax.persistence.Entity;
@Entity
public class LineChange extends BaseEntity {
private Boolean added;
private Boolean removed;
private Boolean added = false;
private Boolean removed = false;
private String lineFrom;
private String lineTo;

View File

@ -251,20 +251,32 @@ public class GitRepositoryService {
if (strings[i].startsWith("---")) {
i++;
} else {
lineChange.setLineFrom(lineChange.getLineFrom() + "\n" + strings[i]);
i++;
if (lineChange.getLineFrom() == null) {
lineChange.setLineFrom(strings[i]);
i++;
} else {
lineChange.setLineFrom(lineChange.getLineFrom() + "\n" + strings[i]);
i++;
}
}
}
lineChange.setRemoved(true);
}
if (strings[i].startsWith("+")) {
while ((i < stringsLength) && strings[i].startsWith("+")) {
if (strings[i].startsWith("+++")) {
i++;
} else {
lineChange.setLineTo(lineChange.getLineTo() + "\n" + strings[i]);
i++;
if (lineChange.getLineTo() == null) {
lineChange.setLineTo(strings[i]);
i++;
} else {
lineChange.setLineTo(lineChange.getLineTo() + "\n" + strings[i]);
i++;
}
}
}
lineChange.setAdded(true);
}
if ((lineChange.getLineTo() != null) || (lineChange.getLineFrom() != null)
|| ((lineChange.getLineTo() != null) && (lineChange.getLineFrom() != null))) {