]> git.phdru.name Git - cookiecutter.git/blob - clone2current
Add script `add-remote`
[cookiecutter.git] / clone2current
1 #! /bin/sh
2
3 if [ ! -d ".git" -a -z "$1" ]; then
4    echo "Usage: $0 repository [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 repository (.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 "$HOME"/prog/git-scripts/set-commit-date-recursive &&
37
38 echo /publish-docs >>.git/info/exclude &&
39 echo /update-remotes >>.git/info/exclude &&
40 git config update-remotes.files publish-docs &&
41 cp -p "$HOME"/current/projects/m_lib/update-remotes . &&
42
43 cd "$source_dir" &&
44 if [ -n "$directories" ]; then
45    dest_dir="$directories/$dest_dir"
46 fi &&
47 {
48     git remote add current "$HOME"/current/projects/"$dest_dir" ||
49     exec git remote set-url current "$HOME"/current/projects/"$dest_dir"
50 }