TCR scripts - the way I do it. Inspired by Kent Beck's Limbo on the Cheap, Test && Commit || Revert, and Thomas Deniffel.
This is written for projects with a supported build wrapper, and used on MacOS.
tcr is the main command. It compiles, verifies, commits on a green run, and notifies plus reverts production-code changes on a red run.
buildIt: Compiles production and test code throughbuildTool.testIt: Stages current changes, runs verification, and unstages changes before returning failure when verification fails.buildTool: Finds the project build wrapper and runs the matching TCR command.commitIt: Opens the commit dialog. I use Arlo's Commit Notation.revertIt: Preserves non-production changes, stashes reverted production changes with thetcr-revert-backupmessage, and usesTCR_PROD_PATHto identify production code.success: Sends a MacOS success notification.failure: Sends a MacOS failure notification and exits nonzero.buddy: Waits for a file change underTCR_WATCH_PATHbefore runningtcr. Requiresfswatch.collab: Repeatedly pulls with rebase/autostash, pushes only after a successful pull, then sleeps for 30 seconds.
buildTool auto-detects wrappers in this order:
./gradlew:testClassesfor compile,buildfor verify./mvnw:test-compilefor compile,verifyfor verify
Set TCR_BUILD_TOOL to force one when a project has multiple wrappers:
TCR_BUILD_TOOL=maven tcr
The default layout is a JVM-style project with watched files under src and production code under src/main. Override these when a project uses another layout:
TCR_WATCH_PATH: path watched bybuddy; defaults tosrc.TCR_PROD_PATH: path treated as production code byrevertIt; defaults tosrc/main.TCR_STASH_MESSAGE: stash message used byrevertIt; defaults totcr-revert-backup.