java.lang.Object
org.variantsync.diffdetective.variation.diff.construction.JGitDiff

public final class JGitDiff extends Object
Class which groups functions of parsing variation diffs with JGit.
Author:
Paul Bittner
  • Field Details

    • NO_NEWLINE_AT_END_OF_FILE

      private static final Pattern NO_NEWLINE_AT_END_OF_FILE
  • Constructor Details

    • JGitDiff

      private JGitDiff()
  • Method Details

    • textDiff

      public static String textDiff(Path beforeFile, Path afterFile, org.eclipse.jgit.diff.DiffAlgorithm.SupportedAlgorithm algorithm) throws IOException
      Creates a text-based diff from two line-based text inputs. Uses JGit to diff the two files using the specified options.
      Parameters:
      beforeFile - Path to text file before the change.
      afterFile - Path to text file after the change.
      algorithm - Specification of which algorithm to use for diffing with JGit.
      Returns:
      A variation diff comprising the changes.
      Throws:
      IOException - when JGit fails in differencing
    • textDiff

      public static String textDiff(String linesBefore, String linesAfter, org.eclipse.jgit.diff.DiffAlgorithm.SupportedAlgorithm algorithm) throws IOException
      Creates a text-based diff from two line-based text inputs. Uses JGit to diff the two files using the specified options.
      Parameters:
      linesBefore - State of annotated lines before the change.
      linesAfter - State of annotated lines after the change.
      algorithm - Specification of which algorithm to use for diffing with JGit.
      Returns:
      A variation diff comprising the changes.
      Throws:
      IOException - when JGit fails in differencing
    • diff

      public static VariationDiff<DiffLinesLabel> diff(String linesBefore, String linesAfter, org.eclipse.jgit.diff.DiffAlgorithm.SupportedAlgorithm algorithm, VariationDiffParseOptions options) throws IOException, DiffParseException
      Creates a variation diff from to line-based text inputs. Expects variability to be implemented via C preprocessor in those lines. Uses JGit to diff the two files using the specified options, and afterwards, creates the variation diff. Creates a variation diff from to line-based text inputs. First creates a line-based diff with textDiff(String, String, DiffAlgorithm.SupportedAlgorithm) and then parses that diff with VariationDiff.fromDiff(String, VariationDiffParseOptions).
      Parameters:
      linesBefore - State of annotated lines before the change.
      linesAfter - State of annotated lines after the change.
      algorithm - Specification of which algorithm to use for diffing with JGit.
      options - various options for parsing
      Returns:
      A variation diff comprising the changes.
      Throws:
      IOException - when JGit fails in differencing
      DiffParseException - when DiffDetective fails in parsing the JGit diff to a variation diff