phillipuniverse / githook-maven-plugin

Maven plugin to install local git hooks
MIT License
28 stars 1 forks source link

Do nothing on missing .git directory #11

Closed fuglu closed 4 years ago

fuglu commented 4 years ago

When building applications with Docker, the .git directory will be excluded in most cases. Currently the plugin fails with the message Not a git repository, could not find a .git/hooks directory anywhere.

It would be great if we could just issue a warning instead of aborting the build if the .git directory is missing.

Of course, a special Maven profile could work around this problem, but for the sake of simplicity, let's modify the plugin.

Husky (the Node.js equivalent of githook-maven-plugin) already supports this behavior, and we use it frequently.

phillipuniverse commented 4 years ago

Solid use case, thanks for taking the time to open an issue.

I think I would like to solve this with a configuration property that has a default of the current behavior (exception) but the ability to ignore it completely.

I'll try to get this done sooner rather than later (I'm shooting for sometime this week) but a PR is always welcome!

phillipuniverse commented 4 years ago

@fuglu this is now fixed, I would expect you to use it like this:

<plugin>
    <groupId>io.github.phillipuniverse</groupId>
    <artifactId>githook-maven-plugin</artifactId>
    <version>1.0.5-SNAPSHOT</version>
    <executions>
        <execution>
            <goals>
                <goal>install</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <skipRepositoryCheck>true</skipRepositoryCheck>
    </configuration>
</plugin>

This should now be on Maven Central in the snapshot repository, so you can get to it right away by adding the repository to your pom. I will release a 1.0.5 sometime tomorrow but it would be great to get some verification from you.

Thanks again for the issue!