diff --git a/.gitignore b/.gitignore index e764695..73547ff 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,4 @@ bin/ .DS_Store ### Greencently -*when-all-tests-were-green* +*greencently* diff --git a/README.md b/README.md index 8b55c3d..b3ee5ef 100644 --- a/README.md +++ b/README.md @@ -32,20 +32,20 @@ tasks.withType { } ``` 2. Run all tests in project -3. If green, observe top-level timestamp file `.when-all-tests-were-green-junit5` -4. Append to top-level `.gitignore`: `*when-all-tests-were-green*` +3. If green, observe top-level timestamp file `.greencently-junit5` +4. Append to top-level `.gitignore`: `*greencently*` 5. Observe `git status` _not_ showing timestamp file 6. In pre-commit hook, inspect file modification time. Example: ```sh #!/bin/sh -all_tests_were_recently_green() { +greencently() { too_many_seconds_ago=$1 - thenstamp=$(date -r .when-all-tests-were-green-junit5 '+%s' 2>/dev/null || echo 0) + thenstamp=$(date -r .greencently-junit5 '+%s' 2>/dev/null || echo 0) nowstamp=$(date '+%s') secondsago=$(expr ${nowstamp} - ${thenstamp}) [ ${secondsago} -lt ${too_many_seconds_ago} ] } -if all_tests_were_recently_green 30; then +if greencently 30; then ./gradlew clean build -x test else ./gradlew clean build diff --git a/src/main/kotlin/com/schmonz/greencently/Timestamp.kt b/src/main/kotlin/com/schmonz/greencently/Timestamp.kt index 8b45bda..6547ad8 100644 --- a/src/main/kotlin/com/schmonz/greencently/Timestamp.kt +++ b/src/main/kotlin/com/schmonz/greencently/Timestamp.kt @@ -7,7 +7,7 @@ import kotlin.io.path.setLastModifiedTime class Timestamp(suffix: String) { private val path = Paths.get(System.getProperty("user.dir")) - .resolve(".when-all-tests-were-green-$suffix") + .resolve(".greencently-$suffix") private fun modifyFile() = path.setLastModifiedTime(FileTime.from(Instant.now()))