Package com.zfabrik.impl.gitcr
Class GitComponentRepositoryImpl
- java.lang.Object
-
- com.zfabrik.components.provider.util.AbstractExtComponentRepository<com.zfabrik.components.provider.fs.RootBoundFSCRComponent,com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDB>
-
- com.zfabrik.components.provider.fs.AbstractFileSystemComponentRepository
-
- com.zfabrik.impl.gitcr.GitComponentRepositoryImpl
-
- All Implemented Interfaces:
com.zfabrik.components.provider.IComponentsRepository,com.zfabrik.util.sync.ISynchronizer
public class GitComponentRepositoryImpl extends com.zfabrik.components.provider.fs.AbstractFileSystemComponentRepositoryGit based components repository based onAbstractFileSystemComponentRepositoryThe Git CR clones the source repo (i.e. the one defined by
gitcr.path) into the z2-repo cache. On sync the cloned repo fetches all changes from the source repo, so that git does all the ugly stuff :-)Known GitCR properties:
gitcr.uriThe URI to the source repo. Can be an absolute path, a local path relative to bin, or a remote URL gitcr.priorityorgitcr.prioThe priority of the repository gitcr.branchThe branch to clone. Defaults to the active branch of the source repository gitcr.refA Git ref to fetch and check out as active content. This can be a tag ( refs/tags/<tag name>), or a branch (refs/heads/<branch name>) or HEAD for the default branch. For compatibility, it can also be a remote tracking branch (refs/remotes/origin/<branch name>ororigin/<branch name>).As this information is used to compute a ref spec, this may not be a single commit, as git fetch requires some form of ref.
In particular this can be "HEAD" to simply follow the remote default branch!
Use this option, if you need more control than given bygitcr.branch. Note that the latter will be used with preference and hence needs to be omitted, if you want to usegitcr.ref.gitcr.rootsComma-separated list of paths relative to the repo root to search for modules. Can be left empty for the default, which is searching from the root - Author:
- Udo Offermann, Henning Blohm
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringGITCR_BRANCHBranch to clone from the source repository.static java.lang.StringGITCR_OPTIONALIf set to 'true', the gitcr will be ignore silently if the defined gitcr.uri is invalid.static java.lang.StringGITCR_PRIOstatic java.lang.StringGITCR_PRIORITYPriority of the repository within the repository chain.static java.lang.StringGITCR_PWDPassword for authentication at the repositorystatic java.lang.StringGITCR_REFA Git ref to fetch and check out as active content.static java.lang.StringGITCR_ROOTSA comma separated list of folders in the repo to search for components.static java.lang.StringGITCR_TIMEOUTnetwork timeout-value in seconds.static java.lang.StringGITCR_URIURI of the git source repository.static java.lang.StringGITCR_USERUser name for authentication at the repository
-
Constructor Summary
Constructors Constructor Description GitComponentRepositoryImpl(java.lang.String name, java.util.Properties props)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.PropertiesgetExpectedConfiguration()provided expected repository configuration.java.lang.StringgetLabel()java.io.FilegetLocalRepo()static java.lang.StringgetRef(java.lang.String name, java.util.Properties props)com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDBscan(com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDB current)Scans for changes in this GitCR which implies: ifcurrentisnullthe source repository will be cloned into the repository cache if the repositoryjava.lang.StringtoString()-
Methods inherited from class com.zfabrik.components.provider.fs.AbstractFileSystemComponentRepository
download, getRoots, setRoots
-
Methods inherited from class com.zfabrik.components.provider.util.AbstractExtComponentRepository
as, checkOfflineMode, complete, configure, configure, configure, findComponents, getCacheRoot, getComponent, getContext, getDB, getModules, getName, getRevision, getRevision, getURL, has, isRelaxedMode, preInvalidation, preInvalidation, retrieve, setEvictionDelay, start, stop, test_setContext, test_setDb, test_setInited
-
-
-
-
Field Detail
-
GITCR_ROOTS
public static final java.lang.String GITCR_ROOTS
A comma separated list of folders in the repo to search for components. Can be left empty, if the repo is only at top level. Otherwise a list in order of decreasing priority can be given.- See Also:
- Constant Field Values
-
GITCR_URI
public static final java.lang.String GITCR_URI
URI of the git source repository.- See Also:
- Constant Field Values
-
GITCR_PRIORITY
public static final java.lang.String GITCR_PRIORITY
Priority of the repository within the repository chain. SeeIComponentsRepository. Both gitcr.priority and gitcr.prio are valid keys.- See Also:
- Constant Field Values
-
GITCR_PRIO
public static final java.lang.String GITCR_PRIO
- See Also:
- Constant Field Values
-
GITCR_BRANCH
public static final java.lang.String GITCR_BRANCH
Branch to clone from the source repository. Setting this is equivalent to settingGITCR_REFwith the branch name prefixed byrefs/heads/.- See Also:
- Constant Field Values
-
GITCR_REF
public static final java.lang.String GITCR_REF
A Git ref to fetch and check out as active content. This can be a tag (refs/tags/<tag name>), or a branch (refs/heads/<branch name>) or HEAD for the default branch. For compatibility, it can also be a remote tracking branch (refs/remotes/origin/<branch name>ororigin/<branch name>).As this information is used to compute a ref spec, this may not be a single commit, as git fetch requires some form of ref.
In particular this can be "HEAD" to simply follow the remote default branch!
Use this option, if you need more control than given bygitcr.branch. Note that the latter will be used with preference and hence needs to be omitted, if you want to usegitcr.ref.- See Also:
- Constant Field Values
-
GITCR_USER
public static final java.lang.String GITCR_USER
User name for authentication at the repository- See Also:
- Constant Field Values
-
GITCR_PWD
public static final java.lang.String GITCR_PWD
Password for authentication at the repository- See Also:
- Constant Field Values
-
GITCR_OPTIONAL
public static final java.lang.String GITCR_OPTIONAL
If set to 'true', the gitcr will be ignore silently if the defined gitcr.uri is invalid. Defaults to 'true', in which case only a warning is logged, when the origin repository is not reachable.- See Also:
- Constant Field Values
-
GITCR_TIMEOUT
public static final java.lang.String GITCR_TIMEOUT
network timeout-value in seconds. Defaults to 10seconds.- See Also:
- Constant Field Values
-
-
Method Detail
-
getExpectedConfiguration
protected java.util.Properties getExpectedConfiguration()
Description copied from class:com.zfabrik.components.provider.util.AbstractExtComponentRepositoryprovided expected repository configuration. This property set is used by theFSComponentRepositoryHelperto make a decision on whether the repository cache is still valid. Any change in repository configuration between repository initialization will be taken as reason to completely purge the local repository. By default this method returns the complete repository configuration.- Overrides:
getExpectedConfigurationin classcom.zfabrik.components.provider.util.AbstractExtComponentRepository<com.zfabrik.components.provider.fs.RootBoundFSCRComponent,com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDB>
-
scan
public com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDB scan(com.zfabrik.components.provider.fs.MultiRootFSComponentRepositoryDB current)
Scans for changes in this GitCR which implies:- if
currentisnullthe source repository will be cloned into the repository cache - if the repository
- Overrides:
scanin classcom.zfabrik.components.provider.fs.AbstractFileSystemComponentRepository
- if
-
getLocalRepo
public java.io.File getLocalRepo()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classcom.zfabrik.components.provider.fs.AbstractFileSystemComponentRepository
-
getLabel
public java.lang.String getLabel()
-
getRef
public static java.lang.String getRef(java.lang.String name, java.util.Properties props)
-
-