- git fetch https://git.opendaylight.org/gerrit/${PROJECT} refs/changes/${PATCH}
- git checkout FETCH_HEAD
- cd $BUILD_DIR
+ CHECKOUT=`echo ${patch_code} | cut -d\= -s -f 2 | cut -d\: -f 1`
+ if [ "x${CHECKOUT}" != "x" ]; then
+ echo "checking out ${CHECKOUT}"
+ git fetch "https://git.opendaylight.org/gerrit/${PROJECT}" "refs/changes/$CHECKOUT"
+ git checkout FETCH_HEAD
+ else
+ echo "checking out ${DISTRIBUTION_BRANCH_TO_BUILD}"
+ git checkout "${DISTRIBUTION_BRANCH_TO_BUILD}"
+ fi
+ PICK_SEGMENT=`echo "${patch_code}" | cut -d\: -s -f 2-`
+ IFS=':' read -ra PICKS <<< "${PICK_SEGMENT}"
+ for pick in "${PICKS[@]}"
+ do
+ echo "cherry-picking ${pick}"
+ git fetch "https://git.opendaylight.org/gerrit/${PROJECT}" "refs/changes/${pick}"
+ git cherry-pick --ff --keep-redundant-commits FETCH_HEAD
+ done
+ cd "${BUILD_DIR}"