From 86090af95543a76dc5a400c99a28a43a501fe2c2 Mon Sep 17 00:00:00 2001 From: Luke Whittington Date: Tue, 5 Feb 2019 22:02:27 +0000 Subject: [PATCH] #5 Add StandardCopyOption to allow git hooks to be overriden. --- src/main/java/com/rudikershaw/gitbuildhook/InstallMojo.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/rudikershaw/gitbuildhook/InstallMojo.java b/src/main/java/com/rudikershaw/gitbuildhook/InstallMojo.java index 36131d2..8d296d3 100644 --- a/src/main/java/com/rudikershaw/gitbuildhook/InstallMojo.java +++ b/src/main/java/com/rudikershaw/gitbuildhook/InstallMojo.java @@ -3,6 +3,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoFailureException; @@ -99,7 +100,8 @@ public void execute() throws MojoFailureException { private void installGitHook(final GitHookType hookType, final String filePath, final String hooksDirectory) { if (filePath != null) { try { - Files.copy(Paths.get(filePath), Paths.get(hooksDirectory + "/" + hookType.getHookFileName())); + Files.copy(Paths.get(filePath), Paths.get(hooksDirectory + "/" + hookType.getHookFileName()), + StandardCopyOption.REPLACE_EXISTING); } catch (final IOException e) { getLog().warn("Could not move file into .git/hooks directory", e); }