Class GitVersionService
-
- All Implemented Interfaces:
public final class GitVersionServiceCalculate the version from a Git Repository. The repository uses GitFlow for the development. The start parameter is the local source directory.
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringheadsPrefixpublic final static IntegerstringLengthpublic final static IntegershaLengthpublic final static IntegerradixLengthprivate final Gitclientprivate final Repositoryrepositoryprivate final Stringbranchprivate StringmainBranchprivate StringdevelopBranchprivate StringmajorBranchprivate StringhotfixPrefixprivate StringfeaturePrefixprivate StringreleasePrefixprivate StringsupportPrefixprivate StringversionPrefixprivate Stringseparatorprivate BooleanlocalOnlyprivate Booleanfullbranchprivate VersiondefaultVersionprivate StringsourceBranchprivate StringpullRequestIDprivate StringbuildIDprivate BooleanisMergeBuildprivate final StringversionWithIDprivate final Stringversionprivate final StringcontainerVersionprivate final StringrevIDprivate final StringpreviousVersion
-
Constructor Summary
Constructors Constructor Description GitVersionService(File directory, VersionType versionType)creates the service from a directory GitVersionService(File directory)creates the service from a directory
-
Method Summary
Modifier and Type Method Description final GitgetClient()Git client for the existing working copy. final RepositorygetRepository()Repository for the existing working copy. final StringgetBranch()This is the current branch name. final StringgetMainBranch()Name of the main branch. final UnitsetMainBranch(String mainBranch)Name of the main branch. final StringgetDevelopBranch()Name of the develop branch. final UnitsetDevelopBranch(String developBranch)Name of the develop branch. final StringgetMajorBranch()Name/path of the feature branch with major changes for the next major version. final UnitsetMajorBranch(String majorBranch)Name/path of the feature branch with major changes for the next major version. final StringgetHotfixPrefix()Prefix of a hotfix branch. final UnitsetHotfixPrefix(String hotfixPrefix)Prefix of a hotfix branch. final StringgetFeaturePrefix()Prefix of a feature branch. final UnitsetFeaturePrefix(String featurePrefix)Prefix of a feature branch. final StringgetReleasePrefix()Prefix of a release branch. final UnitsetReleasePrefix(String releasePrefix)Prefix of a release branch. final StringgetSupportPrefix()Prefix of a support branch. final UnitsetSupportPrefix(String supportPrefix)Prefix of a support branch. final StringgetVersionPrefix()Prefix of a version tag. final UnitsetVersionPrefix(String versionPrefix)Prefix of a version tag. final StringgetSeparator()Separator for prefix and branch name. final UnitsetSeparator(String separator)Separator for prefix and branch name. final BooleangetLocalOnly()Version can be set for development to local only. final UnitsetLocalOnly(Boolean localOnly)Version can be set for development to local only. final BooleangetFullbranch()Version is shortened for branches and hotfixes with a hash for the string if shortened is true. final UnitsetFullbranch(Boolean fullbranch)Version is shortened for branches and hotfixes with a hash for the string if shortened is true. final VersiongetDefaultVersion()Default version. final UnitsetDefaultVersion(Version defaultVersion)Default version. final StringgetSourceBranch()Source Branch Name Default value is an empty string. final UnitsetSourceBranch(String sourceBranch)Source Branch Name Default value is an empty string. final StringgetPullRequestID()Pull Request ID Default value is an empty string. final UnitsetPullRequestID(String pullRequestID)Pull Request ID Default value is an empty string. final StringgetBuildID()Build ID for Pull Requests and unique container version Default value is an empty string. final UnitsetBuildID(String buildID)Build ID for Pull Requests and unique container version Default value is an empty string. final BooleanisMergeBuild()This must be set to true, if the version should be calculated for a pull request. final UnitsetMergeBuild(Boolean isMergeBuild)This must be set to true, if the version should be calculated for a pull request. final StringgetVersionWithID()This is the calculated version of the Git repository. final StringgetVersion()This is the calculated version of the Git repository. final StringgetContainerVersion()This is the calculated containerVersion of the Git repository. final StringgetRevID()final StringgetPreviousVersion()This is the calculated previous version from the Git repository. final RevCommitgetRevObjectFrom(Version version)Calculates the commit for a specified version. -
-
Constructor Detail
-
GitVersionService
GitVersionService(File directory, VersionType versionType)
creates the service from a directory- Parameters:
directory- local source directoryversionType- default value com.intershop.release.version.VersionType.fourDigits.
-
GitVersionService
GitVersionService(File directory)
creates the service from a directory- Parameters:
directory- local source directory
-
-
Method Detail
-
getClient
final Git getClient()
Git client for the existing working copy.
-
getRepository
final Repository getRepository()
Repository for the existing working copy.
-
getMainBranch
final String getMainBranch()
Name of the main branch. Default value is master.
-
setMainBranch
final Unit setMainBranch(String mainBranch)
Name of the main branch. Default value is master.
-
getDevelopBranch
final String getDevelopBranch()
Name of the develop branch. Default value is develop.
-
setDevelopBranch
final Unit setDevelopBranch(String developBranch)
Name of the develop branch. Default value is develop.
-
getMajorBranch
final String getMajorBranch()
Name/path of the feature branch with major changes for the next major version. The branch starts with feature.
-
setMajorBranch
final Unit setMajorBranch(String majorBranch)
Name/path of the feature branch with major changes for the next major version. The branch starts with feature.
-
getHotfixPrefix
final String getHotfixPrefix()
Prefix of a hotfix branch. Default value is hotfix.
-
setHotfixPrefix
final Unit setHotfixPrefix(String hotfixPrefix)
Prefix of a hotfix branch. Default value is hotfix.
-
getFeaturePrefix
final String getFeaturePrefix()
Prefix of a feature branch. Default value is feature.
-
setFeaturePrefix
final Unit setFeaturePrefix(String featurePrefix)
Prefix of a feature branch. Default value is feature.
-
getReleasePrefix
final String getReleasePrefix()
Prefix of a release branch. Default value is release.
-
setReleasePrefix
final Unit setReleasePrefix(String releasePrefix)
Prefix of a release branch. Default value is release.
-
getSupportPrefix
final String getSupportPrefix()
Prefix of a support branch. Default value is support.
-
setSupportPrefix
final Unit setSupportPrefix(String supportPrefix)
Prefix of a support branch. Default value is support.
-
getVersionPrefix
final String getVersionPrefix()
Prefix of a version tag. Default value is version.
-
setVersionPrefix
final Unit setVersionPrefix(String versionPrefix)
Prefix of a version tag. Default value is version.
-
getSeparator
final String getSeparator()
Separator for prefix and branch name. Default value is /.
-
setSeparator
final Unit setSeparator(String separator)
Separator for prefix and branch name. Default value is /.
-
getLocalOnly
final Boolean getLocalOnly()
Version can be set for development to local only.
-
setLocalOnly
final Unit setLocalOnly(Boolean localOnly)
Version can be set for development to local only.
-
getFullbranch
final Boolean getFullbranch()
Version is shortened for branches and hotfixes with a hash for the string if shortened is true.
-
setFullbranch
final Unit setFullbranch(Boolean fullbranch)
Version is shortened for branches and hotfixes with a hash for the string if shortened is true.
-
getDefaultVersion
final Version getDefaultVersion()
Default version. Default value is Version.Builder(versionType).build().
-
setDefaultVersion
final Unit setDefaultVersion(Version defaultVersion)
Default version. Default value is Version.Builder(versionType).build().
-
getSourceBranch
final String getSourceBranch()
Source Branch Name Default value is an empty string.
-
setSourceBranch
final Unit setSourceBranch(String sourceBranch)
Source Branch Name Default value is an empty string.
-
getPullRequestID
final String getPullRequestID()
Pull Request ID Default value is an empty string. Used to identify a merge build
-
setPullRequestID
final Unit setPullRequestID(String pullRequestID)
Pull Request ID Default value is an empty string. Used to identify a merge build
-
getBuildID
final String getBuildID()
Build ID for Pull Requests and unique container version Default value is an empty string. Used to identify a merge build
-
setBuildID
final Unit setBuildID(String buildID)
Build ID for Pull Requests and unique container version Default value is an empty string. Used to identify a merge build
-
isMergeBuild
final Boolean isMergeBuild()
This must be set to true, if the version should be calculated for a pull request. Therefore the following environment variables must be set: sourceBranch, pullRequestID, buildID
-
setMergeBuild
final Unit setMergeBuild(Boolean isMergeBuild)
This must be set to true, if the version should be calculated for a pull request. Therefore the following environment variables must be set: sourceBranch, pullRequestID, buildID
-
getVersionWithID
final String getVersionWithID()
This is the calculated version of the Git repository. If a buildID is specified for special branches a build id is added.
-
getVersion
final String getVersion()
This is the calculated version of the Git repository.
-
getContainerVersion
final String getContainerVersion()
This is the calculated containerVersion of the Git repository.
-
getPreviousVersion
final String getPreviousVersion()
This is the calculated previous version from the Git repository.
-
getRevObjectFrom
final RevCommit getRevObjectFrom(Version version)
Calculates the commit for a specified version.
- Parameters:
version- is version tag
-
-
-
-