-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgca_worktree.sh
executable file
·48 lines (35 loc) · 1.22 KB
/
gca_worktree.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
#!/bin/bash
set -u
WORK_SRC_ROOT="/data/mysql-server"
WORK_MAIN_REPO="8.0"
readonly BRANCH=$1
readonly LOWEST_VERSION_ARG=$2
readonly DEFAULT_LOWEST_VERSION="5.6"
if [ "$LOWEST_VERSION_ARG" = "" ]; then
echo "Creating branches starting at $DEFAULT_LOWEST_VERSION"
LOWEST_VERSION="$DEFAULT_LOWEST_VERSION"
else
LOWEST_VERSION="$LOWEST_VERSION_ARG"
fi
if [ "$LOWEST_VERSION" != "5.6" ] && [ "$LOWEST_VERSION" != "5.7" ]; then
echo "Only 5.6 and 5.7 are valid lowest versions"
exit 1
fi
function create_git_gca_worktree ()
{
local lower_base_branch=$1
local lower_branch=$2
local higher_branch=$3
local gca_rev
gca_rev="$(git rev-list "$lower_base_branch" ^"$higher_branch" --first-parent --topo-order \
| tail -1)^"
echo "Creating $lower_branch from $lower_base_branch for merge to $higher_branch at $gca_rev"
git worktree add -b "$lower_branch" "../$lower_branch" "$gca_rev"
}
pushd "$WORK_SRC_ROOT/$WORK_MAIN_REPO" || exit 1
git worktree add -b "$BRANCH-8.0" "../$BRANCH-8.0" percona/8.0
create_git_gca_worktree "percona/5.7" "$BRANCH-5.7" "$BRANCH-8.0"
if [ "$LOWEST_VERSION" = "5.6" ]; then
create_git_gca_worktree "percona/5.6" "$BRANCH-5.6" "$BRANCH-5.7"
fi
popd || exit 0