Skip to content

Commit

Permalink
Rename (incompatibly) more things to "greencently".
Browse files Browse the repository at this point in the history
  • Loading branch information
schmonz committed Nov 27, 2024
1 parent 84656a0 commit 0c02f32
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ bin/
.DS_Store

### Greencently
*when-all-tests-were-green*
*greencently*
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ tasks.withType<Test> {
}
```
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
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/schmonz/greencently/Timestamp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit 0c02f32

Please sign in to comment.