mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
Kokoro merge bot: Rebase merges before uploading
This allows the bot to account for manually cherry-picked commits. To make rebases work properly, we had to fix the commit message trailers to be added in a separate paragraph. This ensures git inspect-trailers can add and find the Commit-Id trailer. BUG=b:226975273 TEST=./ci/kokoro/simulate.py ./ci/kokoro/build-merge-into-chromeos.sh Change-Id: If008be1f1c671ef1d79c6f223f10ea0e8f6742b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3561015 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Maciek Swiech <drmasquatch@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
parent
ba0e3dbcb8
commit
e871ee9601
2 changed files with 19 additions and 10 deletions
|
@ -195,18 +195,21 @@ main() {
|
|||
parent_commit="FETCH_HEAD"
|
||||
fi
|
||||
|
||||
local merge_count=$(git log --oneline --decorate=no --no-color \
|
||||
"${parent_commit}..origin/main" | wc -l)
|
||||
if [ "${merge_count}" -lt "$MIN_COMMIT_COUNT" ]; then
|
||||
echo "Not enough commits to merge. Skipping."
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Checking out parent: ${parent_commit}"
|
||||
git checkout -b chromeos "${parent_commit}"
|
||||
git branch --set-upstream-to origin/chromeos chromeos
|
||||
|
||||
local merge_count=$(git log --oneline --decorate=no --no-color \
|
||||
"${parent_commit}..origin/main" | wc -l)
|
||||
if [ "${merge_count}" -ge "$MIN_COMMIT_COUNT" ]; then
|
||||
"${KOKORO_ARTIFACTS_DIR}/create_merge" "origin/main"
|
||||
else
|
||||
echo "Not enough commits to merge."
|
||||
fi
|
||||
|
||||
# Rebase to integrate cherry-picks. Always resolve conflicts with content from origin/main.
|
||||
git rebase --rebase-merges -X theirs
|
||||
|
||||
upload_with_retries
|
||||
|
||||
echo "Abandoning previous dry runs"
|
||||
|
|
|
@ -90,7 +90,9 @@ merge_message() {
|
|||
bug_references
|
||||
fi
|
||||
echo "TEST=CQ"
|
||||
echo ""
|
||||
}
|
||||
|
||||
merge_trailers() {
|
||||
cq_depends
|
||||
if [ "${DRY_RUN_ONLY}" = true ]; then
|
||||
echo "Commit: false"
|
||||
|
@ -99,7 +101,11 @@ merge_message() {
|
|||
|
||||
main() {
|
||||
prerequisites
|
||||
git merge -X theirs --no-ff "${MERGE_TARGET}" -m "$(merge_message)"
|
||||
# Note: trailers need to be added in a separate -m argument. Otherwise trailing whitespace may
|
||||
# be trimmed which can confuse the gerrit preupload hook when it's trying to add the Commit-Id
|
||||
# trailer.
|
||||
git merge -X theirs --no-ff "${MERGE_TARGET}" -m "$(merge_message)" -m "$(merge_trailers)"
|
||||
|
||||
git --no-pager log -n 1
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue