Refactor, DRY
[git-tools-moved-to-github.git] / id-cvs-to-git / id-cvs-to-git.sh
1 #!/bin/sh
2 # id-cvs-to-git.sh: Creates new bare Git Project from CVS
3 #
4 usage() {
5         cat  <<EOF
6 Usage:
7 id-cvs-to-git.sh source project description
8
9  source: is a GIT project source or 'CVS'
10  project: is the GIT project name (destination) and project source (If CVS)
11  description: description for the project
12  
13  Convert YAZ from CVS to Git
14   id-cvs-to-git.sh CVS yaz "Yet another Z39.50 toolkit"
15
16  Make bare new Git project from existing Git repo ../newproject
17   id-cvs-to-git.sh ../newproject newproject "My new project"
18 EOF
19 }
20
21 SRC=$1
22 P=$2
23 DESC="$3"
24
25 if test -z "$SRC"; then
26         usage
27         exit 1
28 fi
29 if test -z "$P"; then
30         echo "Error: Missing Project"
31         usage
32         exit 1
33 fi
34 if test -z "$DESC"; then
35         echo "Error: Missing Description"
36         usage
37         exit 1
38 fi
39 if test "$SRC" = "CVS"; then
40         rm -fr import_project
41         mkdir import_project
42         cd import_project
43         git cvsimport -u -A ../import.names -v $P
44         cd ..
45         git clone --bare import_project ${P}.git
46 else
47         git clone --bare ${SRC} ${P}.git
48 fi
49 touch ${P}.git/git-daemon-export-ok
50 echo $DESC > ${P}.git/description