Skip to content

Commit

Permalink
chore: diff template -> source
Browse files Browse the repository at this point in the history
  • Loading branch information
ditsuke committed Mar 21, 2023
1 parent 856bfe2 commit 996c681
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crossterm::style::Stylize;
use handlebars::Handlebars;

use crate::config::{SymbolicTarget, TemplateTarget, Variables};
use crate::difference;
use crate::difference::{self, diff_nonempty, generate_template_diff, print_diff};
use crate::filesystem::{Filesystem, SymlinkComparison, TemplateComparison};

#[cfg_attr(test, mockall::automock)]
Expand Down Expand Up @@ -537,22 +537,21 @@ pub fn update_template(
TemplateComparison::Changed => {
// At this point, we're not sure if there's a difference between the rendered source
// and target, only that the target has been modified in some way.
let diff = difference::generate_diff(source, target, handlebars, variables)
.context("diff source with target")?;
if difference::diff_nonempty(&diff) {
let diff = generate_template_diff(source, target, handlebars, variables, false)
.context("diff source and target")?;
if diff_nonempty(&diff) {
error!(
"Updating template {:?} -> {:?} but {}. Skipping.",
"Updating template {:?} -> {:?} but {}. Skipping",
source, target.target, comparison
);
info!(
"{} template {:?} -> {:?}",
"[~].yellow()", source, target.target,
);
difference::print_diff(diff, diff_context_lines);
if log_enabled!(log::Level::Info) {
info!("Refusing because of the following changes in source: ");
print_diff(diff, diff_context_lines);
}
Ok(false)
} else {
perform_template_deploy(source, cache, target, fs, handlebars, variables)
.context("perform template acche")?;
.context("perform template cache")?;
Ok(true)
}
}
Expand Down

0 comments on commit 996c681

Please sign in to comment.