mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-11 12:35:26 +00:00
chromeos: Add script for merging from cros/main
This script can be used to manually create merge commits to be uploaded to gerrit, and will also be used by the buildes doing automatic uprevs. The main purpose of the script is to create a helpful commit message describing the commits included. BUG=b:209034086 TEST=./tools/chromeos/create_merge Change-Id: I65715ebefb182a5287b5052b6af56361e41d8efd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3315374 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
b6a6e94382
commit
0830e2f11c
1 changed files with 74 additions and 0 deletions
74
tools/chromeos/create_merge
Executable file
74
tools/chromeos/create_merge
Executable file
|
@ -0,0 +1,74 @@
|
|||
#!/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
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/../../" || exit
|
||||
|
||||
ORIGIN="$(git remote get-url cros)"
|
||||
MERGE_TARGET="${1:-cros/main}"
|
||||
|
||||
commit_list() {
|
||||
git log --oneline --decorate=no --no-color "HEAD..${MERGE_TARGET}"
|
||||
}
|
||||
|
||||
prerequisites() {
|
||||
if [[ -e "${ORIGIN}" ]]; then
|
||||
echo "'cros' remote does not exist."
|
||||
echo "Are you running this in a ChromeOS checkout?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local tracking="$(git rev-parse --abbrev-ref --symbolic-full-name @{u})"
|
||||
if [[ "${tracking}" != "cros/chromeos" ]]; then
|
||||
echo "Not tracking the cros/chromeos 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
|
||||
}
|
||||
|
||||
merge_message() {
|
||||
local old=$(git rev-parse HEAD)
|
||||
local new=$(git rev-parse "${MERGE_TARGET}")
|
||||
local count=$(commit_list | wc -l)
|
||||
|
||||
echo "Merge ${count} commits from ${MERGE_TARGET}"
|
||||
echo ""
|
||||
commit_list
|
||||
echo ""
|
||||
echo "${ORIGIN}/+log/${old}..${new}"
|
||||
echo ""
|
||||
echo "BUG=None"
|
||||
echo "TEST=CQ"
|
||||
}
|
||||
|
||||
main() {
|
||||
prerequisites
|
||||
git merge --no-ff "${MERGE_TARGET}" -m "$(merge_message)"
|
||||
git log -n 1
|
||||
}
|
||||
|
||||
main
|
Loading…
Reference in a new issue