יום שישי, 27 בינואר 2012

Bash script to copy changes from SVN to a different location

This was originally made by request from a developer from my office.
#!/bin/bash
NEWDIR="/home/usern/svn-script"
for file in $(svn status | tr -s ' ' ' ' | cut -d" " -f2)
do
declare -i DIRLEVEL=$(grep -o "/" $file| wc -l)
DIRLEVEL=$( echo "$DIRLEVEL - 1" |bc )
SRCPATH=$(echo $file | cut -d"/" -f1-"$DIRLEVEL" )
mkdir -p $NEWDIR/$SRCPATH
cp -v $file $NEWDIR/$SRCPATH
done
later to be updated and improved by Lev to include better method to parse the path and scenarios where files should be ignored.
#!/bin/bash

NEWDIR="${1:-$HOME/svn-script}"

mkdir -p "${NEWDIR}"
if [ $? -ne 0 ]then
echo "Could not create ${NEWDIR}"
exit 1
fi

# check if running from subversion dir:
if [ ! -d .svn ]then
echo "This is not a working copy directory!"
exit 1
fi

for FILE in $(svn status | awk '$1 ~ /[AMR]/ { print $2 }')do
if [ -d ${FILE} ]then

אין תגובות:

הוסף רשומת תגובה