Put project_name into .git/description
[cookiecutter.git] / clone2current
1 #! /bin/sh
2
3 if [ -z "$1" ]; then
4    echo "Usage: $0 repoistory [directories]" >&2
5    exit 1
6 fi
7
8 cd "$1" && source_dir="`pwd`" &&
9
10 if [ ! -d ".git" ]; then
11    echo "$source_dir is not a repoistory (.git isn't found)" >&2
12    exit 1
13 fi &&
14
15 cd "$HOME"/current/projects &&
16 directories="$2" &&
17 if [ -n "$directories" ]; then
18    mkdir -p "$directories" && cd "$directories"
19 fi &&
20
21 dest_dir="`basename \"$source_dir\"`" &&
22 git clone "$source_dir" "$dest_dir" &&
23
24 cd "$dest_dir" &&
25 pwd >> "`dirname \"$0\"`"/locate-all.list &&
26 if [ "`cat \"$source_dir\"/.git/description`" = \
27    "Unnamed repository; edit this file 'description' to name the repository." ]
28 then
29    `git var GIT_EDITOR` "$source_dir"/.git/description .git/description
30 else
31    cp -p "$source_dir"/.git/description .git
32 fi &&
33
34 cd "$source_dir" &&
35 if [ -n "$directories" ]; then
36    dest_dir="$directories/$dest_dir"
37 fi &&
38 exec git remote add current "$HOME"/current/projects/"$dest_dir"