Class GitStatusConsumer

  • All Implemented Interfaces:
    org.codehaus.plexus.util.cli.StreamConsumer

    public class GitStatusConsumer
    extends java.lang.Object
    implements org.codehaus.plexus.util.cli.StreamConsumer
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.regex.Pattern ADDED_PATTERN
      The pattern used to match added file lines
      private java.util.List<ScmFile> changedFiles
      Entries are relative to working directory, not to the repositoryroot
      private static java.util.regex.Pattern DELETED_PATTERN
      The pattern used to match deleted file lines
      private ScmLogger logger  
      private static java.util.regex.Pattern MODIFIED_PATTERN
      The pattern used to match modified file lines
      private java.net.URI relativeRepositoryPath  
      private static java.util.regex.Pattern RENAMED_PATTERN
      The pattern used to match renamed file lines
      private java.io.File workingDirectory  
    • Constructor Summary

      Constructors 
      Constructor Description
      GitStatusConsumer​(ScmLogger logger, java.io.File workingDirectory)
      Consumer when workingDirectory and repositoryRootDirectory are the same
      GitStatusConsumer​(ScmLogger logger, java.io.File workingDirectory, java.net.URI relativeRepositoryPath)
      Assuming that you have to discover the repositoryRoot, this is how you can get the relativeRepositoryPath
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void consumeLine​(java.lang.String line)
      java.util.List<ScmFile> getChangedFiles()  
      private boolean isFile​(java.lang.String file)  
      protected static java.lang.String resolvePath​(java.lang.String fileEntry, java.net.URI path)  
      static java.net.URI resolveURI​(java.lang.String fileEntry, java.net.URI path)  
      private static java.lang.String stripQuotes​(java.lang.String str)  
      private static java.lang.String unescape​(java.lang.String fileEntry)
      Dequote a quoted string generated by git status --porcelain.
      static java.net.URI uriFromPath​(java.lang.String path)
      Create an URI whose getPath() returns the given path and getScheme() returns null.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ADDED_PATTERN

        private static final java.util.regex.Pattern ADDED_PATTERN
        The pattern used to match added file lines
      • MODIFIED_PATTERN

        private static final java.util.regex.Pattern MODIFIED_PATTERN
        The pattern used to match modified file lines
      • DELETED_PATTERN

        private static final java.util.regex.Pattern DELETED_PATTERN
        The pattern used to match deleted file lines
      • RENAMED_PATTERN

        private static final java.util.regex.Pattern RENAMED_PATTERN
        The pattern used to match renamed file lines
      • workingDirectory

        private java.io.File workingDirectory
      • changedFiles

        private java.util.List<ScmFile> changedFiles
        Entries are relative to working directory, not to the repositoryroot
      • relativeRepositoryPath

        private java.net.URI relativeRepositoryPath
    • Constructor Detail

      • GitStatusConsumer

        public GitStatusConsumer​(ScmLogger logger,
                                 java.io.File workingDirectory)
        Consumer when workingDirectory and repositoryRootDirectory are the same
        Parameters:
        logger - the logger
        workingDirectory - the working directory
      • GitStatusConsumer

        public GitStatusConsumer​(ScmLogger logger,
                                 java.io.File workingDirectory,
                                 java.net.URI relativeRepositoryPath)
        Assuming that you have to discover the repositoryRoot, this is how you can get the relativeRepositoryPath
         URI.create( repositoryRoot ).relativize( fileSet.getBasedir().toURI() )
         
        Parameters:
        logger - the logger
        workingDirectory - the working directory
        relativeRepositoryPath - the working directory relative to the repository root
        Since:
        1.9
        See Also:
        GitStatusCommand.createRevparseShowPrefix(org.apache.maven.scm.ScmFileSet)
    • Method Detail

      • consumeLine

        public void consumeLine​(java.lang.String line)
        Specified by:
        consumeLine in interface org.codehaus.plexus.util.cli.StreamConsumer
      • isFile

        private boolean isFile​(java.lang.String file)
      • resolvePath

        protected static java.lang.String resolvePath​(java.lang.String fileEntry,
                                                      java.net.URI path)
      • resolveURI

        public static java.net.URI resolveURI​(java.lang.String fileEntry,
                                              java.net.URI path)
        Parameters:
        fileEntry - the fileEntry, must not be null
        path - the path, must not be null
        Returns:
      • uriFromPath

        public static java.net.URI uriFromPath​(java.lang.String path)
        Create an URI whose getPath() returns the given path and getScheme() returns null. The path may contain spaces, colons, and other special characters.
        Parameters:
        path - the path.
        Returns:
        the new URI
      • getChangedFiles

        public java.util.List<ScmFile> getChangedFiles()
      • stripQuotes

        private static java.lang.String stripQuotes​(java.lang.String str)
        Parameters:
        str - the (potentially quoted) string, must not be null
        Returns:
        the string with a pair of double quotes removed (if they existed)
      • unescape

        private static java.lang.String unescape​(java.lang.String fileEntry)
        Dequote a quoted string generated by git status --porcelain. The leading and trailing quotes have already been removed.
        Parameters:
        fileEntry -
        Returns: