#!/bin/bash
#
#   FILE: cvs_add_dir
# AUTHOR: Gratien D'haese <gdha@it3.be>
#   DATE: 17 June 2002
# Copyright (C) 2002 Gratien D'haese <gdha@it3.be>
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

# Simple script to add/commit a new directory recursively into cvs
# Script assumes CVSROOT is set as an environment variable.
# script take one argument (directory name)

# currently script assumes you are in the CVSROOT directory of your project
# set DEBUG=echo to enable debug mode (echo the line instead of exec)
#DEBUG=echo
DIR=$1

if [ ! -d "$DIR" ]; then
   echo "Directory $DIR not found."
   exit 1
fi

# do a cvs add of all directories found recursively
for dirs in `find $DIR -type d`
do
    echo Adding $dirs to the CVS tree
    $DEBUG cvs add $dirs
    $DEBUG cvs commit -m \'$DIR\' $dirs
done

echo "Press ANY key to continue (Ctrl-C to abort now)"
read garbage

# do a cvs add of all files found recursively
for dirs in `find $DIR -type d -depth | grep -v CVS`
do
    echo Adding files to the CVS tree
    $DEBUG cvs add $dirs/*
    $DEBUG cvs commit -m \'$DIR\' $dirs/*
done
$DEBUG cvs add $DIR/*
