-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbranch.sh
executable file
·47 lines (39 loc) · 1.07 KB
/
branch.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
#!/bin/bash
# @param $1
# Replacement pattern
# @param $2
# File path.
function portable_sed() {
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' -e "$1" "$2"
else
sed -i -e "$1" "$2"
fi
}
echo -e "Enter the new branch name (e.g. 10.2.x):"
read b
echo -e "Enter the original branch name (e.g. 10.1.x):"
read pb
n=${b/x/0}
cn=${b/.x/}
p=${pb/x/0}
cp=${pb/.x/}
git checkout "$pb"
git pull
rm -rf vendor
echo -e "Composer installing.\n"
composer install --no-progress --no-suggest -n -q
(cd core; rm -rf node_modules; yarn install)
git checkout -b "$b"
# @todo Make it fail if the following don't make changes.
echo -e "\nUpdating version constant.\n"
portable_sed "s/VERSION = '[0-9\.]*-dev'/VERSION = '$n-dev'/1" core/lib/Drupal.php
echo -e "Updating templates.\n"
for file in `find composer/Template -name composer.json`
do
portable_sed "s/\^$cp/\^$cn/g" $file
done
echo -e "\nUpdating metapackages.\n"
COMPOSER_ROOT_VERSION="$b-dev" composer update drupal/core* --no-progress --no-suggest -n -q
(cd core; rm -rf node_modules; yarn install)
git commit -am "Drupal $b-dev"