public class GitRepositoryHelper extends Object
Modifier and Type | Method and Description |
---|---|
boolean |
addFiles(org.eclipse.jgit.lib.Repository repo,
String site,
String... paths) |
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 |
commitFiles(org.eclipse.jgit.lib.Repository repo,
String site,
String comment,
org.eclipse.jgit.lib.PersonIdent user,
String... paths) |
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,
String creator) |
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) |
String[] |
getGitPaths(String... paths) |
static GitRepositoryHelper |
getHelper(StudioConfiguration studioConfiguration,
SecurityService securityService,
UserServiceInternal userServiceInternal,
org.craftercms.commons.crypto.TextEncryptor textEncryptor,
GeneralLockService generalLockService,
RetryingRepositoryOperationFacade retryingRepositoryOperationFacade) |
String |
getPublishedRepoLockKey(String site)
Returns the key to use when locking Git operations for a site's published repo
|
org.eclipse.jgit.lib.Repository |
getRepository(String siteId,
GitRepositories gitRepository) |
org.eclipse.jgit.lib.Repository |
getRepository(String siteId,
GitRepositories gitRepository,
String sandboxBranch) |
String |
getSandboxRepoLockKey(String site)
Returns the key to use when locking Git operations for a site's sandbox repo
|
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,
String creator)
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, GeneralLockService generalLockService, RetryingRepositoryOperationFacade retryingRepositoryOperationFacade) throws org.craftercms.commons.crypto.CryptoException
org.craftercms.commons.crypto.CryptoException
public 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)IOException
public 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.CryptoException
IOException
ServiceLayerException
org.eclipse.jgit.api.errors.GitAPIException
public 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.CryptoException
ServiceLayerException
public org.eclipse.jgit.lib.PersonIdent getAuthorIdent(User user) throws ServiceLayerException, UserNotFoundException
user
- authorServiceLayerException
UserNotFoundException
public org.eclipse.jgit.revwalk.RevTree getTreeForCommit(org.eclipse.jgit.lib.Repository repository, String commitId) throws IOException
IOException
public org.eclipse.jgit.revwalk.RevTree getTreeForLastCommit(org.eclipse.jgit.lib.Repository repository) throws IOException
IOException
public 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, String creator)
site
- message
- sandboxBranch
- creator
- site creatorpublic 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, String creator) throws InvalidRemoteRepositoryException, InvalidRemoteRepositoryCredentialsException, RemoteRepositoryNotFoundException, ServiceLayerException
public void removeSandbox(String siteId)
public boolean buildGlobalRepo() throws IOException
IOException
public boolean createGlobalRepo()
public boolean deleteSiteGitRepo(String site)
public boolean writeFile(org.eclipse.jgit.lib.Repository repo, String site, String path, InputStream content)
public boolean addFiles(org.eclipse.jgit.lib.Repository repo, String site, String... paths)
public String commitFiles(org.eclipse.jgit.lib.Repository repo, String site, String comment, org.eclipse.jgit.lib.PersonIdent user, String... paths)
public org.eclipse.jgit.lib.PersonIdent getCurrentUserIdent() throws ServiceLayerException, UserNotFoundException
ServiceLayerException
UserNotFoundException
public org.eclipse.jgit.lib.PersonIdent getAuthorIdent(String author) throws ServiceLayerException, UserNotFoundException
author
- authorServiceLayerException
UserNotFoundException
public String getSandboxRepoLockKey(String site)
site
- the site nameCopyright © 2023 CrafterCMS. All rights reserved.