parseGitShortStatStdout static method
Parses the stdout of git --shortstat into the representation model. Example of git diff --shortstat:
3 files changed, 455 insertions(+), 12 deletions(-)
Implementation
static ShortStatDto parseGitShortStatStdout(String rawGitShortStats) {
List<String> shortStatParts = List<String>.empty(growable: true);
int numberOfChangedFiles = -1;
int insertions = -1;
int deletions = -1;
try {
shortStatParts = rawGitShortStats.split(',');
for (int i = 0; i < shortStatParts.length; i++) {
shortStatParts[i] = shortStatParts[i].trim();
}
numberOfChangedFiles = int.parse(shortStatParts[0].split(' ')[0]);
insertions = int.parse(shortStatParts[1].split(' ')[0]);
deletions = int.parse(shortStatParts[2].split(' ')[0]);
} catch (e) {
numberOfChangedFiles = -1;
insertions = -1;
deletions = -1;
}
return ShortStatDto(numberOfChangedFiles, insertions, deletions);
}