@@ -7,49 +7,70 @@ 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+ if [[ ! " $UPSTREAM_REF " =~ ^stable_[0-9]+\. [0-9]+\. y$ ]]; then
12+ echo " Invalid UPSTREAM_REF format: $UPSTREAM_REF "
13+ echo " Expected format: stable_X.Y.y (e.g., stable_6.12.y)"
14+ exit 1
15+ fi
16+
17+ # Extract kernel version from UPSTREAM_REF (e.g., stable_6.12.y -> 6.12)
18+ KERNEL_VERSION=$( echo " $UPSTREAM_REF " | sed -E ' s/.*_([0-9]+\.[0-9]+)\.y/\1/' )
19+ if [ -z " $KERNEL_VERSION " ]; then
20+ echo " Failed to extract kernel version from UPSTREAM_REF: $UPSTREAM_REF "
21+ echo " Expected format: stable_X.Y.y (e.g., stable_6.12.y)"
22+ exit 1
23+ fi
24+ echo " Detected kernel version: $KERNEL_VERSION "
25+
26+ # Define branch names based on kernel version
27+ CIQ_BASE_BRANCH=" ciq-${KERNEL_VERSION} .y"
28+ CIQ_NEXT_BRANCH=" ciq-${KERNEL_VERSION} .y-next"
29+ CIQ_TMP_BRANCH=" {automation_tmp}_ciq-${KERNEL_VERSION} .y-next"
30+
1031git fetch --all
11- git show-ref --verify --quiet refs/remotes/origin/$UPSTREAM_REF
32+ git show-ref --verify --quiet " refs/remotes/origin/${ UPSTREAM_REF} "
1233if [ $? -ne 0 ]; then
1334 echo " UPSTREAM_REF $UPSTREAM_REF does not exist, please check status of remote and local branches"
1435 exit 1
1536fi
1637
17- git checkout $ UPSTREAM_REF
38+ git checkout " ${ UPSTREAM_REF} "
1839if [ $? -ne 0 ]; then
1940 echo " Failed to checkout $UPSTREAM_REF , please check status of remote and local branches"
2041 exit 1
2142fi
2243
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"
44+ git show-ref --verify --quiet " refs/heads/${CIQ_NEXT_BRANCH} "
45+ if [ $? -eq 0 ]; then
46+ echo " $CIQ_NEXT_BRANCH branch already exists, please check status of remote and local branches"
2647 exit 1
2748fi
2849
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"
50+ git show-ref --verify --quiet " refs/heads/${CIQ_TMP_BRANCH} "
51+ if [ $? -eq 0 ]; then
52+ echo " $CIQ_TMP_BRANCH branch already exists, please check status of remote and local branches"
3253 exit 1
3354fi
3455
35- git checkout -b ciq-6.12.y-next $ UPSTREAM_REF
56+ git checkout -b " ${CIQ_NEXT_BRANCH} " " ${ UPSTREAM_REF} "
3657if [ $? -ne 0 ]; then
37- echo " Failed to checkout ciq-6.12.y-next , please check status of remote and local branches"
58+ echo " Failed to checkout $CIQ_NEXT_BRANCH , please check status of remote and local branches"
3859 exit 1
3960fi
40- git checkout ciq-6.12.y
61+ git checkout " ${CIQ_BASE_BRANCH} "
4162if [ $? -ne 0 ]; then
42- echo " Failed to checkout ciq-6.12.y , please check status of remote and local branches"
63+ echo " Failed to checkout $CIQ_BASE_BRANCH , please check status of remote and local branches"
4364 exit 1
4465fi
45- git checkout -b {automation_tmp}_ciq-6.12.y-next
66+ git checkout -b " ${CIQ_TMP_BRANCH} "
4667if [ $? -ne 0 ]; then
47- echo " Failed to checkout {automation_tmp}_ciq-6.12.y-next , please check status of remote and local branches"
68+ echo " Failed to checkout $CIQ_TMP_BRANCH , please check status of remote and local branches"
4869 exit 1
4970fi
50- git rebase ciq-6.12.y-next
71+ git rebase " ${CIQ_NEXT_BRANCH} "
5172if [ $? -ne 0 ]; then
52- echo " Failed to rebase {automation_tmp}_ciq-6.12.y-next , please check status of remote and local branches"
73+ echo " Failed to rebase $CIQ_TMP_BRANCH , please check status of remote and local branches"
5374 exit 1
5475fi
5576
0 commit comments