From 5ff36efde2b2ebae9919b63bfc6e326d594d86e8 Mon Sep 17 00:00:00 2001 From: Shivam Kapoor Date: Sat, 27 Nov 2021 22:29:26 +0530 Subject: [PATCH 1/4] doc: invoke writeHooks on sbt load --- Readme.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 23bac73..8eaba25 100644 --- a/Readme.md +++ b/Readme.md @@ -18,7 +18,21 @@ Add the plugin to your build with the following in `project/plugins.sbt`: addSbtPlugin("uk.co.randomcoding" % "sbt-git-hooks" % "0.2.0") ``` -Then run the task `writeHooks` to copy the hooks into `.git/hooks` +Then run the task `writeHooks` to copy the hooks into `.git/hooks`. + +**Note**: Everytime there are modifications to custom git hooks, you are expected to run this `writeHooks` sbt task. This requirement however could be mitigated by invoking this task on every sbt load by adding following code to `build.sbt`: +```scala +lazy val startupTransition: State => State = { s: State => + "writeHooks" :: s +} + +onLoad in Global := { + val old = (onLoad in Global).value + startupTransition compose old +} +``` + +Now if you run `sbt` in your repository directory, `writeHooks` task will automically be called and your updated custom git hooks will be copied out-of-the-box. ### Licence From 4bf49d64c12276ceee64f23045598c7b30a68861 Mon Sep 17 00:00:00 2001 From: Shivam Kapoor Date: Sat, 27 Nov 2021 22:29:36 +0530 Subject: [PATCH 2/4] doc: invoke writeHooks on sbt load From 70b81357f54adc5280bd2ee0e1c926c09cd4be02 Mon Sep 17 00:00:00 2001 From: Shivam Kapoor Date: Sat, 27 Nov 2021 22:30:14 +0530 Subject: [PATCH 3/4] Update Readme.md --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 8eaba25..26ab7d3 100644 --- a/Readme.md +++ b/Readme.md @@ -20,7 +20,7 @@ addSbtPlugin("uk.co.randomcoding" % "sbt-git-hooks" % "0.2.0") Then run the task `writeHooks` to copy the hooks into `.git/hooks`. -**Note**: Everytime there are modifications to custom git hooks, you are expected to run this `writeHooks` sbt task. This requirement however could be mitigated by invoking this task on every sbt load by adding following code to `build.sbt`: +**Note**: Everytime there are modifications to custom git hooks, you are expected to run this `writeHooks` sbt task. This requirement however could be automated by invoking this task on every sbt load by adding following code to `build.sbt`: ```scala lazy val startupTransition: State => State = { s: State => "writeHooks" :: s From 38b34bb204e08579cba45febd504c8b12844d386 Mon Sep 17 00:00:00 2001 From: Shivam Kapoor Date: Sat, 27 Nov 2021 22:31:14 +0530 Subject: [PATCH 4/4] Update Readme.md --- Readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 26ab7d3..300bba3 100644 --- a/Readme.md +++ b/Readme.md @@ -20,7 +20,7 @@ addSbtPlugin("uk.co.randomcoding" % "sbt-git-hooks" % "0.2.0") Then run the task `writeHooks` to copy the hooks into `.git/hooks`. -**Note**: Everytime there are modifications to custom git hooks, you are expected to run this `writeHooks` sbt task. This requirement however could be automated by invoking this task on every sbt load by adding following code to `build.sbt`: +**Note**: Everytime there are modifications to custom git hooks, you are expected to run this `writeHooks` sbt task. This requirement however could be automated by invoking this task on every sbt load. To do so add following code to `build.sbt`: ```scala lazy val startupTransition: State => State = { s: State => "writeHooks" :: s @@ -32,7 +32,7 @@ onLoad in Global := { } ``` -Now if you run `sbt` in your repository directory, `writeHooks` task will automically be called and your updated custom git hooks will be copied out-of-the-box. +Now if you run `sbt` in your repository directory, `writeHooks` task will automically be called and your updated custom git hooks will be copied to `.git/hooks` out-of-the-box. ### Licence