Skip to content

Instantly share code, notes, and snippets.

@abachman
Created September 3, 2009 16:05
Show Gist options
  • Save abachman/180371 to your computer and use it in GitHub Desktop.
Save abachman/180371 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Copy svn:ignore files between directories. Handy when checking out and working
# on branches. This script is specific to my needs, but could be easily
# generalized.
# - Adam Bachman, Sept 2009
usage() {
printf "Copies svn:ignore'd rails configurations from one project to another.\n\n" >&2
printf "Usage: %s /from/dir /to/dir \n\n" $(basename $0) >&2
exit 2
}
if [ -z "$1" ]; then
usage
fi
if [ -z "$2" ]; then
usage
fi
# remove trailing /
dirA=$(echo "$1" | sed -e 's,\(.\)/$,\1,')
dirB=$(echo "$2" | sed -e 's,\(.\)/$,\1,')
PATHS="config/development config/test"
if [ -d $dirA ]; then
if [ -d $dirB ]; then
for _path in `echo $PATHS`; do
for _file in `svn propget svn:ignore $dirA/$_path`; do
cp -v $dirA/$_path/$_file $dirB/$_path/$_file
done
done
else
echo "$dirB is not a valid directory."
fi
else
echo "$dirA is not a valid directory."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment