@@ -12,30 +12,30 @@ if [ -z "$PR_BRANCH" ] || [ -z "$TARGET_BRANCH" ]; then
1212fi
1313
1414# Check if all branches exist
15- git show-ref --verify --quiet refs/heads/$ PR_BRANCH
15+ git show-ref --verify --quiet refs/heads/" ${ PR_BRANCH} "
1616if [ $? -ne 0 ]; then
1717 echo " Branch ${PR_BRANCH} does not exist."
1818 exit 1
1919fi
2020
21- git show-ref --verify --quiet refs/heads/$ TARGET_BRANCH
21+ git show-ref --verify --quiet refs/heads/" ${ TARGET_BRANCH} "
2222if [ $? -ne 0 ]; then
2323 echo " Branch ${TARGET_BRANCH} does not exist."
2424 exit 1
2525fi
2626
27- git show-ref --verify --quiet refs/heads/$ NEXT_BRANCH
27+ git show-ref --verify --quiet refs/heads/" ${ NEXT_BRANCH} "
2828if [ $? -ne 0 ] ; then
2929 echo " Branch ${NEXT_BRANCH} does not exist."
3030 exit 1
3131fi
3232
3333
3434# collect all static data fire before making alterations to the local and remote repositories
35- PAST_VERSION=$( git describe --tags --abbrev=0 $ TARGET_BRANCH | awk -F ' -' ' {print $2}' )
35+ PAST_VERSION=$( git describe --tags --abbrev=0 " ${ TARGET_BRANCH} " | awk -F ' -' ' {print $2}' )
3636if [ -z " $PAST_VERSION " ]; then
3737 echo " Failed to get a CIQ Tag from ${TARGET_BRANCH} ."
38- echo " LastTag: $( git describe --tags --abbrev=0 $ TARGET_BRANCH) "
38+ echo " LastTag: $( git describe --tags --abbrev=0 " ${ TARGET_BRANCH} " ) "
3939 exit 1
4040fi
4141# Check if PAST_VERSION matches the regex
@@ -48,10 +48,10 @@ PAST_VERSION_BRANCH="ciq-${PAST_VERSION}"
4848echo " PAST_VERSION: $PAST_VERSION "
4949echo " PAST_VERSION_BRANCH: $PAST_VERSION_BRANCH "
5050
51- NEW_GKH_TAG=$( git describe --tags --abbrev=0 $ PR_BRANCH | sed ' s/^.//g' )
51+ NEW_GKH_TAG=$( git describe --tags --abbrev=0 " ${ PR_BRANCH} " | sed ' s/^.//g' )
5252if [ -z " $NEW_GKH_TAG " ]; then
5353 echo " Failed to get a GKH Tag from ${PR_BRANCH} ."
54- echo " LastTag: $( git describe --tags --abbrev=0 $ PR_BRANCH) "
54+ echo " LastTag: $( git describe --tags --abbrev=0 " ${ PR_BRANCH} " ) "
5555 exit 1
5656fi
5757# Check if NEW_GKH_TAG matches the regex
@@ -63,43 +63,43 @@ NEW_CIQ_TAG="ciq_kernel-${NEW_GKH_TAG}-1"
6363# merge PR branch into next branch
6464set +x
6565
66- echo " Commands expected to run (This is in the even it fails during the run)"
67- echo " git checkout $ NEXT_BRANCH"
68- echo " git pull origin $ NEXT_BRANCH"
69- echo " git merge --ff-only $ PR_BRANCH"
70- echo " git push origin $ NEXT_BRANCH"
71- echo " git branch -m $ TARGET_BRANCH $ PAST_VERSION_BRANCH"
72- echo " git push origin :$ TARGET_BRANCH $ PAST_VERSION_BRANCH"
73- echo " git push origin -u $ PAST_VERSION_BRANCH"
74- echo " git branch -m $ NEXT_BRANCH $ TARGET_BRANCH"
75- echo " git push origin :$ NEXT_BRANCH $ TARGET_BRANCH"
76- echo " git push origin -u $ TARGET_BRANCH"
77- echo " git tag $ NEW_CIQ_TAG $ TARGET_BRANCH"
78- echo " git push origin $ NEW_CIQ_TAG"
66+ echo " Commands expected to run (This is in the event it fails during the run)"
67+ echo " git checkout \" ${ NEXT_BRANCH} \" "
68+ echo " git pull origin \" ${ NEXT_BRANCH} \" "
69+ echo " git merge --ff-only \" ${ PR_BRANCH} \" "
70+ echo " git push origin \" ${ NEXT_BRANCH} \" "
71+ echo " git branch -m \" ${ TARGET_BRANCH} \" \" ${ PAST_VERSION_BRANCH} \" "
72+ echo " git push origin :\" ${ TARGET_BRANCH} \" \" ${ PAST_VERSION_BRANCH} \" "
73+ echo " git push origin -u \" ${ PAST_VERSION_BRANCH} \" "
74+ echo " git branch -m \" ${ NEXT_BRANCH} \" \" ${ TARGET_BRANCH} \" "
75+ echo " git push origin :\" ${ NEXT_BRANCH} \" \" ${ TARGET_BRANCH} \" "
76+ echo " git push origin -u \" ${ TARGET_BRANCH} \" "
77+ echo " git tag \" ${ NEW_CIQ_TAG} \" \" ${ TARGET_BRANCH} \" "
78+ echo " git push origin \" ${ NEW_CIQ_TAG} \" "
7979
8080echo " git checkout $NEXT_BRANCH "
81- git checkout $ NEXT_BRANCH
81+ git checkout " ${ NEXT_BRANCH} "
8282if [ $? -ne 0 ]; then
8383 echo " Failed to checkout ${NEXT_BRANCH} ."
8484 exit 1
8585fi
8686
8787echo " git pull origin $NEXT_BRANCH "
88- git pull origin $ NEXT_BRANCH
88+ git pull origin " ${ NEXT_BRANCH} "
8989if [ $? -ne 0 ]; then
9090 echo " Failed to pull ${NEXT_BRANCH} ."
9191 exit 1
9292fi
9393
94- echo " git merge --ff-only $PR_BRANCH "
95- git merge --ff-only $ PR_BRANCH
94+ echo " git merge --ff-only ${ PR_BRANCH} "
95+ git merge --ff-only " ${ PR_BRANCH} "
9696if [ $? -ne 0 ]; then
9797 echo " Failed to merge ${PR_BRANCH} into ${NEXT_BRANCH} ."
9898 exit 1
9999fi
100100
101101echo " git push origin $NEXT_BRANCH "
102- git push origin $ NEXT_BRANCH
102+ git push origin " ${ NEXT_BRANCH} "
103103if [ $? -ne 0 ]; then
104104 echo " Failed to push ${NEXT_BRANCH} ."
105105 exit 1
@@ -112,59 +112,64 @@ if [ $? -ne 0 ]; then
112112 echo " Failed to delete ${PR_BRANCH} remotely."
113113 exit 1
114114fi
115+ git branch -d " ${PR_BRANCH} "
116+ if [ $? -ne 0 ]; then
117+ echo " Failed to delete ${PR_BRANCH} locally."
118+ exit 1
119+ fi
115120
116121
117122echo " git branch -m $TARGET_BRANCH $PAST_VERSION_BRANCH "
118- git branch -m $ TARGET_BRANCH $ PAST_VERSION_BRANCH
123+ git branch -m " ${ TARGET_BRANCH} " " ${ PAST_VERSION_BRANCH} "
119124if [ $? -ne 0 ]; then
120125 echo " Failed to rename ${TARGET_BRANCH} to ${PAST_VERSION_BRANCH} ."
121126 exit 1
122127fi
123128
124129echo " git push origin :$TARGET_BRANCH $PAST_VERSION_BRANCH "
125- git push origin :$ TARGET_BRANCH $ PAST_VERSION_BRANCH
130+ git push origin :" ${ TARGET_BRANCH} " " ${ PAST_VERSION_BRANCH} "
126131if [ $? -ne 0 ]; then
127132 echo " Failed to delete ${TARGET_BRANCH} ."
128133 exit 1
129134fi
130135
131136echo " git push origin -u $PAST_VERSION_BRANCH "
132- git push origin -u $ PAST_VERSION_BRANCH
137+ git push origin -u " ${ PAST_VERSION_BRANCH} "
133138if [ $? -ne 0 ]; then
134139 echo " Failed to push ${PAST_VERSION_BRANCH} ."
135140 exit 1
136141fi
137142
138143echo " git branch -m $NEXT_BRANCH $TARGET_BRANCH "
139- git branch -m $ NEXT_BRANCH $ TARGET_BRANCH
144+ git branch -m " ${ NEXT_BRANCH} " " ${ TARGET_BRANCH} "
140145if [ $? -ne 0 ]; then
141146 echo " Failed to rename ${NEXT_BRANCH} to ${TARGET_BRANCH} ."
142147 exit 1
143148fi
144149
145150echo " git push origin :$NEXT_BRANCH $TARGET_BRANCH "
146- git push origin :$ NEXT_BRANCH $ TARGET_BRANCH
151+ git push origin :" ${ NEXT_BRANCH} " " ${ TARGET_BRANCH} "
147152if [ $? -ne 0 ]; then
148153 echo " Failed to delete ${NEXT_BRANCH} ."
149154 exit 1
150155fi
151156
152157echo " git push origin -u $TARGET_BRANCH "
153- git push origin -u $ TARGET_BRANCH
158+ git push origin -u " ${ TARGET_BRANCH} "
154159if [ $? -ne 0 ]; then
155160 echo " Failed to push ${TARGET_BRANCH} ."
156161 exit 1
157162fi
158163
159164echo " git tag $NEW_CIQ_TAG $TARGET_BRANCH "
160- git tag $ NEW_CIQ_TAG $ TARGET_BRANCH
165+ git tag " ${ NEW_CIQ_TAG} " " ${ TARGET_BRANCH} "
161166if [ $? -ne 0 ]; then
162167 echo " Failed to tag ${TARGET_BRANCH} with ${NEW_CIQ_TAG} ."
163168 exit 1
164169fi
165170
166171echo " git push origin $NEW_CIQ_TAG "
167- git push origin $ NEW_CIQ_TAG
172+ git push origin " ${ NEW_CIQ_TAG} "
168173if [ $? -ne 0 ]; then
169174 echo " Failed to push ${NEW_CIQ_TAG} ."
170175 exit 1
0 commit comments