diff --git a/.travis.yml b/.travis.yml index e60a940..cba0f41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,3 +12,7 @@ script: ./tests.sh after_success: coveralls +env: + global: + - DOTDROP_FORCE_NODEBUG= + - DOTDROP_NOBANNER= diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index 8846694..193c276 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -354,16 +354,18 @@ def cmd_importer(o): # prepare hierarchy for dotfile srcf = os.path.join(o.dotpath, src) overwrite = not os.path.exists(srcf) - if o.safe and os.path.exists(srcf): - c = Comparator(debug=o.debug) - diff = c.compare(srcf, dst) - if diff != '': - # files are different, dunno what to do - LOG.log('diff \"{}\" VS \"{}\"'.format(dst, srcf)) - LOG.emph(diff) - # ask user - msg = 'Dotfile \"{}\" already exists, overwrite?'.format(srcf) - overwrite = LOG.ask(msg) + if os.path.exists(srcf): + overwrite = True + if o.safe: + c = Comparator(debug=o.debug) + diff = c.compare(srcf, dst) + if diff != '': + # files are different, dunno what to do + LOG.log('diff \"{}\" VS \"{}\"'.format(dst, srcf)) + LOG.emph(diff) + # ask user + msg = 'Dotfile \"{}\" already exists, overwrite?' + overwrite = LOG.ask(msg.format(srcf)) if o.debug: LOG.dbg('will overwrite: {}'.format(overwrite)) diff --git a/tests-ng/import-subfile.sh b/tests-ng/import-subfile.sh index 0dc27d1..c0746d1 100755 --- a/tests-ng/import-subfile.sh +++ b/tests-ng/import-subfile.sh @@ -73,14 +73,15 @@ _EOF cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir # change the file -echo "second" > ${tmpd}/adir/file1 +echo "second" >> ${tmpd}/adir/file1 # import file cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir/file1 # test +#cat ${tmps}/dotfiles/${tmpd}/adir/file1 [ ! -e ${tmps}/dotfiles/${tmpd}/adir/file1 ] && echo "not exist" && exit 1 -grep 'second' ${tmps}/dotfiles/${tmpd}/adir/file1 +grep 'second' ${tmps}/dotfiles/${tmpd}/adir/file1 >/dev/null ## CLEANING rm -rf ${tmps} ${tmpd} diff --git a/tests.sh b/tests.sh index 3a33715..3974bb3 100755 --- a/tests.sh +++ b/tests.sh @@ -25,10 +25,6 @@ which ${nosebin} 2>/dev/null [ "$?" != "0" ] && echo "Install nosetests" && exit 1 set -e -# comment this to get debug info -#export DOTDROP_FORCE_NODEBUG= -#export DOTDROP_NOBANNER= - # execute tests with coverage PYTHONPATH=dotdrop ${nosebin} -s --with-coverage --cover-package=dotdrop #PYTHONPATH=dotdrop python3 -m pytest tests