Preserve trailing newlines and restore connections.env via git checkout on down
Fix set_local_db/set_dot_env unconditionally stripping (then forcing) the file's trailing newline: they now detect whether the source file originally ended in a newline and reproduce that on write, verified against both the newline and no-newline cases. Replace the reverse-toggle computation for connections.env on `down` with a straight `git checkout`, so the file always ends up byte-for-byte identical to HEAD instead of relying on toggle logic to get it exactly right. Both git call sites now go through a shared helper that checks the process exit status and errors out instead of silently reporting success on a failed checkout/update-index, with test coverage against real temporary git repos.
This commit is contained in:
@@ -56,7 +56,7 @@ dev_tools foo down
|
||||
## What it does
|
||||
|
||||
1. Starts or stops the Docker Compose service defined by `DOCKER_SERVICE` / `DOCKER_DIR`.
|
||||
2. Modifies `conf/global/connections.env` and marks it with `git update-index --assume-unchanged` to avoid accidental commits.
|
||||
2. `conf/global/connections.env`: `up` toggles it to the CI credentials and marks it `git update-index --assume-unchanged` to avoid accidental commits; `down` unmarks it and restores it to its committed state with `git checkout` (rather than computing the reverse toggle), so it's guaranteed byte-for-byte identical to HEAD.
|
||||
3. Toggles database connection entries in `<PROJECT_DIR>/conf/local/.env`: `up` switches the connection to `ci`, `down` switches it to `staging`.
|
||||
|
||||
## Tests
|
||||
|
||||
Reference in New Issue
Block a user