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

Better communication of exceptions in GitDirLocator #228

Open
rehevkor5 opened this issue Nov 17, 2023 · 0 comments
Open

Better communication of exceptions in GitDirLocator #228

rehevkor5 opened this issue Nov 17, 2023 · 0 comments

Comments

@rehevkor5
Copy link

Was experiencing a strange failure:

> Error while evaluating property 'generatedProperties' of task ':generateGitProperties'.
   > No Git repository found.

This was occurring despite a .git directory being present.

After re-running with --debug, I observed an exception like so:

java.io.FileNotFoundException: /Users/myuser/.gitconfig (Permission denied)
        at java.base/java.io.FileInputStream.open0(Native Method)
        at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
        at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
        at gradlegitproperties.org.eclipse.jgit.util.io.SilentFileInputStream.<init>(SilentFileInputStream.java:31)
        at gradlegitproperties.org.eclipse.jgit.util.IO.readFully(IO.java:101)
        at gradlegitproperties.org.eclipse.jgit.util.IO.readFully(IO.java:48)
        at gradlegitproperties.org.eclipse.jgit.storage.file.FileBasedConfig.load(FileBasedConfig.java:127)
        at gradlegitproperties.org.eclipse.jgit.util.SystemReader.updateAll(SystemReader.java:390)
        at gradlegitproperties.org.eclipse.jgit.util.SystemReader.getUserConfig(SystemReader.java:316)
        at gradlegitproperties.org.eclipse.jgit.internal.storage.file.FileRepository.<init>(FileRepository.java:161)
        at gradlegitproperties.org.eclipse.jgit.lib.BaseRepositoryBuilder.build(BaseRepositoryBuilder.java:625)
        at gradlegitproperties.org.eclipse.jgit.api.Git.open(Git.java:93)
        at gradlegitproperties.org.eclipse.jgit.api.Git.open(Git.java:73)
        at gradlegitproperties.org.eclipse.jgit.api.Git$open.call(Unknown Source)
        at gradlegitproperties.org.ajoberstar.grgit.operation.OpenOp.call(OpenOp.groovy:46)
        at gradlegitproperties.org.ajoberstar.grgit.operation.OpenOp.call(OpenOp.groovy)
        at java_util_concurrent_Callable$call.call(Unknown Source)
        at gradlegitproperties.org.ajoberstar.grgit.internal.OpSyntax.mapOperation(OpSyntax.groovy:20)
        at gradlegitproperties.org.ajoberstar.grgit.internal.OpSyntax$mapOperation.callStatic(Unknown Source)
        at gradlegitproperties.org.ajoberstar.grgit.Grgit.open(Grgit.groovy)
        at gradlegitproperties.org.ajoberstar.grgit.Grgit$open.call(Unknown Source)
        at com.gorylenko.GitDirLocator.lookupGitDirectory(GitDirLocator.groovy:23)
        at com.gorylenko.GitDirLocator$lookupGitDirectory.call(Unknown Source)
        at com.gorylenko.GenerateGitPropertiesTask.getDotGitDirectory(GenerateGitPropertiesTask.groovy:155)
        at com.gorylenko.GenerateGitPropertiesTask.getSource(GenerateGitPropertiesTask.groovy:58)
        at com.gorylenko.GenerateGitPropertiesTask_Decorated.getSource(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.gradle.api.internal.tasks.properties.bean.AbstractNestedRuntimeBeanNode$BeanPropertyValue$1$1.create(AbstractNestedRuntimeBeanNode.java:77)
        at org.gradle.internal.deprecation.DeprecationLogger.whileDisabled(DeprecationLogger.java:256)
...

(truncated Gradle call stack for brevity)

So, turns out my recent migration to a new laptop led to incorrect permissions on my ~/.gitconfig file, and this manifests as the confusing "No Git repository found." error.

So, it's easy to fix. But it looks like better exception handling inside of com.gorylenko.GitDirLocator.lookupGitDirectory would probably result in a more informative error message.

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