public class GitRepositoryHelper extends Object
| Modifier and Type | Method and Description |
|---|---|
boolean |
addGitIgnoreFile(String siteId) |
boolean |
buildGlobalRepo()
Build the global repository as part of system startup and caches it
|
Path |
buildRepoPath(GitRepositories repoType)
Builds repository path
|
Path |
buildRepoPath(GitRepositories repoType,
String siteId)
Builds repository path
|
boolean |
buildSiteRepo(String siteId) |
String |
commitFile(org.eclipse.jgit.lib.Repository repo,
String site,
String path,
String comment,
org.eclipse.jgit.lib.PersonIdent user) |
boolean |
copyContentFromBlueprint(String blueprintLocation,
String site) |
org.eclipse.jgit.lib.Repository |
createGitRepository(Path path) |
boolean |
createGlobalRepo() |
boolean |
createPublishedRepository(String siteId,
String sandboxBranch)
Create a site published git repository from scratch
|
boolean |
createSandboxRepository(String site,
String sandboxBranch)
Create a site sandbox git repository from scratch
|
boolean |
createSiteCloneRemoteGitRepo(String siteId,
String sandboxBranch,
String remoteName,
String remoteUrl,
String remoteBranch,
boolean singleBranch,
String authenticationType,
String remoteUsername,
String remotePassword,
String remoteToken,
String remotePrivateKey,
boolean createAsOrphan) |
boolean |
deleteSiteGitRepo(String site) |
org.eclipse.jgit.lib.PersonIdent |
getAuthorIdent(String author)
Return the author identity as a jgit PersonIdent
|
org.eclipse.jgit.lib.PersonIdent |
getAuthorIdent(User user)
Return the author identity as a jgit PersonIdent
|
String |
getCommitMessage(String commitMessageKey) |
org.eclipse.jgit.lib.PersonIdent |
getCurrentUserIdent()
Return the current user identity as a jgit PersonIdent
|
List<String> |
getFilesInCommit(org.eclipse.jgit.lib.Repository repository,
org.eclipse.jgit.revwalk.RevCommit commit) |
String |
getGitPath(String path) |
static GitRepositoryHelper |
getHelper(StudioConfiguration studioConfiguration,
SecurityService securityService,
UserServiceInternal userServiceInternal,
org.craftercms.commons.crypto.TextEncryptor textEncryptor) |
org.eclipse.jgit.lib.Repository |
getRepository(String siteId,
GitRepositories gitRepository) |
org.eclipse.jgit.lib.Repository |
getRepository(String siteId,
GitRepositories gitRepository,
String sandboxBranch) |
org.eclipse.jgit.transport.SshSessionFactory |
getSshSessionFactory(String privateKey,
Path tempKey) |
org.eclipse.jgit.revwalk.RevTree |
getTreeForCommit(org.eclipse.jgit.lib.Repository repository,
String commitId) |
org.eclipse.jgit.revwalk.RevTree |
getTreeForLastCommit(org.eclipse.jgit.lib.Repository repository) |
boolean |
isRemoteValid(org.eclipse.jgit.api.Git git,
String remote,
String authenticationType,
String remoteUsername,
String remotePassword,
String remoteToken,
String remotePrivateKey) |
org.eclipse.jgit.lib.Repository |
openRepository(Path repositoryPath)
Opens a git repository
|
boolean |
performInitialCommit(String site,
String message,
String sandboxBranch)
Perform an initial commit after large changes to a site.
|
void |
removeSandbox(String siteId) |
boolean |
replaceParameters(String siteId,
Map<String,String> parameters) |
protected boolean |
replaceSiteNameVariable(String site,
Path path) |
<T extends org.eclipse.jgit.api.TransportCommand> |
setAuthenticationForCommand(T gitCommand,
String authenticationType,
String username,
String password,
String token,
String privateKey,
Path tempKey,
boolean decrypt) |
boolean |
updateSiteNameConfigVar(String site) |
boolean |
writeFile(org.eclipse.jgit.lib.Repository repo,
String site,
String path,
InputStream content) |
public static GitRepositoryHelper getHelper(StudioConfiguration studioConfiguration, SecurityService securityService, UserServiceInternal userServiceInternal, org.craftercms.commons.crypto.TextEncryptor textEncryptor) throws org.craftercms.commons.crypto.CryptoException
org.craftercms.commons.crypto.CryptoExceptionpublic org.eclipse.jgit.lib.Repository getRepository(String siteId, GitRepositories gitRepository)
public org.eclipse.jgit.lib.Repository getRepository(String siteId, GitRepositories gitRepository, String sandboxBranch)
public boolean buildSiteRepo(String siteId)
public Path buildRepoPath(GitRepositories repoType)
repoType - repository typepublic Path buildRepoPath(GitRepositories repoType, String siteId)
repoType - repository typesiteId - site Id (if empty it is global repository)public org.eclipse.jgit.lib.Repository openRepository(Path repositoryPath) throws IOException
repositoryPath - path to repository to open (including .git)IOExceptionpublic boolean isRemoteValid(org.eclipse.jgit.api.Git git,
String remote,
String authenticationType,
String remoteUsername,
String remotePassword,
String remoteToken,
String remotePrivateKey)
throws org.craftercms.commons.crypto.CryptoException,
IOException,
ServiceLayerException,
org.eclipse.jgit.api.errors.GitAPIException
org.craftercms.commons.crypto.CryptoExceptionIOExceptionServiceLayerExceptionorg.eclipse.jgit.api.errors.GitAPIExceptionpublic org.eclipse.jgit.transport.SshSessionFactory getSshSessionFactory(String privateKey, Path tempKey)
public <T extends org.eclipse.jgit.api.TransportCommand> T setAuthenticationForCommand(T gitCommand,
String authenticationType,
String username,
String password,
String token,
String privateKey,
Path tempKey,
boolean decrypt)
throws org.craftercms.commons.crypto.CryptoException,
ServiceLayerException
org.craftercms.commons.crypto.CryptoExceptionServiceLayerExceptionpublic org.eclipse.jgit.lib.PersonIdent getAuthorIdent(User user) throws ServiceLayerException, UserNotFoundException
user - authorServiceLayerExceptionUserNotFoundExceptionpublic org.eclipse.jgit.revwalk.RevTree getTreeForCommit(org.eclipse.jgit.lib.Repository repository,
String commitId)
throws IOException
IOExceptionpublic org.eclipse.jgit.revwalk.RevTree getTreeForLastCommit(org.eclipse.jgit.lib.Repository repository)
throws IOException
IOExceptionpublic List<String> getFilesInCommit(org.eclipse.jgit.lib.Repository repository, org.eclipse.jgit.revwalk.RevCommit commit)
public boolean createSandboxRepository(String site, String sandboxBranch)
site - site to createsandboxBranch - sandbox branch namepublic boolean createPublishedRepository(String siteId, String sandboxBranch)
siteId - site to createsandboxBranch - sandbox branch namepublic org.eclipse.jgit.lib.Repository createGitRepository(Path path)
public boolean copyContentFromBlueprint(String blueprintLocation, String site)
public boolean updateSiteNameConfigVar(String site)
public boolean addGitIgnoreFile(String siteId)
public boolean performInitialCommit(String site, String message, String sandboxBranch)
site - message - public boolean createSiteCloneRemoteGitRepo(String siteId, String sandboxBranch, String remoteName, String remoteUrl, String remoteBranch, boolean singleBranch, String authenticationType, String remoteUsername, String remotePassword, String remoteToken, String remotePrivateKey, boolean createAsOrphan) throws InvalidRemoteRepositoryException, InvalidRemoteRepositoryCredentialsException, RemoteRepositoryNotFoundException, ServiceLayerException
public void removeSandbox(String siteId)
public boolean buildGlobalRepo()
throws IOException
IOExceptionpublic boolean createGlobalRepo()
public boolean deleteSiteGitRepo(String site)
public boolean writeFile(org.eclipse.jgit.lib.Repository repo,
String site,
String path,
InputStream content)
public String commitFile(org.eclipse.jgit.lib.Repository repo, String site, String path, String comment, org.eclipse.jgit.lib.PersonIdent user)
public org.eclipse.jgit.lib.PersonIdent getCurrentUserIdent()
throws ServiceLayerException,
UserNotFoundException
ServiceLayerExceptionUserNotFoundExceptionpublic org.eclipse.jgit.lib.PersonIdent getAuthorIdent(String author) throws ServiceLayerException, UserNotFoundException
author - authorServiceLayerExceptionUserNotFoundExceptionCopyright © 2020 CrafterCMS. All rights reserved.