diff --git a/Readme.md b/Readme.md index 0902fdf..23bac73 100644 --- a/Readme.md +++ b/Readme.md @@ -10,12 +10,12 @@ the hooks that are available. ### How to use -`sbt-git-hooks` is an auto plugin for SBT 1.0. +`sbt-git-hooks` is an auto plugin for SBT 1.1.x Add the plugin to your build with the following in `project/plugins.sbt`: ``` -addSbtPlugin("uk.co.randomcoding" % "sbt-git-hooks" % "0.1.0") +addSbtPlugin("uk.co.randomcoding" % "sbt-git-hooks" % "0.2.0") ``` Then run the task `writeHooks` to copy the hooks into `.git/hooks` diff --git a/build.sbt b/build.sbt index 29bb43c..c54d7c5 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,8 @@ name := "sbt-git-hooks" -version := "0.1.0" +version := "0.2.0" -scalaVersion := "2.12.3" +scalaVersion := "2.12.6" organization := "uk.co.randomcoding" diff --git a/project/build.properties b/project/build.properties index 306837d..5a1b382 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.0.1 +sbt.version = 1.1.6 diff --git a/src/main/scala/uk/co/randomcoding/sbt/GitHooks.scala b/src/main/scala/uk/co/randomcoding/sbt/GitHooks.scala index 5052943..9d16bb0 100644 --- a/src/main/scala/uk/co/randomcoding/sbt/GitHooks.scala +++ b/src/main/scala/uk/co/randomcoding/sbt/GitHooks.scala @@ -56,12 +56,14 @@ object GitHooks extends AutoPlugin { object WriteGitHooks { def apply(hooksSourceDir: File, hooksTargetDir: File, log: ManagedLogger): Unit = { - log.info(s"Copying hooks from ${hooksSourceDir.getAbsolutePath} into ${hooksTargetDir.getAbsolutePath}") - Option(hooksSourceDir.listFiles).map(_.toList).getOrElse(Nil).foreach { hook => - val hookTarget = hooksTargetDir.toPath.resolve(hook.getName) - log.info(s"Copying ${hook.getName} to $hookTarget") - Files.copy(hook.toPath, hookTarget, StandardCopyOption.REPLACE_EXISTING) - if (!Properties.isWin) Files.setPosixFilePermissions(hookTarget, PosixFilePermissions.fromString("rwxr-xr-x")) - } + if (hooksTargetDir.exists()) { + log.info(s"Copying hooks from ${hooksSourceDir.getAbsolutePath} into ${hooksTargetDir.getAbsolutePath}") + Option(hooksSourceDir.listFiles).map(_.toList).getOrElse(Nil).foreach { hook => + val hookTarget = hooksTargetDir.toPath.resolve(hook.getName) + log.info(s"Copying ${hook.getName} to $hookTarget") + Files.copy(hook.toPath, hookTarget, StandardCopyOption.REPLACE_EXISTING) + if (!Properties.isWin) Files.setPosixFilePermissions(hookTarget, PosixFilePermissions.fromString("rwxr-xr-x")) + } + } else log.info(s"${hooksTargetDir.getPath} does not exist (possibly within a submodule). Not writing any hooks.") } }