class GitDiff {

    public static GitDiff parse(String line) throws Exception {
        line = line.trim();
        String[] split = line.split(",");
        Map<String, Integer> modifications = new HashMap<>();

        Matcher matcher = FILE_PATTERN.matcher(split[0]);
        if (!matcher.find()) {
            throw new Exception("Unable to parse diff line: " + line);
        }
        int changedFiles = Integer.valueOf(matcher.group("number"));

        // We should be greater than 1
        String input;
        if (split.length > 1) {
            input = split[1];
            matcher = MODIF_PATTERN.matcher(input);
            if (matcher.find()) {
                modifications.put(matcher.group("sign"), Integer.valueOf(matcher.group("number")));
            }
        }
        if (split.length > 2) {
            input = split[2];
            matcher = MODIF_PATTERN.matcher(input);
            if (matcher.find()) {
                modifications.put(matcher.group("sign"), Integer.valueOf(matcher.group("number")));
            }
        }

        int addition = modifications.getOrDefault("+", 0);
        int deletion = modifications.getOrDefault("-", 0);
        return new GitDiff(addition, deletion, changedFiles);
    }

    public  GitDiff(int addition, int deletion, int changedFiles);

}