mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-12 01:54:02 +00:00
fix import as tild issue #220
This commit is contained in:
@@ -345,11 +345,12 @@ def cmd_importer(o):
|
|||||||
src = strip_home(dst)
|
src = strip_home(dst)
|
||||||
if o.import_as:
|
if o.import_as:
|
||||||
# handle import as
|
# handle import as
|
||||||
src = o.import_as.rstrip(os.sep)
|
src = os.path.expanduser(o.import_as)
|
||||||
|
src = src.rstrip(os.sep)
|
||||||
src = os.path.abspath(src)
|
src = os.path.abspath(src)
|
||||||
src = strip_home(src)
|
src = strip_home(src)
|
||||||
if o.debug:
|
if o.debug:
|
||||||
LOG.dbg('import src for {}: {}'.format(dst, src))
|
LOG.dbg('import src for {} as {}'.format(dst, src))
|
||||||
|
|
||||||
strip = '.' + os.sep
|
strip = '.' + os.sep
|
||||||
if o.keepdot:
|
if o.keepdot:
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
|
|||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
|
clean()
|
||||||
|
{
|
||||||
|
rm -rf ${tmps} ${tmpd} ~/.dotdrop.test ~/.dotdrop-dotfiles-test
|
||||||
|
}
|
||||||
|
|
||||||
# the dotfile source
|
# the dotfile source
|
||||||
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
||||||
mkdir -p ${tmps}/dotfiles
|
mkdir -p ${tmps}/dotfiles
|
||||||
@@ -113,10 +118,32 @@ nb=`cat ${cfg} | grep f_file3 | wc -l`
|
|||||||
cat ${cfg} | grep "src: config/adir" || exit 1
|
cat ${cfg} | grep "src: config/adir" || exit 1
|
||||||
cat ${cfg} | grep "src: config2/file3" || exit 1
|
cat ${cfg} | grep "src: config2/file3" || exit 1
|
||||||
|
|
||||||
cat ${cfg}
|
# test import from sub in home
|
||||||
|
mkdir -p ~/.dotdrop-dotfiles-test/{dotfiles,config}
|
||||||
|
cfg=~/.dotdrop-dotfiles-test/config/config.yaml
|
||||||
|
echo 'remove-me' > ~/.dotdrop.test
|
||||||
|
cat > ${cfg} << _EOF
|
||||||
|
config:
|
||||||
|
backup: true
|
||||||
|
banner: true
|
||||||
|
create: true
|
||||||
|
dotpath: ~/.dotdrop-dotfiles-test/dotfiles
|
||||||
|
keepdot: false
|
||||||
|
link_dotfile_default: nolink
|
||||||
|
link_on_import: nolink
|
||||||
|
longkey: true
|
||||||
|
dotfiles:
|
||||||
|
profiles:
|
||||||
|
_EOF
|
||||||
|
|
||||||
|
cd ${ddpath} | ${bin} import -b -c ${cfg} -p test -V ~/.dotdrop.test --as=~/.whatever
|
||||||
|
#cat ${cfg}
|
||||||
|
|
||||||
|
[ ! -e ~/.dotdrop-dotfiles-test/dotfiles/whatever ] && clean && echo 'tild imported' && exit 1
|
||||||
|
cat ${cfg} | grep '~/.whatever' && clean && echo 'import with tild failed' && exit 1
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
rm -rf ${tmps} ${tmpd}
|
clean
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ echo -e "$(tput setaf 6)==> RUNNING $(basename $BASH_SOURCE) <==$(tput sgr0)"
|
|||||||
# this is the test
|
# this is the test
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
|
clean()
|
||||||
|
{
|
||||||
|
rm -rf ${tmps} ${tmpd} ~/.dotdrop-test
|
||||||
|
}
|
||||||
|
|
||||||
# the dotfile source
|
# the dotfile source
|
||||||
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
tmps=`mktemp -d --suffix='-dotdrop-tests' || mktemp -d`
|
||||||
mkdir -p ${tmps}/dotfiles
|
mkdir -p ${tmps}/dotfiles
|
||||||
@@ -73,11 +78,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/testfile
|
|||||||
cat ${cfg}
|
cat ${cfg}
|
||||||
|
|
||||||
# ensure exists and is not link
|
# ensure exists and is not link
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && exit 1
|
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && clean && exit 1
|
||||||
cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1
|
cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1
|
||||||
grep 'original' ${tmps}/dotfiles/${tmpd}/testfile
|
grep 'original' ${tmps}/dotfiles/${tmpd}/testfile
|
||||||
nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l`
|
nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l`
|
||||||
[ "${nb}" != "1" ] && echo 'not 1 entry' && exit 1
|
[ "${nb}" != "1" ] && echo 'not 1 entry' && clean && exit 1
|
||||||
|
|
||||||
# re-import without changing
|
# re-import without changing
|
||||||
echo "[+] re-import without changes"
|
echo "[+] re-import without changes"
|
||||||
@@ -85,11 +90,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/testfile
|
|||||||
cat ${cfg}
|
cat ${cfg}
|
||||||
|
|
||||||
# test is only once
|
# test is only once
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && exit 1
|
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && clean && exit 1
|
||||||
cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1
|
cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1
|
||||||
grep 'original' ${tmps}/dotfiles/${tmpd}/testfile
|
grep 'original' ${tmps}/dotfiles/${tmpd}/testfile
|
||||||
nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l`
|
nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l`
|
||||||
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
|
[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1
|
||||||
|
|
||||||
# re-import with changes
|
# re-import with changes
|
||||||
echo "[+] re-import with changes"
|
echo "[+] re-import with changes"
|
||||||
@@ -98,11 +103,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/testfile
|
|||||||
cat ${cfg}
|
cat ${cfg}
|
||||||
|
|
||||||
# test is only once
|
# test is only once
|
||||||
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && exit 1
|
[ ! -e ${tmps}/dotfiles/${tmpd}/testfile ] && echo "does not exist" && clean && exit 1
|
||||||
cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1
|
cat ${cfg} | grep ${tmpd}/testfile >/dev/null 2>&1
|
||||||
grep 'modified' ${tmps}/dotfiles/${tmpd}/testfile
|
grep 'modified' ${tmps}/dotfiles/${tmpd}/testfile
|
||||||
nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l`
|
nb=`cat ${cfg} | grep ${tmpd}/testfile | wc -l`
|
||||||
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
|
[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1
|
||||||
|
|
||||||
# ###################################################
|
# ###################################################
|
||||||
|
|
||||||
@@ -113,11 +118,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ~/.dotdrop.test
|
|||||||
cat ${cfg}
|
cat ${cfg}
|
||||||
|
|
||||||
# ensure exists and is not link
|
# ensure exists and is not link
|
||||||
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
|
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && clean && exit 1
|
||||||
cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1
|
cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1
|
||||||
grep 'original' ${tmps}/dotfiles/dotdrop.test
|
grep 'original' ${tmps}/dotfiles/dotdrop.test
|
||||||
nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l`
|
nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l`
|
||||||
[ "${nb}" != "1" ] && echo 'not 1 entry' && exit 1
|
[ "${nb}" != "1" ] && echo 'not 1 entry' && clean && exit 1
|
||||||
|
|
||||||
# re-import without changing
|
# re-import without changing
|
||||||
echo "[+] re-import without changes in home"
|
echo "[+] re-import without changes in home"
|
||||||
@@ -125,11 +130,11 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ~/.dotdrop.test
|
|||||||
cat ${cfg}
|
cat ${cfg}
|
||||||
|
|
||||||
# test is only once
|
# test is only once
|
||||||
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
|
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && clean && exit 1
|
||||||
cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1
|
cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1
|
||||||
grep 'original' ${tmps}/dotfiles/dotdrop.test
|
grep 'original' ${tmps}/dotfiles/dotdrop.test
|
||||||
nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l`
|
nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l`
|
||||||
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
|
[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1
|
||||||
|
|
||||||
# re-import with changes
|
# re-import with changes
|
||||||
echo "[+] re-import with changes in home"
|
echo "[+] re-import with changes in home"
|
||||||
@@ -138,14 +143,14 @@ cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ~/.dotdrop.test
|
|||||||
cat ${cfg}
|
cat ${cfg}
|
||||||
|
|
||||||
# test is only once
|
# test is only once
|
||||||
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && exit 1
|
[ ! -e "${tmps}/dotfiles/dotdrop.test" ] && echo "does not exist" && clean && exit 1
|
||||||
cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1
|
cat ${cfg} | grep "~/.dotdrop.test" >/dev/null 2>&1
|
||||||
grep 'modified' ${tmps}/dotfiles/dotdrop.test
|
grep 'modified' ${tmps}/dotfiles/dotdrop.test
|
||||||
nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l`
|
nb=`cat ${cfg} | grep "~/.dotdrop.test" | wc -l`
|
||||||
[ "${nb}" != "1" ] && echo 'two entries!' && exit 1
|
[ "${nb}" != "1" ] && echo 'two entries!' && clean && exit 1
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
rm -rf ${tmps} ${tmpd} ~/.dotdrop-test
|
clean
|
||||||
|
|
||||||
echo "OK"
|
echo "OK"
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user