Skip to content

Commit 7e72b2b

Browse files
committed
lt_rebase: Add additional saftey checks for git branches
1 parent 78d0f87 commit 7e72b2b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

lt_rebase.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,50 @@ if [ -z "$UPSTREAM_REF" ]; then
88
fi
99

1010
git fetch --all
11+
git show-ref --verify --quiet refs/remotes/origin/$UPSTREAM_REF
12+
if [ $? -ne 0 ]; then
13+
echo "UPSTREAM_REF $UPSTREAM_REF does not exist, please check status of remote and local branches"
14+
exit 1
15+
fi
16+
17+
git checkout $UPSTREAM_REF
18+
if [ $? -ne 0 ]; then
19+
echo "Failed to checkout $UPSTREAM_REF, please check status of remote and local branches"
20+
exit 1
21+
fi
22+
1123
git show-ref --verify --quiet refs/heads/ciq-6.12.y-next
1224
if [ $? -eq 0 ]; then
1325
echo "ciq-6.12.y-next branch already exists, please check status of remote and local branches"
1426
exit 1
1527
fi
1628

29+
git show-ref --verify --quiet refs/heads/{automation_tmp}_ciq-6.12.y-next
30+
if [ $? -eq 0 ]; then
31+
echo "{automation_tmp}_ciq-6.12.y-next branch already exists, please check status of remote and local branches"
32+
exit 1
33+
fi
34+
1735
git checkout -b ciq-6.12.y-next $UPSTREAM_REF
36+
if [ $? -ne 0 ]; then
37+
echo "Failed to checkout ciq-6.12.y-next, please check status of remote and local branches"
38+
exit 1
39+
fi
1840
git checkout ciq-6.12.y
41+
if [ $? -ne 0 ]; then
42+
echo "Failed to checkout ciq-6.12.y, please check status of remote and local branches"
43+
exit 1
44+
fi
1945
git checkout -b {automation_tmp}_ciq-6.12.y-next
46+
if [ $? -ne 0 ]; then
47+
echo "Failed to checkout {automation_tmp}_ciq-6.12.y-next, please check status of remote and local branches"
48+
exit 1
49+
fi
2050
git rebase ciq-6.12.y-next
51+
if [ $? -ne 0 ]; then
52+
echo "Failed to rebase {automation_tmp}_ciq-6.12.y-next, please check status of remote and local branches"
53+
exit 1
54+
fi
2155

2256
REPO_STATUS=$(git status -s)
2357
if [ ! -z "$REPO_STATUS" ]; then

0 commit comments

Comments
 (0)