Files
scripts/aosp-merger/push-merge.sh
Michael Bestas cf357b2ac3 aosp-merger: Get the correct branch for squash/push from git
Change-Id: I54c3fe16b6c05c7b39ede9c4a4ef05f5b4f44e28
2023-03-21 04:59:43 +05:30

75 lines
2.0 KiB
Bash
Executable File

#!/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} -b <branch-suffix>"
}
# Verify argument count
if [ "${#}" -eq 0 ]; then
usage
exit 1
fi
while [ "${#}" -gt 0 ]; do
case "${1}" in
-b | --branch-suffix )
BRANCHSUFFIX="${2}"; 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}"
BRANCH=$(git config --get branch.${STAGINGBRANCH}.merge | sed 's|refs/heads/||')
if [ -z "${BRANCH}" ]; then
BRANCH="${lineageos_branch}"
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 "#### Branch = ${BRANCH} Staging branch = ${STAGINGBRANCH} ####"
# Make sure manifest and forked repos are in a consistent state
echo "#### Verifying there are no uncommitted changes on LineageOS 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 ####"
echo "#### $(basename ${MERGEDREPOS}) ####"
read -p "Pushing ${STAGINGBRANCH} to ${BRANCH}. Press enter to confirm."
# Iterate over each forked project
for PROJECTPATH in ${PROJECTPATHS}; do
cd "${TOP}/${PROJECTPATH}"
echo "#### Submitting ${PROJECTPATH} merge ####"
git checkout "${STAGINGBRANCH}"
lineageremote | grep -v "Remote 'lineage' created"
git push lineage HEAD:refs/heads/"${BRANCH}"
done