As soon as you call grgitService.service.get(), you get a hard "java.lang.IllegalStateException: No .git directory found!" exception as described in #362.
But there is more strange behavior.
In the GrgitService instance registered by the GrgitServicePlugin, currentDirectory is always set, so GrgitService just expects that a Git repository is available.
If you register a new instance of the service like
gradle.sharedServices.registerIfAbsent("customGrgit", GrgitService::class) {
parameters {
initIfNotExists = true
}
}.get()
you get a "MissingValueException: Cannot query the value of this property because it has no value available." as directory is expected to have some value.
If I change it to
gradle.sharedServices.registerIfAbsent("customGrgit", GrgitService::class) {
parameters {
directory = layout.projectDirectory
initIfNotExists = true
}
}.get()
it checks that directory exists and again just expects that a Git repository is available in that directory so fails with "RepositoryNotFoundException: repository not found: D:\Sourcecode\other\showcase"
If I instead try with
gradle.sharedServices.registerIfAbsent("customGrgit", GrgitService::class) {
parameters {
directory = layout.projectDirectory.dir(".git")
initIfNotExists = true
}
}.get()
then it is recognized that .git/ is missing, so it does a git init within that directory, resulting in D:\Sourcecode\other\showcase\.git\.git being created and after that "IllegalStateException: No .git directory found!" from first line here.