mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-16 23:09:11 +00:00
fix chmod compare bug
This commit is contained in:
@@ -28,9 +28,12 @@ class Comparator:
|
|||||||
self.log = Logger(debug=self.debug)
|
self.log = Logger(debug=self.debug)
|
||||||
self.ignore_missing_in_dotdrop = ignore_missing_in_dotdrop
|
self.ignore_missing_in_dotdrop = ignore_missing_in_dotdrop
|
||||||
|
|
||||||
def compare(self, local_path, deployed_path, ignore=None):
|
def compare(self, local_path, deployed_path, ignore=None, mode=None):
|
||||||
"""diff local_path (dotdrop dotfile) and
|
"""
|
||||||
deployed_path (destination file)"""
|
diff local_path (dotdrop dotfile) and
|
||||||
|
deployed_path (destination file)
|
||||||
|
If mode is None, rights will be read from local_path
|
||||||
|
"""
|
||||||
if not ignore:
|
if not ignore:
|
||||||
ignore = []
|
ignore = []
|
||||||
local_path = os.path.expanduser(local_path)
|
local_path = os.path.expanduser(local_path)
|
||||||
@@ -58,19 +61,24 @@ class Comparator:
|
|||||||
self.log.dbg('{} is a file'.format(local_path))
|
self.log.dbg('{} is a file'.format(local_path))
|
||||||
ret = self._comp_file(local_path, deployed_path, ignore)
|
ret = self._comp_file(local_path, deployed_path, ignore)
|
||||||
if not ret:
|
if not ret:
|
||||||
ret = self._comp_mode(local_path, deployed_path)
|
ret = self._comp_mode(local_path, deployed_path, mode=mode)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
self.log.dbg('{} is a directory'.format(local_path))
|
self.log.dbg('{} is a directory'.format(local_path))
|
||||||
|
|
||||||
ret = self._comp_dir(local_path, deployed_path, ignore)
|
ret = self._comp_dir(local_path, deployed_path, ignore)
|
||||||
if not ret:
|
if not ret:
|
||||||
ret = self._comp_mode(local_path, deployed_path)
|
ret = self._comp_mode(local_path, deployed_path, mode=mode)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def _comp_mode(self, local_path, deployed_path):
|
def _comp_mode(self, local_path, deployed_path, mode=None):
|
||||||
"""compare mode"""
|
"""
|
||||||
local_mode = get_file_perm(local_path)
|
compare mode
|
||||||
|
If mode is None, rights will be read on local_path
|
||||||
|
"""
|
||||||
|
local_mode = mode
|
||||||
|
if not local_mode:
|
||||||
|
local_mode = get_file_perm(local_path)
|
||||||
deployed_mode = get_file_perm(deployed_path)
|
deployed_mode = get_file_perm(deployed_path)
|
||||||
if local_mode == deployed_mode:
|
if local_mode == deployed_mode:
|
||||||
return ''
|
return ''
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ def _dotfile_compare(opts, dotfile, tmp):
|
|||||||
|
|
||||||
# compare
|
# compare
|
||||||
# need to be executed before cleaning
|
# need to be executed before cleaning
|
||||||
diff = comp.compare(src, dotfile.dst, ignore=ignores)
|
diff = comp.compare(src, dotfile.dst, ignore=ignores, mode=dotfile.chmod)
|
||||||
|
|
||||||
# clean tmp transformed dotfile if any
|
# clean tmp transformed dotfile if any
|
||||||
if tmpsrc:
|
if tmpsrc:
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ flink="${tmpd}/filelink"
|
|||||||
echo "filelink" > ${flink}
|
echo "filelink" > ${flink}
|
||||||
chmod 777 ${flink}
|
chmod 777 ${flink}
|
||||||
|
|
||||||
|
echo "f777" > ${tmps}/dotfiles/f777
|
||||||
|
chmod 700 ${tmps}/dotfiles/f777
|
||||||
|
|
||||||
toimport="${dnormal} ${dlink} ${dlinkchildren} ${fnormal} ${flink}"
|
toimport="${dnormal} ${dlink} ${dlinkchildren} ${fnormal} ${flink}"
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
@@ -93,10 +96,23 @@ config:
|
|||||||
create: true
|
create: true
|
||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
dotfiles:
|
dotfiles:
|
||||||
|
f_f777:
|
||||||
|
src: f777
|
||||||
|
dst: ${tmpd}/f777
|
||||||
|
chmod: 777
|
||||||
profiles:
|
profiles:
|
||||||
|
p1:
|
||||||
|
dotfiles:
|
||||||
|
- f_f777
|
||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
|
# install
|
||||||
|
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1
|
||||||
|
|
||||||
|
# compare
|
||||||
|
cd ${ddpath} | ${bin} compare -c ${cfg} -p p1
|
||||||
|
|
||||||
# import
|
# import
|
||||||
for i in ${toimport}; do
|
for i in ${toimport}; do
|
||||||
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 ${i}
|
cd ${ddpath} | ${bin} import -c ${cfg} -f -p p1 ${i}
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ clear_on_exit "${tmpd}"
|
|||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
echo 'f777' > ${tmps}/dotfiles/f777
|
echo 'f777' > ${tmps}/dotfiles/f777
|
||||||
|
chmod 700 ${tmps}/dotfiles/f777
|
||||||
echo 'link' > ${tmps}/dotfiles/link
|
echo 'link' > ${tmps}/dotfiles/link
|
||||||
mkdir -p ${tmps}/dotfiles/dir
|
mkdir -p ${tmps}/dotfiles/dir
|
||||||
echo "f1" > ${tmps}/dotfiles/dir/f1
|
echo "f1" > ${tmps}/dotfiles/dir/f1
|
||||||
|
|||||||
2
tests.sh
2
tests.sh
@@ -84,6 +84,8 @@ if [ ! -z ${workers} ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# run bash tests
|
# run bash tests
|
||||||
|
export DOTDROP_DEBUG="yes"
|
||||||
|
unset DOTDROP_FORCE_NODEBUG
|
||||||
workdir_tmp_exists="no"
|
workdir_tmp_exists="no"
|
||||||
[ -d "~/.config/dotdrop/tmp" ] && workdir_tmp_exists="yes"
|
[ -d "~/.config/dotdrop/tmp" ] && workdir_tmp_exists="yes"
|
||||||
if [ -z ${GITHUB_WORKFLOW} ]; then
|
if [ -z ${GITHUB_WORKFLOW} ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user