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:
+8
-2
@@ -5,7 +5,7 @@ use env::config::{load_config, DevToolsConf};
|
||||
use crate::{
|
||||
arguments::Arguments,
|
||||
config::parse::{set_dot_env, set_local_db},
|
||||
git::command::toggle_index,
|
||||
git::command::{restore_connections_env, toggle_index},
|
||||
};
|
||||
use clap::Parser;
|
||||
|
||||
@@ -23,8 +23,14 @@ fn main() -> Result<()> {
|
||||
|
||||
start_docker_compose(&config.container_service, &config.container_dir, start)?;
|
||||
|
||||
print!("{}", set_local_db(start, &config)?);
|
||||
if start {
|
||||
print!("{}", set_local_db(start, &config)?);
|
||||
}
|
||||
toggle_index(start, &config)?;
|
||||
if !start {
|
||||
restore_connections_env(&config)?;
|
||||
println!("[!] conf/global/connections.env restored to committed state.");
|
||||
}
|
||||
print!("{}", set_dot_env(start, &config)?);
|
||||
|
||||
println!(
|
||||
|
||||
Reference in New Issue
Block a user