diff options
author | Isaac J. Manjarres <isaacmanjarres@google.com> | 2023-03-22 11:07:18 -0700 |
---|---|---|
committer | Isaac J. Manjarres <isaacmanjarres@google.com> | 2023-03-22 11:07:18 -0700 |
commit | 1fa988f4e26bfbec074cdc71910e3eeb9e14e186 (patch) | |
tree | 416f770e37dfb09453be7a8d760fbe5ab49b525c | |
parent | 0626853d5cc291c08dba516050813b3e153c9ba7 (diff) | |
download | msm-1fa988f4e26bfbec074cdc71910e3eeb9e14e186.tar.gz |
scripts/handle_aosp_merge.sh: Do not upload commits to gerrit automatically
The AOSP merge automatically pushes the commits it generates to gerrit,
which can cause a lot of CLs to be created, which then have to be
abandoned if the intent was not to have them uploaded in the first
place.
Introduce a new variable that can be set when invoking the script
to determine if it should push the commits that were created to
gerrit or not. The variable will be set to 0 by default, and must
be set to 1 to automatically push commits (i.e. PUSH=1).
Bug: 274786079
Change-Id: I5a060de10f3897c1731985981ff66e2cedf4cc8f
Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
-rwxr-xr-x | scripts/handle_aosp_merge.sh | 68 |
1 files changed, 58 insertions, 10 deletions
diff --git a/scripts/handle_aosp_merge.sh b/scripts/handle_aosp_merge.sh index 4a7b67c..89cfa73 100755 --- a/scripts/handle_aosp_merge.sh +++ b/scripts/handle_aosp_merge.sh @@ -19,6 +19,9 @@ AOSP_BRANCH=${AOSP_BRANCH:-"android13-5.15"} # Kernel Manifest KERNEL_MANIFEST=${KERNEL_MANIFEST:-"android13-msm-pixelwatch-5.15"} +# Whether or not to push commits to gerrit +PUSH=${PUSH:-0} + # Gerrit Topic e.g.: # WK10_AOSP_MERGE_android13-msm-pixelwatch-5.15_AND_android13-5.15 TOPIC=${TOPIC:-WK`date +%U`_AOSP_MERGE_${KERNEL_MANIFEST}_AND_${AOSP_BRANCH}} @@ -36,6 +39,9 @@ KERNEL_PATCHLEVEL="" KERNEL_SUBLEVEL="" AOSP_COMMIT_INFO="" +MANIFEST_DIR=".repo/manifests" +PREBUILTS_DIR="prebuilts/boot-artifacts" + #----------------------------------------------------------------------- # Reset color Color_Off='\033[0m' # Text Reset @@ -58,6 +64,8 @@ function usage() { BOOT_IMAGE_BUILDID: The build ID of the prebuilt boot image to download. AOSP_BRANCH: The GKI branch that was used to generate the boot image. KERNEL_MANIFEST: The kernel manifest branch to use for syncing the kernel repos. + PUSH: Optional: Whether or not to automatically push generated commits + to gerrit for review. This is set to 0 by default. MERGE_BUG: Optional: The bug number associated with this merge. USE_UNSIGNED_USER_IMG: Optional: Set this to 1 only if you need an unsigned (not certified) boot.img. @@ -75,7 +83,11 @@ function usage() { AOSP_BRANCH=android13-5.15-2023-02 \\ KERNEL_MANIFEST=android13-msm-pixelwatch-5.15 $0 - Note: Signed images are only available on release builds on release branches. + Note: + 1. Signed images are only available on release builds on release branches. + + 2. You can set PUSH=1 when invoking $0 to automatically push the generated commits + to gerrit for review. EOF } @@ -132,7 +144,7 @@ function update_manifest_and_sync_gki_kernel() { rev_current_aosp=$(repo info kernel/${GKI_KERNEL_DIR} | grep "Current revision" | \ sed 's/Current revision: //g') - pushd .repo/manifests > /dev/null + pushd ${MANIFEST_DIR} > /dev/null sed -i "s/${rev_current_aosp}/${REV_NEW_AOSP}/" default.xml @@ -146,13 +158,15 @@ function update_manifest_and_sync_gki_kernel() { function commit_and_push_manifest_update() { local merge_msg=$(printf "Update ${AOSP_BRANCH} sync point to (${KERNEL_VERSION}.${KERNEL_PATCHLEVEL}.${KERNEL_SUBLEVEL})\n\nSync SHA:\n${AOSP_COMMIT_INFO}\n\nBug: ${MERGE_BUG}") - pushd .repo/manifests > /dev/null + pushd ${MANIFEST_DIR} > /dev/null git add default.xml git commit --quiet -s -m "${merge_msg}" - echo -e "\n${Yellow}Pushing manifest updates...${Color_Off}" - git push origin HEAD:refs/for/${KERNEL_MANIFEST} -o topic=${TOPIC} + if [[ $PUSH -eq 1 ]]; then + echo -e "\n${Yellow}Pushing manifest updates...${Color_Off}" + git push origin HEAD:refs/for/${KERNEL_MANIFEST} -o topic=${TOPIC} + fi popd > /dev/null } @@ -212,8 +226,10 @@ function merge_aosp_to_device_kernel() { git commit --amend --quiet -s -F CommitInfo.txt rm CommitInfo.txt - echo -e "\n${Yellow}Pushing updates to ${DEVICE_KERNEL_DIR}${Color_Off}" - git push partner HEAD:refs/for/${BRANCH_DEVICE_KERNEL} -o topic=${TOPIC} + if [[ $PUSH -eq 1 ]]; then + echo -e "\n${Yellow}Pushing updates to ${DEVICE_KERNEL_DIR}${Color_Off}" + git push partner HEAD:refs/for/${BRANCH_DEVICE_KERNEL} -o topic=${TOPIC} + fi else echo -e "\n${Yellow}No updates required to ${DEVICE_KERNEL_DIR}${Color_Off}" fi @@ -234,17 +250,45 @@ function update_gki_prebuilts() { ${SCRIPTS_DIR}/download_gki.sh ${download_script_args} exit_if_error $? "Unable to download GKI binaries" - pushd ${CUR_DIR}/prebuilts/boot-artifacts/ > /dev/null + pushd ${CUR_DIR}/${PREBUILTS_DIR} > /dev/null merge_msg=$(git log --pretty='%B' -1 | sed "s/Change-Id/Bug: ${MERGE_BUG}\nChange-Id/") git commit --amend --quiet -s --no-edit -m "${merge_msg}" - echo -e "\n${Yellow}Pushing updates to GKI prebuilts dir${Color_Off}" - git push partner HEAD:refs/for/${BRANCH_DEVICE_KERNEL} -o topic=${TOPIC} + if [[ $PUSH -eq 1 ]]; then + echo -e "\n${Yellow}Pushing updates to GKI prebuilts dir${Color_Off}" + git push partner HEAD:refs/for/${BRANCH_DEVICE_KERNEL} -o topic=${TOPIC} + fi popd > /dev/null } +function log_push_disabled_notice() { + cat <<- EOF + Commits have been generated for integrating ACK SHA ${REV_NEW_AOSP} + but have not been pushed to gerrit. + + To ensure that the commits are pushed to gerrit, rerun the script with + PUSH=1 or push each commit to gerrit manually with the following + commands: + + # Manifest update + cd ${MANIFEST_DIR} + git push origin ${KERNEL_MANIFEST} + cd .. + + # Device kernel update + cd ${DEVICE_KERNEL_DIR} + git push partner ${KERNEL_MANIFEST} + cd .. + + # GKI prebuilts update + cd ${PREBUILTS_DIR} + git push partner ${KERNEL_MANIFEST} + cd .. +EOF +} + sanitize_args echo -e "\nBegin.\n" @@ -259,3 +303,7 @@ merge_aosp_to_device_kernel update_gki_prebuilts echo -e "\nDone.\n" + +if [[ $PUSH -ne 1 ]]; then + log_push_disabled_notice +fi |