From de05935ef1efa1bde32dbcbc80a46487dd825a8c Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Sun, 31 Dec 2023 14:14:00 +0100 Subject: [PATCH] force_chmod as global option to the installer --- dotdrop/dotdrop.py | 12 ++++++------ dotdrop/installer.py | 11 +++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index 91b7fe7..2ba4bd1 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -101,7 +101,8 @@ def _dotfile_compare(opts, dotfile, tmp): dry=opts.dry, base=opts.dotpath, workdir=opts.workdir, debug=opts.debug, backup_suffix=opts.install_backup_suffix, - diff_cmd=opts.diff_command) + diff_cmd=opts.diff_command, + force_chmod=True) comp = Comparator(diff_cmd=opts.diff_command, debug=opts.debug, ignore_missing_in_dotdrop=ignore_missing_in_dotdrop) @@ -234,8 +235,7 @@ def _dotfile_install(opts, dotfile, tmpdir=None): actionexec=pre_actions_exec, is_template=is_template, ignore=ignores, - chmod=dotfile.chmod, - force_chmod=opts.install_force_chmod) + chmod=dotfile.chmod) else: # nolink src = dotfile.src @@ -254,8 +254,7 @@ def _dotfile_install(opts, dotfile, tmpdir=None): noempty=dotfile.noempty, ignore=ignores, is_template=is_template, - chmod=dotfile.chmod, - force_chmod=opts.install_force_chmod) + chmod=dotfile.chmod) if tmp: tmp = os.path.join(opts.dotpath, tmp) if os.path.exists(tmp): @@ -765,7 +764,8 @@ def _get_install_installer(opts, tmpdir=None): showdiff=opts.install_showdiff, backup_suffix=opts.install_backup_suffix, diff_cmd=opts.diff_command, - remove_existing_in_dir=opts.install_remove_existing) + remove_existing_in_dir=opts.install_remove_existing, + force_chmod=opts.install_force_chmod) return inst diff --git a/dotdrop/installer.py b/dotdrop/installer.py index 22666a6..0e96c41 100644 --- a/dotdrop/installer.py +++ b/dotdrop/installer.py @@ -29,7 +29,7 @@ class Installer: dry=False, safe=False, workdir='~/.config/dotdrop', debug=False, diff=True, totemp=None, showdiff=False, backup_suffix='.dotdropbak', diff_cmd='', - remove_existing_in_dir=False): + remove_existing_in_dir=False, force_chmod=False): """ @base: directory path where to search for templates @create: create directory hierarchy if missing when installing @@ -45,6 +45,7 @@ class Installer: @diff_cmd: diff command to use @remove_existing_in_dir: remove file in dir dotfiles if not managed by dotdrop + @force_chmod: apply chmod without confirmation """ self.create = create self.backup = backup @@ -64,6 +65,7 @@ class Installer: self.diff_cmd = diff_cmd self.action_executed = False self.remove_existing_in_dir = remove_existing_in_dir + self.force_chmod = force_chmod # avoids printing file copied logs # when using install_to_tmp for comparing self.comparing = False @@ -77,7 +79,7 @@ class Installer: def install(self, templater, src, dst, linktype, actionexec=None, noempty=False, ignore=None, is_template=True, - chmod=None, force_chmod=False): + chmod=None): """ install src to dst @@ -90,7 +92,6 @@ class Installer: @ignore: pattern to ignore when installing @is_template: this dotfile is a template @chmod: rights to apply if any - @force_chmod: do not ask user to chmod return - True, None : success @@ -189,7 +190,6 @@ class Installer: self._apply_chmod_after_install(src, dst, ret, err, chmod=chmod, - force_chmod=force_chmod, linktype=linktype) return self._log_install(ret, err) @@ -197,7 +197,6 @@ class Installer: def _apply_chmod_after_install(self, src, dst, ret, err, chmod=None, is_sub=False, - force_chmod=False, linktype=LinkTypes.NOLINK): """ handle chmod after install @@ -227,7 +226,7 @@ class Installer: if dstperms != chmod: # apply mode msg = f'chmod {dst} to {chmod:o}' - if not force_chmod and self.safe and not self.log.ask(msg): + if not self.force_chmod and self.safe and not self.log.ask(msg): ret = False err = 'aborted' else: