File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
src/main/scala/uk/co/randomcoding/sbt Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -56,12 +56,14 @@ object GitHooks extends AutoPlugin {
56
56
object WriteGitHooks {
57
57
58
58
def apply (hooksSourceDir : File , hooksTargetDir : File , log : ManagedLogger ): Unit = {
59
- log.info(s " Copying hooks from ${hooksSourceDir.getAbsolutePath} into ${hooksTargetDir.getAbsolutePath}" )
60
- Option (hooksSourceDir.listFiles).map(_.toList).getOrElse(Nil ).foreach { hook =>
61
- val hookTarget = hooksTargetDir.toPath.resolve(hook.getName)
62
- log.info(s " Copying ${hook.getName} to $hookTarget" )
63
- Files .copy(hook.toPath, hookTarget, StandardCopyOption .REPLACE_EXISTING )
64
- if (! Properties .isWin) Files .setPosixFilePermissions(hookTarget, PosixFilePermissions .fromString(" rwxr-xr-x" ))
65
- }
59
+ if (hooksTargetDir.exists()) {
60
+ log.info(s " Copying hooks from ${hooksSourceDir.getAbsolutePath} into ${hooksTargetDir.getAbsolutePath}" )
61
+ Option (hooksSourceDir.listFiles).map(_.toList).getOrElse(Nil ).foreach { hook =>
62
+ val hookTarget = hooksTargetDir.toPath.resolve(hook.getName)
63
+ log.info(s " Copying ${hook.getName} to $hookTarget" )
64
+ Files .copy(hook.toPath, hookTarget, StandardCopyOption .REPLACE_EXISTING )
65
+ if (! Properties .isWin) Files .setPosixFilePermissions(hookTarget, PosixFilePermissions .fromString(" rwxr-xr-x" ))
66
+ }
67
+ } else log.info(s " ${hooksTargetDir.getPath} does not exist (possibly within a submodule). Not writing any hooks. " )
66
68
}
67
69
}
You can’t perform that action at this time.
0 commit comments