aosp-merger: Support pushing merge instead of squash

Change-Id: If5e4ff6672828c9af464e001224b02cd2e35782d
This commit is contained in:
Michael Bestas
2023-03-15 00:51:11 +02:00
parent 0e2addfede
commit 7b7ffd7ed1
3 changed files with 137 additions and 15 deletions

View File

@@ -52,15 +52,15 @@ To merge a new AOSP tag platform-wide:
8. Edit `${TOP/vendor/lineage/vars/common` moving the currently tracked tag from `common_aosp_tag` to `prev_common_aosp_tag`, then updating `common_aosp_tag` to reflect the newly tracked tag, and then do the same for `prev_common_aosp_build_id` and `common_aosp_build_id` - lastly, update the `topic` variable to reflect the current month
9. Run `aosp-merger/aosp-merger.sh`, this will take some time, and reads all the variables you set up above while merging the new tags to all relevant tracked repos. This will likely create conflicts on some forked repository, and will ask you to resolve them. It will then issue a final check to ask you if you'd like to upload the merge to gerrit, then after approval uploads a squash of each relevant merge to Gerrit for review.
9. Run `aosp-merger/aosp-merger.sh`, this will take some time, and reads all the variables you set up above while merging the new tags to all relevant tracked repos. This will likely create conflicts on some forked repository, and will ask you to resolve them. It will then issue a final check to ask you if you'd like to upload the merge to gerrit, then after approval uploads the merge to Gerrit for review.
10. Run `cd packages/apps/Trebuchet` and squash-merge the relevant AOSP tag by hand, and upload a squashed merge to Gerrit on the same topic as the platform merge
10. Run `cd packages/apps/Trebuchet` and merge the relevant AOSP tag by hand, and upload it to Gerrit on the same topic as the platform merge
TODO: Handle Trebuchet AOSP merges in `aosp-merger` scripts
11. Once testing of the merge is completed, a global committer or higher can run `aosp-merger/aosp-merger.sh submit-platform` to push the un-squashed merge of the new tag to the HEAD of all relevant forked repositories
11. Once testing of the merge is completed, a global committer or higher can run `aosp-merger/aosp-merger.sh submit-platform` to push the merge of the new tag to the HEAD of all relevant forked repositories
12. Run `cd packages/apps/Trebuchet` and re-merge the relevant AOSP tag by hand, ensure that the Change-ID is the same as the squashed merge that is already on Gerrit, then push to `HEAD:refs/heads/$branchName` to merge
12. Run `cd packages/apps/Trebuchet`, then push to `HEAD:refs/heads/$branchName` to merge
13. Directly after `submit-platform` is run, a Project Director must merge the `LineageOS/android` change on Gerrit uploaded as part of step 6 above
@@ -74,9 +74,9 @@ To merge a new AOSP tag to all currently Google supported Pixel devices and thei
3. Git commit the `vendor/lineage/vars` variable updates and upload to Gerrit
4. Run `aosp-merger/aosp-merger.sh devices` to merge newly entered AOSP tags to all supported device's device-tree and dependencies, and upload the squashed merges to Gerrit
4. Run `aosp-merger/aosp-merger.sh devices` to merge newly entered AOSP tags to all supported device's device-tree and dependencies, and upload the merges to Gerrit
5. Run `aosp-merger/aosp-merger.sh kernels` to merge newly entered AOSP kernel tags to all supported device's kernel-tree and dependencies, and upload the squashed merges to Gerrit
5. Run `aosp-merger/aosp-merger.sh kernels` to merge newly entered AOSP kernel tags to all supported device's kernel-tree and dependencies, and upload the merges to Gerrit
6. Download pixel factory images, extract files and firmware - e.g. `source ${TOP}/vendor/lineage/vars/devices && for device in devices; do pixel/device.sh $device done`
@@ -100,6 +100,6 @@ To merge a new CAF/CLO tag to all forked repositories:
2. Edit `vendor/lineage/vars/qcom`, `git commit` and upload the change to Gerrit
3. Run the merger script on whatever platforms you have updated the tags to create squashed merges and upload them to Gerrit - e.g. To merge on all support platforms you'd run `for platform in qssi msm8953 sdm660 sdm845 msmnile kona lahaina waipio-vendor waipio-video; do aosp-merger/aosp-merger.sh clo $platform done`
3. Run the merger script on whatever platforms you have updated the tags to create merges and upload them to Gerrit - e.g. To merge on all support platforms you'd run `for platform in qssi msm8953 sdm660 sdm845 msmnile kona lahaina waipio-vendor waipio-video; do aosp-merger/aosp-merger.sh clo $platform done`
4. When testing is done, a global committer or higher can run the merger script to push the un-squashed merges to HEADs - e.g. To push afformentioned merges on all support platforms you'd run `for platform in qssi msm8953 sdm660 sdm845 msmnile kona lahaina waipio-vendor waipio-video; do aosp-merger/aosp-merger.sh submit-clo $platform done`
4. When testing is done, a global committer or higher can run the merger script to push the merges to HEADs - e.g. To push afformentioned merges on all support platforms you'd run `for platform in qssi msm8953 sdm660 sdm845 msmnile kona lahaina waipio-vendor waipio-video; do aosp-merger/aosp-merger.sh submit-clo $platform done`

View File

@@ -56,11 +56,19 @@ merge_aosp_forks() {
}
post_aosp_merge() {
if [ "${merge_method}" = "merge" ]; then
return
else
"${script_path}"/squash.sh --branch-suffix "${os_branch}_merge-${common_aosp_tag}"
fi
}
upload_aosp_merge_to_review() {
if [ "${merge_method}" = "merge" ]; then
"${script_path}"/upload-merge.sh --branch-suffix "${os_branch}_merge-${common_aosp_tag}"
else
"${script_path}"/upload-squash.sh --branch-suffix "${os_branch}_merge-${common_aosp_tag}"
fi
}
push_aosp_merge() {
@@ -75,11 +83,19 @@ merge_pixel_device() {
}
post_pixel_device_merge() {
if [ "${merge_method}" = "merge" ]; then
return
else
"${script_path}"/squash.sh --new-tag "${aosp_tag}" --branch-suffix "${device_branch}_merge-${aosp_tag}" --pixel
fi
}
upload_pixel_device_to_review() {
if [ "${merge_method}" = "merge" ]; then
"${script_path}"/upload-merge.sh --branch-suffix "${device_branch}_merge-${aosp_tag}" --pixel
else
"${script_path}"/upload-squash.sh --branch-suffix "${device_branch}_merge-${aosp_tag}" --pixel
fi
}
push_device_merge() {
@@ -92,11 +108,19 @@ merge_pixel_kernel() {
}
post_pixel_kernel_merge() {
if [ "${merge_method}" = "merge" ]; then
return
else
"${script_path}"/squash.sh --new-tag "${kernel_tag}" --branch-suffix "${device_branch}_merge-${kernel_tag}" --pixel
fi
}
upload_pixel_kernel_to_review() {
if [ "${merge_method}" = "merge" ]; then
"${script_path}"/upload-merge.sh --branch-suffix "${device_branch}_merge-${kernel_tag}" --pixel
else
"${script_path}"/upload-squash.sh --branch-suffix "${device_branch}_merge-${kernel_tag}" --pixel
fi
}
push_kernel_merge() {
@@ -113,7 +137,11 @@ squash_clo_merge() {
}
upload_squash_clo_to_review() {
if [ "${merge_method}" = "merge" ]; then
"${script_path}"/upload-merge.sh --new-tag "${1}" --branch-suffix "${os_branch}_merge-${1}"
else
"${script_path}"/upload-squash.sh --new-tag "${1}" --branch-suffix "${os_branch}_merge-${1}"
fi
}
push_clo_merge() {

94
aosp-merger/upload-merge.sh Executable file
View File

@@ -0,0 +1,94 @@
#!/bin/bash
#
# SPDX-FileCopyrightText: 2017, 2020-2022 The LineageOS Project
# SPDX-FileCopyrightText: 2021-2022 The Calyx Institute
#
# SPDX-License-Identifier: Apache-2.0
#
usage() {
echo "Usage ${0} -n <new-tag> -b <branch-suffix> --pixel"
}
# Verify argument count
if [ "${#}" -eq 0 ]; then
usage
exit 1
fi
PIXEL=false
while [ "${#}" -gt 0 ]; do
case "${1}" in
-n | --new-tag )
NEWTAG="${2}"; shift
;;
-b | --branch-suffix )
BRANCHSUFFIX="${2}"; shift
;;
-p | --pixel )
PIXEL=true; shift
;;
* )
usage
exit 1
;;
esac
shift
done
### CONSTANTS ###
readonly script_path="$(cd "$(dirname "$0")";pwd -P)"
readonly vars_path="${script_path}/../../../vendor/lineage/vars"
source "${vars_path}/common"
TOP="${script_path}/../../.."
STAGINGBRANCH="staging/${BRANCHSUFFIX}"
if [ ! -z "${NEWTAG}" ]; then
TOPIC="${NEWTAG}"
elif [ "${PIXEL}" = true ]; then
TOPIC="${topic}_pixel"
else
TOPIC="${topic}"
fi
# Source build environment (needed for lineageremote)
source "${TOP}/build/envsetup.sh"
# List of merged repos
PROJECTPATHS=$(cat ${MERGEDREPOS} | grep -w merge | awk '{printf "%s\n", $2}')
echo "#### Staging branch = ${STAGINGBRANCH} ####"
# Make sure manifest and forked repos are in a consistent state
echo "#### Verifying there are no uncommitted changes on forked AOSP projects ####"
for PROJECTPATH in ${PROJECTPATHS} .repo/manifests; do
cd "${TOP}/${PROJECTPATH}"
if [[ -n "$(git status --porcelain)" ]]; then
echo "Path ${PROJECTPATH} has uncommitted changes. Please fix."
exit 1
fi
done
echo "#### Verification complete - no uncommitted changes found ####"
# Iterate over each forked project
for PROJECTPATH in ${PROJECTPATHS}; do
cd "${TOP}/${PROJECTPATH}"
if [ "${PIXEL}" = true ]; then
BRANCH="${device_branch}"
else
BRANCH=$(git config --get branch.${STAGINGBRANCH}.merge | sed 's|refs/heads/||')
if [ -z "${BRANCH}" ]; then
BRANCH="${os_branch}"
fi
fi
echo "#### Pushing ${PROJECTPATH} merge to review ####"
git checkout "${STAGINGBRANCH}"
lineageremote | grep -v "Remote 'lineage' created"
FIRST_SHA="$(git show -s --pretty=%P HEAD | cut -d ' ' -f 1)"
SECOND_SHA="$(git show -s --pretty=%P HEAD | cut -d ' ' -f 2)"
git push lineage HEAD:refs/for/"${BRANCH}"%base="${FIRST_SHA}",base="${SECOND_SHA}",topic="${TOPIC}"
done