mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-05 05:39:43 +00:00
@@ -12,3 +12,7 @@ script:
|
||||
./tests.sh
|
||||
after_success:
|
||||
coveralls
|
||||
env:
|
||||
global:
|
||||
- DOTDROP_FORCE_NODEBUG=
|
||||
- DOTDROP_NOBANNER=
|
||||
|
||||
@@ -127,6 +127,8 @@ _dotdrop-import ()
|
||||
'(--no-banner)--no-banner' \
|
||||
'(-d)-d' \
|
||||
'(--dry)--dry' \
|
||||
'(-f)-f' \
|
||||
'(--force)--force' \
|
||||
'(-c=-)-c=-' \
|
||||
'(--cfg=-)--cfg=-' \
|
||||
'(-p=-)-p=-' \
|
||||
|
||||
@@ -127,6 +127,8 @@ _dotdrop.sh-import ()
|
||||
'(--no-banner)--no-banner' \
|
||||
'(-d)-d' \
|
||||
'(--dry)--dry' \
|
||||
'(-f)-f' \
|
||||
'(--force)--force' \
|
||||
'(-c=-)-c=-' \
|
||||
'(--cfg=-)--cfg=-' \
|
||||
'(-p=-)-p=-' \
|
||||
|
||||
@@ -53,7 +53,7 @@ _dotdrop_import()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
||||
if [ $COMP_CWORD -ge 2 ]; then
|
||||
COMPREPLY=( $( compgen -fW '-V --verbose -b --no-banner -d --dry -c= --cfg= -p= --profile= -l= --link= ' -- $cur) )
|
||||
COMPREPLY=( $( compgen -fW '-V --verbose -b --no-banner -d --dry -f --force -c= --cfg= -p= --profile= -l= --link= ' -- $cur) )
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ _dotdropsh_import()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
||||
if [ $COMP_CWORD -ge 2 ]; then
|
||||
COMPREPLY=( $( compgen -fW '-V --verbose -b --no-banner -d --dry -c= --cfg= -p= --profile= -l= --link= ' -- $cur) )
|
||||
COMPREPLY=( $( compgen -fW '-V --verbose -b --no-banner -d --dry -f --force -c= --cfg= -p= --profile= -l= --link= ' -- $cur) )
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
60
completion/generate.sh
Executable file
60
completion/generate.sh
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
# author: deadc0de6 (https://github.com/deadc0de6)
|
||||
# Copyright (c) 2019, deadc0de6
|
||||
|
||||
set -e
|
||||
|
||||
bin="docopt-completion"
|
||||
if ! hash ${bin}; then
|
||||
echo "\"${bin}\" not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rl="readlink -f"
|
||||
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
||||
rl="realpath"
|
||||
|
||||
if ! hash ${rl}; then
|
||||
echo "\"${rl}\" not found!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cur=$(dirname "$(${rl} "${0}")")
|
||||
opwd=$(pwd)
|
||||
|
||||
# output files
|
||||
compl="${cur}"
|
||||
dtsh_zsh="${compl}/_dotdrop.sh-completion.zsh"
|
||||
dtsh_bash="${compl}/dotdrop.sh-completion.bash"
|
||||
dt_zsh="${compl}/_dotdrop-completion.zsh"
|
||||
dt_bash="${compl}/dotdrop-completion.bash"
|
||||
|
||||
# generate for dotdrop.sh
|
||||
cd ${cur}/..
|
||||
docopt-completion ./dotdrop.sh --manual-zsh
|
||||
mv ./_dotdrop.sh ${dtsh_zsh}
|
||||
docopt-completion ./dotdrop.sh --manual-bash
|
||||
mv ./dotdrop.sh.sh ${dtsh_bash}
|
||||
|
||||
# generate for dotdrop
|
||||
vbin="virtualenv"
|
||||
if ! hash ${vbin}; then
|
||||
echo "\"${vbin}\" not found!"
|
||||
exit 1
|
||||
fi
|
||||
cd ${cur}/..
|
||||
venv="/tmp/dotdrop-venv"
|
||||
${vbin} -p python3 ${venv}
|
||||
source ${venv}/bin/activate
|
||||
python setup.py install
|
||||
cd /tmp
|
||||
docopt-completion dotdrop --manual-zsh
|
||||
mv ./_dotdrop ${dt_zsh}
|
||||
docopt-completion dotdrop --manual-bash
|
||||
mv ./dotdrop.sh ${dt_bash}
|
||||
deactivate
|
||||
rm -rf ${venv}
|
||||
|
||||
# pivot back
|
||||
cd ${opwd}
|
||||
@@ -10,7 +10,7 @@ if ! ${rl} "${0}" >/dev/null 2>&1; then
|
||||
rl="realpath"
|
||||
|
||||
if ! hash ${rl}; then
|
||||
echo "\"${rl}\" not found !" && exit 1
|
||||
echo "\"${rl}\" not found!" && exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -353,7 +353,23 @@ def cmd_importer(o):
|
||||
|
||||
# prepare hierarchy for dotfile
|
||||
srcf = os.path.join(o.dotpath, src)
|
||||
if not os.path.exists(srcf):
|
||||
overwrite = not os.path.exists(srcf)
|
||||
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))
|
||||
if overwrite:
|
||||
cmd = ['mkdir', '-p', '{}'.format(os.path.dirname(srcf))]
|
||||
if o.dry:
|
||||
LOG.dry('would run: {}'.format(' '.join(cmd)))
|
||||
|
||||
@@ -52,7 +52,7 @@ USAGE = """
|
||||
|
||||
Usage:
|
||||
dotdrop install [-VbtfndDa] [-c <path>] [-p <profile>] [<key>...]
|
||||
dotdrop import [-Vbd] [-c <path>] [-p <profile>]
|
||||
dotdrop import [-Vbdf] [-c <path>] [-p <profile>]
|
||||
[-l <link>] <path>...
|
||||
dotdrop compare [-Vb] [-c <path>] [-p <profile>]
|
||||
[-o <opts>] [-C <file>...] [-i <pattern>...]
|
||||
|
||||
90
tests-ng/import-subfile.sh
Executable file
90
tests-ng/import-subfile.sh
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env bash
|
||||
# author: deadc0de6 (https://github.com/deadc0de6)
|
||||
# Copyright (c) 2019, deadc0de6
|
||||
#
|
||||
# test import file in directory
|
||||
# after having imported directory
|
||||
#
|
||||
|
||||
# exit on first error
|
||||
set -e
|
||||
|
||||
# all this crap to get current path
|
||||
rl="readlink -f"
|
||||
if ! ${rl} "${0}" >/dev/null 2>&1; then
|
||||
rl="realpath"
|
||||
|
||||
if ! hash ${rl}; then
|
||||
echo "\"${rl}\" not found !" && exit 1
|
||||
fi
|
||||
fi
|
||||
cur=$(dirname "$(${rl} "${0}")")
|
||||
|
||||
#hash dotdrop >/dev/null 2>&1
|
||||
#[ "$?" != "0" ] && echo "install dotdrop to run tests" && exit 1
|
||||
|
||||
#echo "called with ${1}"
|
||||
|
||||
# dotdrop path can be pass as argument
|
||||
ddpath="${cur}/../"
|
||||
[ "${1}" != "" ] && ddpath="${1}"
|
||||
[ ! -d ${ddpath} ] && echo "ddpath \"${ddpath}\" is not a directory" && exit 1
|
||||
|
||||
export PYTHONPATH="${ddpath}:${PYTHONPATH}"
|
||||
bin="python3 -m dotdrop.dotdrop"
|
||||
|
||||
echo "dotdrop path: ${ddpath}"
|
||||
echo "pythonpath: ${PYTHONPATH}"
|
||||
|
||||
# get the helpers
|
||||
source ${cur}/helpers
|
||||
|
||||
echo -e "\e[96m\e[1m==> RUNNING $(basename $BASH_SOURCE) <==\e[0m"
|
||||
|
||||
################################################################
|
||||
# this is the test
|
||||
################################################################
|
||||
|
||||
# the dotfile source
|
||||
tmps=`mktemp -d --suffix='-dotdrop-tests'`
|
||||
mkdir -p ${tmps}/dotfiles
|
||||
# the dotfile destination
|
||||
tmpd=`mktemp -d --suffix='-dotdrop-tests'`
|
||||
#echo "dotfile destination: ${tmpd}"
|
||||
|
||||
# create the dotfile
|
||||
mkdir -p ${tmpd}/adir
|
||||
echo "first" > ${tmpd}/adir/file1
|
||||
|
||||
# create the config file
|
||||
cfg="${tmps}/config.yaml"
|
||||
|
||||
cat > ${cfg} << _EOF
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
dotpath: dotfiles
|
||||
dotfiles:
|
||||
profiles:
|
||||
_EOF
|
||||
#cat ${cfg}
|
||||
|
||||
# import dir
|
||||
cd ${ddpath} | ${bin} import -f -c ${cfg} -p p1 -V ${tmpd}/adir
|
||||
|
||||
# change the file
|
||||
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 >/dev/null
|
||||
|
||||
## CLEANING
|
||||
rm -rf ${tmps} ${tmpd}
|
||||
|
||||
echo "OK"
|
||||
exit 0
|
||||
4
tests.sh
4
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
|
||||
|
||||
Reference in New Issue
Block a user