mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 18:38:01 +00:00
The merge can trigger conflicts if a change has been cherry picked ahead of the merge. We always want to resolve conflicts by picking the incoming version from cros/main. BUG=None TEST=./tools/chromeos/create_merge Change-Id: I06694dd24b051fcdc12dbaccdbab552c72d7f2c4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3494968 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
106 lines
2.4 KiB
Bash
Executable file
106 lines
2.4 KiB
Bash
Executable file
#!/bin/bash
|
|
# Copyright 2021 The Chromium OS Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
#
|
|
# Script to create a commit to merge cros/main into cros/chromeos with a useful
|
|
# commit message.
|
|
#
|
|
# Basic usage to upload a merge to gerrit:
|
|
#
|
|
# $ repo start uprev .
|
|
# $ ./tools/chromeos/create_merge
|
|
# $ git push cros HEAD:refs/for/chromeos
|
|
#
|
|
# To merge with a specific commit, use: ./tools/chromeos/create_merge $SHA
|
|
|
|
set -e
|
|
|
|
if [ "$1" == "--dry-run-only" ]; then
|
|
DRY_RUN_ONLY=true
|
|
shift
|
|
fi
|
|
|
|
LOCAL_BRANCH=$(git branch --show-current)
|
|
REMOTE_NAME=$(git config "branch.${LOCAL_BRANCH}.remote")
|
|
URL=$(git remote get-url "${REMOTE_NAME}")
|
|
|
|
DEFAULT_TARGET="${REMOTE_NAME}/main"
|
|
MERGE_TARGET="${1:-${DEFAULT_TARGET}}"
|
|
|
|
commit_list() {
|
|
git log --oneline --decorate=no --no-color "HEAD..${MERGE_TARGET}"
|
|
}
|
|
|
|
prerequisites() {
|
|
if [[ -e "${LOCAL_BRANCH}" ]] ||
|
|
[[ -e "${REMOTE_NAME}" ]] ||
|
|
[[ -e "${URL}" ]]; then
|
|
echo "This script requires the local repository to be on" \
|
|
"a tracking branch."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -n $(git status -s) ]]; then
|
|
echo "Working directory is not clean:"
|
|
git status -s
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "$(commit_list)" ]]; then
|
|
echo "Nothing to merge."
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
cq_depends() {
|
|
git log --no-color "HEAD..${MERGE_TARGET}" --pretty=email |
|
|
grep ^Cq-Depend: |
|
|
sort -u
|
|
}
|
|
|
|
bug_references() {
|
|
git log --no-color "HEAD..${MERGE_TARGET}" --pretty=email |
|
|
grep ^BUG= |
|
|
grep -vi ^BUG=none |
|
|
sort -u
|
|
}
|
|
|
|
merge_message() {
|
|
local old=$(git rev-parse HEAD)
|
|
local new=$(git rev-parse "${MERGE_TARGET}")
|
|
local count=$(commit_list | wc -l)
|
|
|
|
local notes="$(date +%F)"
|
|
if [[ -n "$(cq_depends)" ]]; then
|
|
notes="${notes}, cq-depend"
|
|
fi
|
|
|
|
if [ "${DRY_RUN_ONLY}" = true ]; then
|
|
echo "Merge dry run (${notes})"
|
|
else
|
|
echo "Merge ${count} commits from ${MERGE_TARGET} (${notes})"
|
|
fi
|
|
echo ""
|
|
commit_list
|
|
echo ""
|
|
echo "${URL}/+log/${old}..${new}"
|
|
echo ""
|
|
if [ "${DRY_RUN_ONLY}" != true ]; then
|
|
bug_references
|
|
fi
|
|
echo "TEST=CQ"
|
|
echo ""
|
|
cq_depends
|
|
if [ "${DRY_RUN_ONLY}" = true ]; then
|
|
echo "Commit: false"
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
prerequisites
|
|
git merge -X theirs --no-ff "${MERGE_TARGET}" -m "$(merge_message)"
|
|
git --no-pager log -n 1
|
|
}
|
|
|
|
main
|