forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reopen_branch.sh
executable file
·54 lines (42 loc) · 1.36 KB
/
reopen_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
48
49
50
51
52
53
54
#!/bin/bash -e
ENVOY_GIT_USERNAME="${ENVOY_GIT_USERNAME:-envoy-bot}"
ENVOY_GIT_EMAIL="${ENVOY_GIT_EMAIL:[email protected]}"
MAIN_BRANCH=refs/heads/main
MAIN_BRANCH_SHORTNAME=main
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [[ "$CURRENT_BRANCH" != "$MAIN_BRANCH" ]] && [[ "$CURRENT_BRANCH" != "$MAIN_BRANCH_SHORTNAME" ]]; then
echo "Current branch ($CURRENT_BRANCH) must be \`main\`, exiting" >&2
exit 1
else
# TODO(phlax): remove once its clear what this should be
echo "Current branch: $CURRENT_BRANCH"
fi
configure_git_user () {
if [[ -z "$ENVOY_GIT_USERNAME" || -z "$ENVOY_GIT_EMAIL" ]]; then
echo 'Unable to set git name/email, using existing git config' >&2
return
fi
git config --global user.name "$ENVOY_GIT_USERNAME"
git config --global user.email "$ENVOY_GIT_EMAIL"
}
create_dev_commit () {
bazel run @envoy_repo//:dev
}
get_release_name () {
local version
version="$(cut -d- -f1 < VERSION.txt | cut -d. -f-2)"
echo -n "release/v${version}"
}
push_commit () {
local release_name commit_sha
release_name="$(get_release_name)"
commit_sha="$(git rev-parse HEAD)"
echo "Re-opening \`main\` branch ${release_name} from ${commit_sha}"
git push origin "$release_name"
}
reopen_branch () {
configure_git_user
create_dev_commit
push_branch
}
reopen_branch