You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently applying the plugin throws an exception if the project is not inside a git repository (i.e. .git folder is missing).
What did you want to happen?
It would be nice if it was possible to define/enable some kind of fallback version (for example "UNKNOWN") if the git repo can't be found. gitVersion() would then return this fallback version. versionDetails() could either return null if the git repo is missing or include a boolean field indicating if the repo was found and empty/default values for other fields.
Alternatively just pushing the exception into gitVersion() and versionDetails() instead of throwing it as soon as the plugin is applied would make it much cleaner for people to manually implement fallback version support using a try-catch block.
This would be useful in cases where you for whatever reason have the code without the git repo and want to run a build and don't care about the version.
One possible use case for this as pointed out in #327 is running unit tests in the CI where code might be copied in without the git repo itself.
Also in general the current behavior forces you to be constantly paranoid about copying the code and the git repo together no matter what you actually want to do with the code.
The text was updated successfully, but these errors were encountered:
A project may have tags v1.1.1 style release tags.
When users, who is outside of the project, download source archive from GitHub Download zip feature,
THe users will find a .git-archival.propertries file like
def dotgit = project.file(".git")
if (dotgit.exists()) {
apply plugin: 'com.palantir.git-version'// calculate version string from git tag, hash and commit distance// It treat as release tag when current HEAD has a tag,// and repository is clean, no modification,and no untracked files,if (versionDetails().isCleanTag) {
// drop first 'v' from version tag
version = gitVersion().substring(1)
} else {
version = versionDetails().lastTag.substring(1) +'-'+ versionDetails().commitDistance +'-'+ versionDetails().gitHash +'-SNAPSHOT'
}
} else {
def gitArchival = project.file(".git-archival.properties")
def prop =newProperties()
prop.load(newFileInputStream(gitArchival))
def versionDescribe = prop.getProperty("describe")
def matcher = versionDescribe =~/^v\d+\.\d+\.\d+$/
version = matcher.find() ? versionDescribe.substring(1) : versionDescribe.substring(1) +"-SNAPSHOT"
}
You will get version variable even when it is not a git work directory.
I hope gradle-git-version plugin handles .git-archival.properties automatically and put these tips on document.
What happened?
Currently applying the plugin throws an exception if the project is not inside a git repository (i.e. .git folder is missing).
What did you want to happen?
It would be nice if it was possible to define/enable some kind of fallback version (for example "UNKNOWN") if the git repo can't be found.
gitVersion()
would then return this fallback version.versionDetails()
could either return null if the git repo is missing or include a boolean field indicating if the repo was found and empty/default values for other fields.Alternatively just pushing the exception into
gitVersion()
andversionDetails()
instead of throwing it as soon as the plugin is applied would make it much cleaner for people to manually implement fallback version support using a try-catch block.This would be useful in cases where you for whatever reason have the code without the git repo and want to run a build and don't care about the version.
One possible use case for this as pointed out in #327 is running unit tests in the CI where code might be copied in without the git repo itself.
Also in general the current behavior forces you to be constantly paranoid about copying the code and the git repo together no matter what you actually want to do with the code.
The text was updated successfully, but these errors were encountered: