From 0bde2ab6b6cc2acefa5445fca49f8f3c9c90281a Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Mon, 11 Oct 2021 17:42:00 +0200 Subject: [PATCH] respect create: false in install --temp for #326 --- docs/usage.md | 2 +- dotdrop/dotdrop.py | 3 ++- dotdrop/installer.py | 12 ++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 9d73cd4..68e4dd0 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -84,7 +84,7 @@ A dotfile will be installed only if it differs from the version already present Some available options: * `-t`/`--temp`: Install the dotfile(s) to a temporary directory for review (helping to debug templating issues, for example). - Note that actions are not executed in this mode and the config entry `create` is always considered to be `true`. + Note that actions are not executed in this mode. * `-a`/`--force-actions`: Force the execution of actions even if the dotfiles are not installed * `-f`/`--force`: Do not ask for any confirmation diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index f5a65cf..2aecd62 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -145,7 +145,8 @@ def _dotfile_compare(opts, dotfile, tmp): # install dotfile to temporary dir for compare ret, err, insttmp = inst.install_to_temp(templ, tmp, src, dotfile.dst, is_template=True, - chmod=dotfile.chmod) + chmod=dotfile.chmod, + set_create=True) if not ret: # failed to install to tmp line = '=> compare {} error: {}' diff --git a/dotdrop/installer.py b/dotdrop/installer.py index 9c89132..466d2e7 100644 --- a/dotdrop/installer.py +++ b/dotdrop/installer.py @@ -185,7 +185,8 @@ class Installer: return self._log_install(ret, err) def install_to_temp(self, templater, tmpdir, src, dst, - is_template=True, chmod=None, ignore=None): + is_template=True, chmod=None, ignore=None, + set_create=False): """ install a dotfile to a tempdir @@ -196,6 +197,7 @@ class Installer: @is_template: this dotfile is a template @chmod: rights to apply if any @ignore: patterns to ignore + @set_create: force create to True return - success, error-if-any, dotfile-installed-path @@ -215,8 +217,9 @@ class Installer: self.dry = False diffsaved = self.diff self.diff = False - createsaved = self.create - self.create = True + if set_create: + createsaved = self.create + self.create = True totemp = self.totemp self.totemp = None @@ -232,7 +235,8 @@ class Installer: # restore flags self.dry = drysaved self.diff = diffsaved - self.create = createsaved + if set_create: + self.create = createsaved self.comparing = False self.totemp = totemp