Class GitRepositoryHelper


  • public class GitRepositoryHelper
    extends Object
    • Constructor Detail

      • GitRepositoryHelper

        public GitRepositoryHelper()
    • Method Detail

      • getRepository

        public org.eclipse.jgit.lib.Repository getRepository​(String siteId,
                                                             GitRepositories gitRepository)
      • getRepository

        public org.eclipse.jgit.lib.Repository getRepository​(String siteId,
                                                             GitRepositories gitRepository,
                                                             String sandboxBranch)
      • buildSiteRepo

        public boolean buildSiteRepo​(String siteId)
      • buildRepoPath

        public Path buildRepoPath​(GitRepositories repoType)
        Builds repository path
        Parameters:
        repoType - repository type
        Returns:
        repository path
      • buildRepoPath

        public Path buildRepoPath​(GitRepositories repoType,
                                  String siteId)
        Builds repository path
        Parameters:
        repoType - repository type
        siteId - site Id (if empty it is global repository)
        Returns:
        repository path
      • openRepository

        public org.eclipse.jgit.lib.Repository openRepository​(Path repositoryPath)
                                                       throws IOException
        Opens a git repository
        Parameters:
        repositoryPath - path to repository to open (including .git)
        Returns:
        repository object if successful
        Throws:
        IOException - IO error
      • getAuthorIdent

        public org.eclipse.jgit.lib.PersonIdent getAuthorIdent​(User user)
        Return the author identity as a jgit PersonIdent
        Parameters:
        user - author
        Returns:
        author user as a PersonIdent
      • getTreeForCommit

        public org.eclipse.jgit.revwalk.RevTree getTreeForCommit​(org.eclipse.jgit.lib.Repository repository,
                                                                 String commitId)
                                                          throws IOException
        Throws:
        IOException
      • getTreeForLastCommit

        public org.eclipse.jgit.revwalk.RevTree getTreeForLastCommit​(org.eclipse.jgit.lib.Repository repository)
                                                              throws IOException
        Throws:
        IOException
      • getFilesInCommit

        public List<String> getFilesInCommit​(org.eclipse.jgit.lib.Repository repository,
                                             org.eclipse.jgit.revwalk.RevCommit commit)
      • createSandboxRepository

        public boolean createSandboxRepository​(String site,
                                               String sandboxBranch)
        Create a site sandbox git repository from scratch
        Parameters:
        site - site to create
        sandboxBranch - sandbox branch name
        Returns:
        true if successful, false otherwise
      • createPublishedRepository

        public boolean createPublishedRepository​(String siteId,
                                                 String sandboxBranch)
        Create a site published git repository from scratch
        Parameters:
        siteId - site to create
        sandboxBranch - sandbox branch name
        Returns:
        true if successful, false otherwise
      • createGitRepository

        public org.eclipse.jgit.lib.Repository createGitRepository​(Path path)
      • getCommitMessage

        public String getCommitMessage​(String commitMessageKey)
      • copyContentFromBlueprint

        public boolean copyContentFromBlueprint​(String blueprintLocation,
                                                String site)
      • updateSiteNameConfigVar

        public boolean updateSiteNameConfigVar​(String site)
      • replaceSiteNameVariable

        protected boolean replaceSiteNameVariable​(String site,
                                                  Path path)
      • replaceParameters

        public boolean replaceParameters​(String siteId,
                                         Map<String,​String> parameters)
      • addGitIgnoreFiles

        public boolean addGitIgnoreFiles​(String siteId)
      • performInitialCommit

        public boolean performInitialCommit​(String site,
                                            String message,
                                            String sandboxBranch)
        Perform an initial commit after large changes to a site. Will not work against the global config repo.
        Parameters:
        site - site identifier
        message - commit message
        sandboxBranch - sandbox branch name
        Returns:
        true if successful, false otherwise
      • removeSandbox

        public void removeSandbox​(String siteId)
      • buildGlobalRepo

        public boolean buildGlobalRepo()
                                throws IOException
        Build the global repository as part of system startup and caches it
        Returns:
        true if successful, false otherwise
        Throws:
        IOException - IO error
      • createGlobalRepo

        public boolean createGlobalRepo()
      • deleteSiteGitRepo

        public boolean deleteSiteGitRepo​(String site)
      • writeFile

        public boolean writeFile​(org.eclipse.jgit.lib.Repository repo,
                                 String site,
                                 String path,
                                 InputStream content)
      • commitFile

        public String commitFile​(org.eclipse.jgit.lib.Repository repo,
                                 String site,
                                 String path,
                                 String comment,
                                 org.eclipse.jgit.lib.PersonIdent user)
      • setStudioConfiguration

        public void setStudioConfiguration​(StudioConfiguration studioConfiguration)
      • getEncryptor

        public org.craftercms.commons.crypto.TextEncryptor getEncryptor()
      • setEncryptor

        public void setEncryptor​(org.craftercms.commons.crypto.TextEncryptor encryptor)
      • setSecurityService

        public void setSecurityService​(SecurityService securityService)
      • setUserServiceInternal

        public void setUserServiceInternal​(UserServiceInternal userServiceInternal)
      • setGeneralLockService

        public void setGeneralLockService​(GeneralLockService generalLockService)
      • setAuthConfiguratorFactory

        public void setAuthConfiguratorFactory​(org.craftercms.commons.git.utils.AuthConfiguratorFactory authConfiguratorFactory)