Add option to specify custom tmp CVS directory

parent 06622c6a
......@@ -37,36 +37,41 @@ BLUE='\033[0;34m'
GREEN='\033[0;32m'
NO_COLOR='\033[0m'
# Set the tmp directory used for backups if not set by the user
if [ -z "${WEBIS_TMP_PATH}" ]; then
WEBIS_TMP_PATH="${HOME}/tmp"
fi
#
# Main
#
main() {
local tmp=~/tmp/cvsupdate-$$
mkdir -p $(dirname $tmp)
local tmp=${WEBIS_TMP_PATH}/cvsupdate-$$
mkdir -p "${WEBIS_TMP_PATH}"
echo "CVS STATUS"
webis cvs status 2> /dev/zero | grep "Needs merge" | awk '{print " - "$NF}' > $tmp
if [ $(cat $tmp | wc -l) -gt 0 ];then
webis cvs status 2> /dev/zero | grep "Needs merge" | awk '{print " - "$NF}' > "$tmp"
if [ $(cat "$tmp" | wc -l) -gt 0 ];then
echo "Update would lead to the following conflicts:"
cat $tmp
cat "$tmp"
echo "Do you want to continue? [y/N]"
read cont
if [ "$cont" != "y" ];then
rm $tmp
rm "$tmp"
exit 0
fi
fi
rm $tmp
rm "$tmp"
echo "CVS UPDATE"
deleted_directories_directory=~/tmp/webis-cvs-update-${PWD##*/}-$(date "+%Y-%m-%d-%H-%M-%S")
deleted_directories_directory="${WEBIS_TMP_PATH}/webis-cvs-update-${PWD##*/}-$(date '+%Y-%m-%d-%H-%M-%S')"
cvs -q update -dP -I "*.log" -I "*.swp" -I "*.bak" -I "bin*" 2>&1 \
| while read line; do
if [[ "$line" == "cvs update: skipping directory "* ]]; then
dir=`echo "$line" | awk '{print $5}'`
echo -e "${BLUE}Moving remotely deleted directory${NO_COLOR} $dir to $deleted_directories_directory/$dir"
sed -i "/^D\/`basename $dir`\/\/\/\/$/d" `dirname $dir`/CVS/Entries
mkdir -p $deleted_directories_directory
rsync -a --relative --remove-source-files $dir $deleted_directories_directory
mkdir -p "$deleted_directories_directory"
rsync -a --relative --remove-source-files $dir "$deleted_directories_directory"
find . -depth -type d -empty -delete
else
case $line in
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment