diff --git a/docs/config-format.md b/docs/config-format.md index 931b76c..1565882 100644 --- a/docs/config-format.md +++ b/docs/config-format.md @@ -19,6 +19,7 @@ Entry | Description | Default `diff_command` | the diff command to use for diffing files | `diff -r -u {0} {1}` `dotpath` | path to the directory containing the dotfiles to be managed by dotdrop (absolute path or relative to the config file location) | `dotfiles` `filter_file` | list of paths to load templating filters from (see [Templating available filters](templating.md#template-filters)) | - +`force_chmod` | if true, do not ask confirmation to apply permissions on install | `false` `func_file` | list of paths to load templating functions from (see [Templating available methods](templating.md#template-methods)) | - `ignore_missing_in_dotdrop` | ignore missing files in dotdrop when comparing and importing (see [Ignore missing](usage.md#ignore-missing)) | false `ignoreempty` | do not deploy template if empty | false diff --git a/docs/config.md b/docs/config.md index 7ac4ff0..e9ebca2 100644 --- a/docs/config.md +++ b/docs/config.md @@ -91,12 +91,15 @@ On `install` the following rules are applied: * if `chmod` is specified in the dotfile, it will be applied to the installed dotfile * otherwise the permissions of the dotfile in the `dotpath` are applied. +* if the global setting `force_chmod` is set to true dotdrop will not ask + for confirmation to apply permission On `update`: * if the permissions of the file in the filesystem differ from the dotfile in the `dotpath` then the dotfile entry `chmod` is added/updated accordingly + ## Symlink dotfiles Dotdrop is able to install dotfiles in three different ways @@ -173,7 +176,7 @@ Similar to a `.gitignore` file, you can prefix ignore patterns with an exclamati This so-called "negative ignore pattern" will cause any files that match that pattern to __not__ be ignored, provided they *would have* been ignored by an earlier ignore pattern (dotdrop will warn if that is not the case). This feature allows you to, for example, ignore all files within a certain directory, except for one -particular one (see example below). +particular one (see example below). ```yaml config: diff --git a/dotdrop/cfg_yaml.py b/dotdrop/cfg_yaml.py index 4ebd20b..ffa7acb 100644 --- a/dotdrop/cfg_yaml.py +++ b/dotdrop/cfg_yaml.py @@ -59,7 +59,6 @@ class CfgYaml: key_dotfile_noempty = 'ignoreempty' key_dotfile_template = 'template' key_dotfile_chmod = 'chmod' - key_dotfile_ignore_missing = 'ignore_missing_in_dotdrop' # profile key_profile_dotfiles = 'dotfiles' diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index 6616578..595dc70 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -226,7 +226,8 @@ def _dotfile_install(o, dotfile, tmpdir=None): actionexec=pre_actions_exec, is_template=is_template, ignore=ignores, - chmod=dotfile.chmod) + chmod=dotfile.chmod, + force_chmod=o.install_force_chmod) elif hasattr(dotfile, 'link') and \ dotfile.link == LinkTypes.LINK_CHILDREN: # link_children @@ -235,7 +236,8 @@ def _dotfile_install(o, dotfile, tmpdir=None): actionexec=pre_actions_exec, is_template=is_template, chmod=dotfile.chmod, - ignore=ignores) + ignore=ignores, + force_chmod=o.install_force_chmod) else: # nolink src = dotfile.src @@ -256,7 +258,8 @@ def _dotfile_install(o, dotfile, tmpdir=None): noempty=dotfile.noempty, ignore=ignores, is_template=is_template, - chmod=dotfile.chmod) + chmod=dotfile.chmod, + force_chmod=o.install_force_chmod) if tmp: tmp = os.path.join(o.dotpath, tmp) if os.path.exists(tmp): diff --git a/dotdrop/installer.py b/dotdrop/installer.py index b2295b8..8b0c1a4 100644 --- a/dotdrop/installer.py +++ b/dotdrop/installer.py @@ -66,7 +66,7 @@ class Installer: def install(self, templater, src, dst, linktype, actionexec=None, noempty=False, ignore=[], is_template=True, - chmod=None): + chmod=None, force_chmod=False): """ install src to dst @@ -79,6 +79,7 @@ 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 @@ -171,7 +172,7 @@ class Installer: if dstperms != chmod: # apply mode msg = 'chmod {} to {:o}'.format(dst, chmod) - if self.safe and not self.log.ask(msg): + if not force_chmod and self.safe and not self.log.ask(msg): r = False err = 'aborted' else: diff --git a/dotdrop/options.py b/dotdrop/options.py index c8d001d..6a21233 100644 --- a/dotdrop/options.py +++ b/dotdrop/options.py @@ -257,6 +257,7 @@ class Options(AttrMonitor): self.install_default_actions_post = [a for a in self.default_actions if a.kind == Action.post] self.install_ignore = self.instignore + self.install_force_chmod = self.force_chmod # "compare" specifics self.compare_focus = self.args['--file'] diff --git a/dotdrop/settings.py b/dotdrop/settings.py index 038ff5e..fa8467e 100644 --- a/dotdrop/settings.py +++ b/dotdrop/settings.py @@ -40,6 +40,7 @@ class Settings(DictParser): key_func_file = 'func_file' key_filter_file = 'filter_file' key_diff_command = 'diff_command' + key_force_chmod = 'force_chmod' key_template_dotfile_default = 'template_dotfile_default' key_ignore_missing_in_dotdrop = 'ignore_missing_in_dotdrop' @@ -59,7 +60,8 @@ class Settings(DictParser): minversion=None, func_file=[], filter_file=[], diff_command='diff -r -u {0} {1}', template_dotfile_default=True, - ignore_missing_in_dotdrop=False): + ignore_missing_in_dotdrop=False, + force_chmod=False): self.backup = backup self.banner = banner self.create = create @@ -87,6 +89,7 @@ class Settings(DictParser): self.diff_command = diff_command self.template_dotfile_default = template_dotfile_default self.ignore_missing_in_dotdrop = ignore_missing_in_dotdrop + self.force_chmod = force_chmod def _serialize_seq(self, name, dic): """serialize attribute 'name' into 'dic'""" @@ -111,6 +114,7 @@ class Settings(DictParser): self.key_diff_command: self.diff_command, self.key_template_dotfile_default: self.template_dotfile_default, self.key_ignore_missing_in_dotdrop: self.ignore_missing_in_dotdrop, + self.key_force_chmod: self.force_chmod } self._serialize_seq(self.key_default_actions, dic) self._serialize_seq(self.key_import_actions, dic) diff --git a/tests-ng/chmod-install.sh b/tests-ng/chmod-install.sh index e59562b..5628368 100755 --- a/tests-ng/chmod-install.sh +++ b/tests-ng/chmod-install.sh @@ -121,6 +121,7 @@ config: backup: true create: true dotpath: dotfiles + force_chmod: true dotfiles: f_f777: src: f777 @@ -191,7 +192,8 @@ _EOF # install echo "first install round" -cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 -V +#cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 -V +cd ${ddpath} | ${bin} install -c ${cfg} -p p1 -V has_rights "${tmpd}/f777" "777" has_rights "${tmpd}/link" "777"