Class GitDiffProcessor
- java.lang.Object
-
- org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
-
- org.craftercms.deployer.impl.processors.AbstractMainDeploymentProcessor
-
- org.craftercms.deployer.impl.processors.git.GitDiffProcessor
-
- All Implemented Interfaces:
DeploymentProcessor,InitializableByConfigBean,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware
public class GitDiffProcessor extends AbstractMainDeploymentProcessor
Processor that, based on a previous processed commit that's stored, does a diff with the current commit of the deployment, to find out the change set. If there is no previous processed commit, then the entire repository becomes the change set. This processor is used basically to create the change set and should be used before other processors that actually process the change set, likeElasticsearchIndexingProcessor.- Author:
- avasquez
-
-
Field Summary
Fields Modifier and Type Field Description protected StringblobFileExtensionprotected static StringINCLUDE_GIT_LOG_CONFIG_KEYprotected booleanincludeGitLogprotected FilelocalRepoFolderprotected ProcessedCommitsStoreprocessedCommitsStorestatic StringUPDATE_COMMIT_CONFIG_KEYprotected booleanupdateCommitStore-
Fields inherited from class org.craftercms.deployer.impl.processors.AbstractMainDeploymentProcessor
FAIL_DEPLOYMENT_CONFIG_KEY, failDeploymentOnFailure
-
Fields inherited from class org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
alwaysRun, env, excludeFiles, includeFiles, JUMPING_TO_PARAM_NAME, jumpTo, label, name, siteName, targetId
-
-
Constructor Summary
Constructors Constructor Description GitDiffProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringasContentStoreUrl(String path)protected voiddoDestroy()Allows extending classes perform any custom cleanupprotected voiddoInit(org.apache.commons.configuration2.Configuration config)Allows extending classes perform any custom initializationprotected ChangeSetdoMainProcess(Deployment deployment, ProcessorExecution execution, ChangeSet filteredChangeSet, ChangeSet originalChangeSet)protected org.eclipse.jgit.lib.ObjectIdgetFromCommitIdParam(Deployment deployment)protected org.eclipse.jgit.lib.ObjectIdgetLatestCommitId(org.eclipse.jgit.api.Git git)protected booleangetReprocessAllFilesParam(Deployment deployment)protected org.eclipse.jgit.api.GitopenLocalRepository()protected ChangeSetprocessDiffEntries(List<org.eclipse.jgit.diff.DiffEntry> diffEntries)protected ChangeSetresolveChangeSetFromCommits(org.eclipse.jgit.api.Git git, org.eclipse.jgit.lib.ObjectId fromCommitId, org.eclipse.jgit.lib.ObjectId toCommitId)voidsetBlobFileExtension(String blobFileExtension)voidsetLocalRepoFolder(File localRepoFolder)Sets the local filesystem folder the contains the deployed repository.voidsetProcessedCommitsStore(ProcessedCommitsStore processedCommitsStore)Sets the store for processed commits.protected booleanshouldExecute(Deployment deployment, ChangeSet filteredChangeSet)Indicates if the processor should be executed for the givenDeploymentandChangeSetbooleansupportsMode(Deployment.Mode mode)Indicates if the processor should be included in the given deployment modeprotected voidupdateChangeDetails(ChangeSet changeSet, org.eclipse.jgit.api.Git git, org.eclipse.jgit.lib.ObjectId previousCommitId, org.eclipse.jgit.lib.ObjectId latestCommitId)-
Methods inherited from class org.craftercms.deployer.impl.processors.AbstractMainDeploymentProcessor
doExecute, failDeploymentOnProcessorFailure, init
-
Methods inherited from class org.craftercms.deployer.impl.processors.AbstractDeploymentProcessor
destroy, execute, getFilteredChangeSet, isJumpToActive, isPostDeployment, setBeanName, setEnv, setSiteName, setTargetId, shouldIncludeFile, startJumpTo
-
-
-
-
Field Detail
-
INCLUDE_GIT_LOG_CONFIG_KEY
protected static final String INCLUDE_GIT_LOG_CONFIG_KEY
- See Also:
- Constant Field Values
-
UPDATE_COMMIT_CONFIG_KEY
public static final String UPDATE_COMMIT_CONFIG_KEY
- See Also:
- Constant Field Values
-
localRepoFolder
protected File localRepoFolder
-
processedCommitsStore
protected ProcessedCommitsStore processedCommitsStore
-
includeGitLog
protected boolean includeGitLog
-
blobFileExtension
protected String blobFileExtension
-
updateCommitStore
protected boolean updateCommitStore
-
-
Method Detail
-
setLocalRepoFolder
public void setLocalRepoFolder(File localRepoFolder)
Sets the local filesystem folder the contains the deployed repository.
-
setProcessedCommitsStore
public void setProcessedCommitsStore(ProcessedCommitsStore processedCommitsStore)
Sets the store for processed commits.
-
setBlobFileExtension
public void setBlobFileExtension(String blobFileExtension)
-
doInit
protected void doInit(org.apache.commons.configuration2.Configuration config) throws org.craftercms.commons.config.ConfigurationExceptionDescription copied from class:AbstractDeploymentProcessorAllows extending classes perform any custom initialization- Specified by:
doInitin classAbstractDeploymentProcessor- Parameters:
config- the bean's configuration- Throws:
org.craftercms.commons.config.ConfigurationException- if there's configuration related exception
-
doDestroy
protected void doDestroy() throws DeployerExceptionDescription copied from class:AbstractDeploymentProcessorAllows extending classes perform any custom cleanup- Specified by:
doDestroyin classAbstractDeploymentProcessor- Throws:
DeployerException- if an error occurs
-
supportsMode
public boolean supportsMode(Deployment.Mode mode)
Description copied from interface:DeploymentProcessorIndicates if the processor should be included in the given deployment mode- Specified by:
supportsModein interfaceDeploymentProcessor- Overrides:
supportsModein classAbstractDeploymentProcessor- Parameters:
mode- the deployment mode to check- Returns:
- true if the processor should be included
-
shouldExecute
protected boolean shouldExecute(Deployment deployment, ChangeSet filteredChangeSet)
Description copied from class:AbstractMainDeploymentProcessorIndicates if the processor should be executed for the givenDeploymentandChangeSet- Overrides:
shouldExecutein classAbstractMainDeploymentProcessor- Parameters:
deployment- theDeploymentto checkfilteredChangeSet- theChangeSetto check- Returns:
- true if the processor should be executed
-
doMainProcess
protected ChangeSet doMainProcess(Deployment deployment, ProcessorExecution execution, ChangeSet filteredChangeSet, ChangeSet originalChangeSet) throws DeployerException
Description copied from class:AbstractMainDeploymentProcessorPerforms the actual work of processing the files in theChangeSet, it is also possible to return a newChangeSetto be used for the following processors in the pipeline- Specified by:
doMainProcessin classAbstractMainDeploymentProcessor- Parameters:
deployment- the current deploymentexecution- the current executionfilteredChangeSet- the filtered change set (as returned byAbstractDeploymentProcessor.getFilteredChangeSet(ChangeSet))originalChangeSet- the original change set (as returned by the previous processors in the pipeline)- Returns:
- a new
ChangeSetor null - Throws:
DeployerException- if there is any error processing theChangeSet
-
updateChangeDetails
protected void updateChangeDetails(ChangeSet changeSet, org.eclipse.jgit.api.Git git, org.eclipse.jgit.lib.ObjectId previousCommitId, org.eclipse.jgit.lib.ObjectId latestCommitId)
-
openLocalRepository
protected org.eclipse.jgit.api.Git openLocalRepository() throws DeployerException- Throws:
DeployerException
-
getLatestCommitId
protected org.eclipse.jgit.lib.ObjectId getLatestCommitId(org.eclipse.jgit.api.Git git) throws DeployerException- Throws:
DeployerException
-
resolveChangeSetFromCommits
protected ChangeSet resolveChangeSetFromCommits(org.eclipse.jgit.api.Git git, org.eclipse.jgit.lib.ObjectId fromCommitId, org.eclipse.jgit.lib.ObjectId toCommitId) throws DeployerException
- Throws:
DeployerException
-
processDiffEntries
protected ChangeSet processDiffEntries(List<org.eclipse.jgit.diff.DiffEntry> diffEntries)
-
getReprocessAllFilesParam
protected boolean getReprocessAllFilesParam(Deployment deployment)
-
getFromCommitIdParam
protected org.eclipse.jgit.lib.ObjectId getFromCommitIdParam(Deployment deployment)
-
-