#!/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} " } # Verify argument count if [ "$#" -ne 3 ]; then usage exit 1 fi OPERATION="${1}" OLDTAG="${2}" NEWTAG="${3}" if [ "${OPERATION}" != "merge" -a "${OPERATION}" != "rebase" ]; then usage exit 1 fi ### CONSTANTS ### readonly script_path="$(cd "$(dirname "$0")";pwd -P)" readonly vars_path="${script_path}/../vars" source "${vars_path}/common" TOP="${script_path}/../../.." MERGEDREPOS="${TOP}/merged_repos.txt" BRANCH="${calyxos_branch}" STAGINGBRANCH="staging/${BRANCH}_${OPERATION}-${NEWTAG}" # Source build environment (needed for calyxremote) 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 ####" 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}" calyxremote | grep -v "Remote 'calyx' created" git push calyx HEAD:refs/heads/"${BRANCH}" done