mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-16 12:16:11 +00:00
adding chmod_on_import option for #324
This commit is contained in:
@@ -13,6 +13,7 @@ Entry | Description | Default
|
|||||||
-------- | ------------- | ------------
|
-------- | ------------- | ------------
|
||||||
`backup` | Create a backup of the dotfile in case it differs from the one that will be installed by dotdrop | true
|
`backup` | Create a backup of the dotfile in case it differs from the one that will be installed by dotdrop | true
|
||||||
`banner` | Display the banner | true
|
`banner` | Display the banner | true
|
||||||
|
`chmod_on_import` | Always add a chmod entry on newly imported dotfiles (see `--preserve-mode`) | false
|
||||||
`cmpignore` | List of patterns to ignore when comparing, applied to all dotfiles (enclose in quotes when using wildcards; see [ignore patterns](config.md#ignore-patterns)) | -
|
`cmpignore` | List of patterns to ignore when comparing, applied to all dotfiles (enclose in quotes when using wildcards; see [ignore patterns](config.md#ignore-patterns)) | -
|
||||||
`create` | Create a directory hierarchy when installing dotfiles if it doesn't exist | true
|
`create` | Create a directory hierarchy when installing dotfiles if it doesn't exist | true
|
||||||
`default_actions` | List of action keys to execute for all installed dotfiles (See [actions](config-details.md#actions-entry)) | -
|
`default_actions` | List of action keys to execute for all installed dotfiles (See [actions](config-details.md#actions-entry)) | -
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ dotfiles:
|
|||||||
|
|
||||||
On `import`, the following rules are applied:
|
On `import`, the following rules are applied:
|
||||||
|
|
||||||
* If the `-m`/`--preserve-mode` switch is provided, the imported file's permissions are
|
* If the `-m`/`--preserve-mode` switch is provided or the config option
|
||||||
|
`chmod_on_import` is true, the imported file's permissions are
|
||||||
stored in a `chmod` entry
|
stored in a `chmod` entry
|
||||||
* If the imported file's permissions differ from the umask, then the permissions are automatically
|
* If the imported file's permissions differ from the umask, then the permissions are automatically
|
||||||
stored in the `chmod` entry.
|
stored in the `chmod` entry.
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ class Options(AttrMonitor):
|
|||||||
self.impignore = None
|
self.impignore = None
|
||||||
self.upignore = None
|
self.upignore = None
|
||||||
self.link_on_import = None
|
self.link_on_import = None
|
||||||
|
self.chmod_on_import = None
|
||||||
|
|
||||||
# args parsing
|
# args parsing
|
||||||
self.args = {}
|
self.args = {}
|
||||||
@@ -258,7 +259,7 @@ class Options(AttrMonitor):
|
|||||||
"""import specifics"""
|
"""import specifics"""
|
||||||
self.import_path = self.args['<path>']
|
self.import_path = self.args['<path>']
|
||||||
self.import_as = self.args['--as']
|
self.import_as = self.args['--as']
|
||||||
self.import_mode = self.args['--preserve-mode']
|
self.import_mode = self.args['--preserve-mode'] or self.chmod_on_import
|
||||||
self.import_ignore = self.args['--ignore']
|
self.import_ignore = self.args['--ignore']
|
||||||
self.import_ignore.extend(self.impignore)
|
self.import_ignore.extend(self.impignore)
|
||||||
self.import_ignore.append('*{}'.format(self.install_backup_suffix))
|
self.import_ignore.append('*{}'.format(self.install_backup_suffix))
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class Settings(DictParser):
|
|||||||
key_force_chmod = 'force_chmod'
|
key_force_chmod = 'force_chmod'
|
||||||
key_template_dotfile_default = 'template_dotfile_default'
|
key_template_dotfile_default = 'template_dotfile_default'
|
||||||
key_ignore_missing_in_dotdrop = 'ignore_missing_in_dotdrop'
|
key_ignore_missing_in_dotdrop = 'ignore_missing_in_dotdrop'
|
||||||
|
key_chmod_on_import = 'chmod_on_import'
|
||||||
|
|
||||||
# import keys
|
# import keys
|
||||||
key_import_actions = 'import_actions'
|
key_import_actions = 'import_actions'
|
||||||
@@ -63,7 +64,8 @@ class Settings(DictParser):
|
|||||||
diff_command='diff -r -u {0} {1}',
|
diff_command='diff -r -u {0} {1}',
|
||||||
template_dotfile_default=True,
|
template_dotfile_default=True,
|
||||||
ignore_missing_in_dotdrop=False,
|
ignore_missing_in_dotdrop=False,
|
||||||
force_chmod=False):
|
force_chmod=False,
|
||||||
|
chmod_on_import=False):
|
||||||
self.backup = backup
|
self.backup = backup
|
||||||
self.banner = banner
|
self.banner = banner
|
||||||
self.create = create
|
self.create = create
|
||||||
@@ -92,6 +94,7 @@ class Settings(DictParser):
|
|||||||
self.template_dotfile_default = template_dotfile_default
|
self.template_dotfile_default = template_dotfile_default
|
||||||
self.ignore_missing_in_dotdrop = ignore_missing_in_dotdrop
|
self.ignore_missing_in_dotdrop = ignore_missing_in_dotdrop
|
||||||
self.force_chmod = force_chmod
|
self.force_chmod = force_chmod
|
||||||
|
self.chmod_on_import = chmod_on_import
|
||||||
|
|
||||||
def _serialize_seq(self, name, dic):
|
def _serialize_seq(self, name, dic):
|
||||||
"""serialize attribute 'name' into 'dic'"""
|
"""serialize attribute 'name' into 'dic'"""
|
||||||
@@ -116,7 +119,8 @@ class Settings(DictParser):
|
|||||||
self.key_diff_command: self.diff_command,
|
self.key_diff_command: self.diff_command,
|
||||||
self.key_template_dotfile_default: self.template_dotfile_default,
|
self.key_template_dotfile_default: self.template_dotfile_default,
|
||||||
self.key_ignore_missing_in_dotdrop: self.ignore_missing_in_dotdrop,
|
self.key_ignore_missing_in_dotdrop: self.ignore_missing_in_dotdrop,
|
||||||
self.key_force_chmod: self.force_chmod
|
self.key_force_chmod: self.force_chmod,
|
||||||
|
self.key_chmod_on_import: self.chmod_on_import,
|
||||||
}
|
}
|
||||||
self._serialize_seq(self.key_default_actions, dic)
|
self._serialize_seq(self.key_default_actions, dic)
|
||||||
self._serialize_seq(self.key_import_actions, dic)
|
self._serialize_seq(self.key_import_actions, dic)
|
||||||
|
|||||||
@@ -212,6 +212,37 @@ cd ${ddpath} | ${bin} detail -c ${cfg} -p p1 -V
|
|||||||
cnt=`cat ${cfg} | grep chmod | wc -l`
|
cnt=`cat ${cfg} | grep chmod | wc -l`
|
||||||
[ "${cnt}" != "0" ] && echo "chmod inserted but not needed" && exit 1
|
[ "${cnt}" != "0" ] && echo "chmod inserted but not needed" && exit 1
|
||||||
|
|
||||||
|
## with config option chmod_on_import
|
||||||
|
cat > ${cfg} << _EOF
|
||||||
|
config:
|
||||||
|
backup: true
|
||||||
|
create: true
|
||||||
|
dotpath: dotfiles
|
||||||
|
chmod_on_import: true
|
||||||
|
dotfiles:
|
||||||
|
profiles:
|
||||||
|
_EOF
|
||||||
|
|
||||||
|
# clean
|
||||||
|
rm -rf ${tmps}/dotfiles
|
||||||
|
mkdir -p ${tmps}/dotfiles
|
||||||
|
|
||||||
|
# import
|
||||||
|
for i in ${toimport}; do
|
||||||
|
chmod_to_umask ${i}
|
||||||
|
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 -V ${i}
|
||||||
|
done
|
||||||
|
|
||||||
|
cat ${cfg}
|
||||||
|
|
||||||
|
# list files
|
||||||
|
cd ${ddpath} | ${bin} detail -c ${cfg} -p p1 -V
|
||||||
|
|
||||||
|
cat ${cfg}
|
||||||
|
tot=`echo ${toimport} | wc -w`
|
||||||
|
cnt=`cat ${cfg} | grep "chmod: " | wc -l`
|
||||||
|
[ "${cnt}" != "${tot}" ] && echo "not all chmod inserted (3)" && exit 1
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
rm -rf ${tmps} ${tmpd}
|
rm -rf ${tmps} ${tmpd}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user