From 9f94f14b8780887eb4602ca80d08b7cfe268bb42 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Sun, 19 May 2019 19:43:07 +0200 Subject: [PATCH] fix cmpignore for #137 --- dotdrop/comparator.py | 10 ++++++++-- tests-ng/compare-ignore.sh | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/dotdrop/comparator.py b/dotdrop/comparator.py index 165450f..66a0ae2 100644 --- a/dotdrop/comparator.py +++ b/dotdrop/comparator.py @@ -66,14 +66,14 @@ class Comparator: ret = [] comp = filecmp.dircmp(left, right) - # handle files only in deployed file + # handle files only in deployed dir for i in comp.left_only: if utils.must_ignore([os.path.join(left, i)], ignore, debug=self.debug): continue ret.append('=> \"{}\" does not exist on local\n'.format(i)) - # handle files only in dotpath file + # handle files only in dotpath dir for i in comp.right_only: if utils.must_ignore([os.path.join(right, i)], ignore, debug=self.debug): @@ -85,6 +85,9 @@ class Comparator: for i in funny: lfile = os.path.join(left, i) rfile = os.path.join(right, i) + if utils.must_ignore([lfile, rfile], + ignore, debug=self.debug): + continue short = os.path.basename(lfile) # file vs dir ret.append('=> different type: \"{}\"\n'.format(short)) @@ -96,6 +99,9 @@ class Comparator: for i in funny: lfile = os.path.join(left, i) rfile = os.path.join(right, i) + if utils.must_ignore([lfile, rfile], + ignore, debug=self.debug): + continue diff = self._diff(lfile, rfile, header=True) ret.append(diff) diff --git a/tests-ng/compare-ignore.sh b/tests-ng/compare-ignore.sh index a19229f..59d8129 100755 --- a/tests-ng/compare-ignore.sh +++ b/tests-ng/compare-ignore.sh @@ -57,6 +57,9 @@ tmpd=`mktemp -d --suffix='-dotdrop-tests'` mkdir -p ${tmpd}/{program,config} touch ${tmpd}/program/a touch ${tmpd}/config/a +mkdir ${tmpd}/vscode +touch ${tmpd}/vscode/extensions.txt +touch ${tmpd}/vscode/keybindings.json # create the config file cfg="${basedir}/config.yaml" @@ -66,6 +69,7 @@ create_conf ${cfg} # sets token echo "[+] import" cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/program cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/config +cd ${ddpath} | ${bin} import -c ${cfg} ${tmpd}/vscode # add files echo "[+] add files" @@ -131,6 +135,23 @@ cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose [ "$?" != "0" ] && exit 1 set -e +# update files +echo touched > ${tmpd}/vscode/extensions.txt +echo touched > ${tmpd}/vscode/keybindings.json + +# expect two diffs +set +e +cd ${ddpath} | ${bin} compare -c ${cfg} --verbose -C ${tmpd}/vscode +[ "$?" = "0" ] && exit 1 +set -e + +# expects no diff +sed '/d_vscode:/a \ \ \ \ cmpignore:\n\ \ \ \ - "*extensions.txt"\n\ \ \ \ - "*keybindings.json"' ${cfg} > ${cfg2} +set +e +cd ${ddpath} | ${bin} compare -c ${cfg2} --verbose -C ${tmpd}/vscode +[ "$?" != "0" ] && exit 1 +set -e + ## CLEANING rm -rf ${basedir} ${tmpd}