Class GitScmTestUtils


  • public final class GitScmTestUtils
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String GIT_COMMAND_LINE
      'git' command line.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private GitScmTestUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void deleteAllDirectories​(java.io.File startDirectory, java.lang.String pattern)  
      static java.lang.String getScmUrl​(java.io.File repositoryRootFile, java.lang.String provider)  
      static void initRepo​(java.io.File repository, java.io.File workingDirectory, java.io.File assertionDirectory)  
      static void initRepo​(java.lang.String source, java.io.File repository, java.io.File workingDirectory)  
      static void setDefaultGitConfig​(java.io.File repositoryRootFile)  
      static void setDefaultGitConfig​(java.io.File repositoryRootFile, java.util.function.Consumer<java.io.FileWriter> configWriterCustomizer)  
      private static void setupRejectAllCommitsHook​(java.io.File repositoryOrWorkspaceRootFile, boolean isServerSide, java.lang.String hookName)  
      static void setupRejectAllCommitsPreCommitHook​(java.io.File workspaceRoot)  
      static void setupRejectAllCommitsPrePushHook​(java.io.File workspaceRoot)
      Sets up a pre-push git hook that rejects all commits for the given repository (client-side).
      static void setupRejectAllCommitsPreReceiveHook​(java.io.File repositoryRootFile)
      Sets up a pre-receive git hook that rejects all commits for the given repository (server-side).
      • Methods inherited from class java.lang.Object

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

      • GIT_COMMAND_LINE

        public static final java.lang.String GIT_COMMAND_LINE
        'git' command line.
        See Also:
        Constant Field Values
    • Constructor Detail

      • GitScmTestUtils

        private GitScmTestUtils()
    • Method Detail

      • initRepo

        public static void initRepo​(java.io.File repository,
                                    java.io.File workingDirectory,
                                    java.io.File assertionDirectory)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • initRepo

        public static void initRepo​(java.lang.String source,
                                    java.io.File repository,
                                    java.io.File workingDirectory)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • getScmUrl

        public static java.lang.String getScmUrl​(java.io.File repositoryRootFile,
                                                 java.lang.String provider)
                                          throws org.codehaus.plexus.util.cli.CommandLineException
        Throws:
        org.codehaus.plexus.util.cli.CommandLineException
      • deleteAllDirectories

        public static void deleteAllDirectories​(java.io.File startDirectory,
                                                java.lang.String pattern)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • setDefaultGitConfig

        public static void setDefaultGitConfig​(java.io.File repositoryRootFile)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • setDefaultGitConfig

        public static void setDefaultGitConfig​(java.io.File repositoryRootFile,
                                               java.util.function.Consumer<java.io.FileWriter> configWriterCustomizer)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • setupRejectAllCommitsPreReceiveHook

        public static void setupRejectAllCommitsPreReceiveHook​(java.io.File repositoryRootFile)
                                                        throws java.io.IOException
        Sets up a pre-receive git hook that rejects all commits for the given repository (server-side). This is useful for testing scenarios where you want to simulate a repository that doesn't allow any new commits. This hook is not supported by JGit.
        Parameters:
        repositoryRootFile - the root directory of the git repository
        Throws:
        java.io.IOException - if there's an error creating or writing the hook file
      • setupRejectAllCommitsPrePushHook

        public static void setupRejectAllCommitsPrePushHook​(java.io.File workspaceRoot)
                                                     throws java.io.IOException
        Sets up a pre-push git hook that rejects all commits for the given repository (client-side). This is useful for testing scenarios where you want to simulate a repository that doesn't allow any new commits.
        Parameters:
        workspaceRoot - the root directory of the git working copy
        Throws:
        java.io.IOException - if there's an error creating or writing the hook file
      • setupRejectAllCommitsPreCommitHook

        public static void setupRejectAllCommitsPreCommitHook​(java.io.File workspaceRoot)
                                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • setupRejectAllCommitsHook

        private static void setupRejectAllCommitsHook​(java.io.File repositoryOrWorkspaceRootFile,
                                                      boolean isServerSide,
                                                      java.lang.String hookName)
                                               throws java.io.IOException
        Throws:
        java.io.IOException