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 String
blobFileExtension
protected static String
INCLUDE_GIT_LOG_CONFIG_KEY
protected boolean
includeGitLog
protected File
localRepoFolder
protected ProcessedCommitsStore
processedCommitsStore
static String
UPDATE_COMMIT_CONFIG_KEY
protected boolean
updateCommitStore
-
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 String
asContentStoreUrl(String path)
protected void
doDestroy()
Allows extending classes perform any custom cleanupprotected void
doInit(org.apache.commons.configuration2.Configuration config)
Allows extending classes perform any custom initializationprotected ChangeSet
doMainProcess(Deployment deployment, ProcessorExecution execution, ChangeSet filteredChangeSet, ChangeSet originalChangeSet)
protected org.eclipse.jgit.lib.ObjectId
getFromCommitIdParam(Deployment deployment)
protected org.eclipse.jgit.lib.ObjectId
getLatestCommitId(org.eclipse.jgit.api.Git git)
protected boolean
getReprocessAllFilesParam(Deployment deployment)
protected org.eclipse.jgit.api.Git
openLocalRepository()
protected ChangeSet
processDiffEntries(List<org.eclipse.jgit.diff.DiffEntry> diffEntries)
protected ChangeSet
resolveChangeSetFromCommits(org.eclipse.jgit.api.Git git, org.eclipse.jgit.lib.ObjectId fromCommitId, org.eclipse.jgit.lib.ObjectId toCommitId)
void
setBlobFileExtension(String blobFileExtension)
void
setLocalRepoFolder(File localRepoFolder)
Sets the local filesystem folder the contains the deployed repository.void
setProcessedCommitsStore(ProcessedCommitsStore processedCommitsStore)
Sets the store for processed commits.protected boolean
shouldExecute(Deployment deployment, ChangeSet filteredChangeSet)
Indicates if the processor should be executed for the givenDeployment
andChangeSet
boolean
supportsMode(Deployment.Mode mode)
Indicates if the processor should be included in the given deployment modeprotected void
updateChangeDetails(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.ConfigurationException
Description copied from class:AbstractDeploymentProcessor
Allows extending classes perform any custom initialization- Specified by:
doInit
in classAbstractDeploymentProcessor
- Parameters:
config
- the bean's configuration- Throws:
org.craftercms.commons.config.ConfigurationException
- if there's configuration related exception
-
doDestroy
protected void doDestroy() throws DeployerException
Description copied from class:AbstractDeploymentProcessor
Allows extending classes perform any custom cleanup- Specified by:
doDestroy
in classAbstractDeploymentProcessor
- Throws:
DeployerException
- if an error occurs
-
supportsMode
public boolean supportsMode(Deployment.Mode mode)
Description copied from interface:DeploymentProcessor
Indicates if the processor should be included in the given deployment mode- Specified by:
supportsMode
in interfaceDeploymentProcessor
- Overrides:
supportsMode
in 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:AbstractMainDeploymentProcessor
Indicates if the processor should be executed for the givenDeployment
andChangeSet
- Overrides:
shouldExecute
in classAbstractMainDeploymentProcessor
- Parameters:
deployment
- theDeployment
to checkfilteredChangeSet
- theChangeSet
to 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:AbstractMainDeploymentProcessor
Performs the actual work of processing the files in theChangeSet
, it is also possible to return a newChangeSet
to be used for the following processors in the pipeline- Specified by:
doMainProcess
in 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
ChangeSet
or 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)
-
-