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