Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous handling of missing Git repository with org.ajoberstar.grgit.service plugin #391

Closed
Vampire opened this issue Jun 29, 2023 · 0 comments

Comments

@Vampire
Copy link
Contributor

Vampire commented Jun 29, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant