-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTYPO3-Documentation-clone.sh
executable file
·61 lines (48 loc) · 1.76 KB
/
TYPO3-Documentation-clone.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash -x
# This script is in the public domain.
# Based on an idea by Fabien Udriot
# see http://pastie.org/4225971
# Gather ANSI escape codes.
bold=$(tput bold)
green=$(tput setaf 2)
reset=$(tput sgr0)
# Enter your username for typo3.org here. If no username is entered here, you
# will be promted for it during execution.
username=""
if [[ -z "$username" ]]; then
read -p "Please enter your typo3.org username: " -r username
fi
# Fetch the list of projects.
list_of_projects="$(ssh "[email protected]" -p 29418 "gerrit ls-projects" | grep -e "^Documentation/TYPO3")"
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
echo "${bold}You need to setup your http://review.typo3.org/ account with an SSH public key.${reset}"
exit 1
fi
start_dir="$(pwd)"
for project in $list_of_projects
do
# Print out the project name in bold green.
echo "${bold}${green}${project}${reset}"
# Create a new directory for the git repository.
project_dir="$(pwd)/$project"
mkdir -p "$project_dir"
cd "$project_dir"
# Clone the actual repository.
git clone --recursive "git://git.typo3.org/$project.git" .
# Fetch gerrit commit hook.
scp -p -P 29418 "[email protected]:hooks/commit-msg" .git/hooks/ && chmod +x .git/hooks/commit-msg
# Init potential submodules.
if [[ -n "$(git submodule status)" ]]
then
git submodule sync
git submodule update --init
if [[ -d .git/modules ]]
then
git submodule foreach "scp -p -P 29418 \"[email protected]:hooks/commit-msg\" \$toplevel/.git/modules/\$path/hooks/ && chmod +x \$toplevel/.git/modules/\$path/hooks/commit-msg"
else
git submodule foreach "scp -p -P 29418 \"[email protected]:hooks/commit-msg\" .git/hooks/ && chmod +x .git/hooks/commit-msg"
fi
fi
# Return to the old directory.
cd "$start_dir"
done