]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash | |
2 | ||
3 | set -e | |
4 | ||
5 | if [[ $# -eq 0 ]] || [[ $1 == "-h" ]] ; then | |
6 | echo "Usage: ${0##*/} <dir to import> [more dirs]" | |
7 | exit 1 | |
8 | fi | |
9 | ||
10 | dir=$1 | |
11 | if [[ ! -e ${dir} ]] ; then | |
12 | echo "cvs-import: $1: directory does not exist" 1>&2 | |
13 | exit 1 | |
14 | fi | |
15 | dir=$(realpath "${dir}") | |
16 | ||
17 | echo "Importing ${dir} and kids" | |
18 | cd "${dir}/.." | |
19 | cvs -Q add "${dir##*/}" | |
20 | ||
21 | find_files() { | |
22 | local depth=$1 | |
23 | shift | |
24 | find . -mindepth ${depth} -maxdepth ${depth} \ | |
25 | '!' '(' -name 'CVS' -o -wholename '*/CVS/*' ')' "$@" | |
26 | } | |
27 | ||
28 | cd "${dir}" | |
29 | i=1 | |
30 | while [[ -n $(find_files ${i}) ]] ; do | |
31 | echo "Importing at depth ${i}" | |
32 | find_files ${i} -exec cvs -Q add {} + | |
33 | : $(( i += 1 )) | |
34 | done | |
35 | ||
36 | echo "Done" |