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

Configuration option to set overwrite #6

Open
dwightmulcahy opened this issue Feb 9, 2019 · 2 comments
Open

Configuration option to set overwrite #6

dwightmulcahy opened this issue Feb 9, 2019 · 2 comments

Comments

@dwightmulcahy
Copy link

something like this

                        <configuration>
                            <overwrite>true</overwrite>     <==== true/false
                            <hooks>
                             ...
                            </hooks>
                        </configuration>

should create an ERROR (but continue) if overwrite==true and file exists...

@dwightmulcahy
Copy link
Author

dwightmulcahy commented Feb 9, 2019

depending on if #7 is implemented it might be better to have something like <overwrite-strategy> that would allow overwrite, chain, backup, etc...

@phillipuniverse
Copy link
Owner

Somewhat related to this, the plugin shouldn't do anything at all if the hash of the existing hook matches what it's trying to write (only do file modifications if necessary).

Also, I think the default behavior should be to overwrite, but maybe warn or prompt or something if it's the first time it's happening? There are 2 use cases of "existing" hooks:

A hook that this plugin didn't write

  1. User throws the plugin into their pom.xml
  2. We try to install the hook; oh wait there's already an existing hook there, the user forgot that they had it. Maybe we error on this case?

A hook the plugin did write, but now there's an update

  1. User has been using the plugin just fine, hooks are happening
  2. They need to update the hook that the plugin manages, this should always overwrite

Use case: maybe the pre-commit hook takes a few seconds to run, v1 of the hook doesn't have any progress indicators, now the user writes v2 with progress indicators

Maybe we can differentiate between those 2 cases with a comment at the top of the file like #written by githook-maven-plugin. Need to think about upgradeability though, people have been using this plugin already and their existing hooks will not have this header.

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

2 participants