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