@@ -7,49 +7,75 @@ if [ -z "$UPSTREAM_REF" ]; then
77 echo " UPSTREAM_REF not set, defaulting to $UPSTREAM_REF "
88fi
99
10+ # Validate UPSTREAM_REF format to prevent shell injection
11+ case " $UPSTREAM_REF " in
12+ stable_[0-9]* .[0-9]* .y)
13+ # Valid format
14+ ;;
15+ * )
16+ echo " Invalid UPSTREAM_REF format: $UPSTREAM_REF "
17+ echo " Expected format: stable_X.Y.y (e.g., stable_6.12.y)"
18+ exit 1
19+ ;;
20+ esac
21+
22+ # Extract kernel version from UPSTREAM_REF (e.g., stable_6.12.y -> 6.12)
23+ KERNEL_VERSION=$( echo " $UPSTREAM_REF " | sed -E ' s/.*_([0-9]+\.[0-9]+)\.y/\1/' )
24+ if [ -z " $KERNEL_VERSION " ]; then
25+ echo " Failed to extract kernel version from UPSTREAM_REF: $UPSTREAM_REF "
26+ echo " Expected format: stable_X.Y.y (e.g., stable_6.12.y)"
27+ exit 1
28+ fi
29+ echo " Detected kernel version: $KERNEL_VERSION "
30+
31+ # Define branch names based on kernel version
32+ CIQ_BASE_BRANCH=" ciq-${KERNEL_VERSION} .y"
33+ CIQ_NEXT_BRANCH=" ciq-${KERNEL_VERSION} .y-next"
34+ CIQ_TMP_BRANCH=" {automation_tmp}_ciq-${KERNEL_VERSION} .y-next"
35+
1036git fetch --all
11- git show-ref --verify --quiet refs/remotes/origin/$UPSTREAM_REF
37+ git show-ref --verify --quiet " refs/remotes/origin/${ UPSTREAM_REF} "
1238if [ $? -ne 0 ]; then
1339 echo " UPSTREAM_REF $UPSTREAM_REF does not exist, please check status of remote and local branches"
1440 exit 1
1541fi
1642
17- git checkout $ UPSTREAM_REF
43+ git checkout " ${ UPSTREAM_REF} "
1844if [ $? -ne 0 ]; then
1945 echo " Failed to checkout $UPSTREAM_REF , please check status of remote and local branches"
2046 exit 1
2147fi
2248
23- git show-ref --verify --quiet refs/heads/ciq-6.12.y-next
24- if [ $? -eq 0 ]; then
25- echo " ciq-6.12.y-next branch already exists, please check status of remote and local branches"
49+ git show-ref --verify --quiet " refs/heads/${CIQ_NEXT_BRANCH} "
50+ if [ $? -eq 0 ]; then
51+ echo " $CIQ_NEXT_BRANCH branch already exists, please check status of remote and local branches"
2652 exit 1
2753fi
2854
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"
55+ git show-ref --verify --quiet " refs/heads/${CIQ_TMP_BRANCH} "
56+ if [ $? -eq 0 ]; then
57+ echo " $CIQ_TMP_BRANCH branch already exists, please check status of remote and local branches"
3258 exit 1
3359fi
3460
35- git checkout -b ciq-6.12.y-next $ UPSTREAM_REF
61+ git checkout -b " ${CIQ_NEXT_BRANCH} " " ${ UPSTREAM_REF} "
3662if [ $? -ne 0 ]; then
37- echo " Failed to checkout ciq-6.12.y-next , please check status of remote and local branches"
63+ echo " Failed to checkout $CIQ_NEXT_BRANCH , please check status of remote and local branches"
3864 exit 1
3965fi
40- git checkout ciq-6.12.y
66+ git checkout " ${CIQ_BASE_BRANCH} "
4167if [ $? -ne 0 ]; then
42- echo " Failed to checkout ciq-6.12.y , please check status of remote and local branches"
68+ echo " Failed to checkout $CIQ_BASE_BRANCH , please check status of remote and local branches"
4369 exit 1
4470fi
45- git checkout -b {automation_tmp}_ciq-6.12.y-next
71+ git checkout -b " ${CIQ_TMP_BRANCH} "
4672if [ $? -ne 0 ]; then
47- echo " Failed to checkout {automation_tmp}_ciq-6.12.y-next , please check status of remote and local branches"
73+ echo " Failed to checkout $CIQ_TMP_BRANCH , please check status of remote and local branches"
4874 exit 1
4975fi
50- git rebase ciq-6.12.y-next
76+ git rebase " ${CIQ_NEXT_BRANCH} "
5177if [ $? -ne 0 ]; then
52- echo " Failed to rebase {automation_tmp}_ciq-6.12.y-next , please check status of remote and local branches"
78+ echo " Failed to rebase $CIQ_TMP_BRANCH , please check status of remote and local branches"
5379 exit 1
5480fi
5581
0 commit comments