dotfiles/.local/bin/aosp_merge

44 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
. build/envsetup.sh
NEWTAG="${1}"
SQUASH="${2}"
TOP="${ANDROID_BUILD_TOP}"
MANIFEST="${TOP}/.repo/manifests/default.xml"
BRANCH=$(grep "default revision" "${MANIFEST}" \
| sed 's/^ *//g;s/<default revision=\"refs\/heads\///g;s/\"//g')
STAGINGBRANCH="${BRANCH}-${NEWTAG}"
# Build list of forked repos
PROJECTBLACKLIST="Gallery2"
PROJECTPATHS=$(grep "remote=\"omnirom" "${MANIFEST}" \
| grep -v "clone-depth=\"1\"" \
| egrep -v ${PROJECTBLACKLIST} \
| sed -n 's/.*path="\([^"]\+\)".*/\1/p')
repo abandon "${STAGINGBRANCH}"
# Iterate over each forked project
for PROJECTPATH in ${PROJECTPATHS}; do
cd "${TOP}/${PROJECTPATH}"
repo start "${STAGINGBRANCH}" .
aospremote | grep -v "Remote 'aosp' created"
git fetch -q --tags aosp "${NEWTAG}"
echo "#### Merging ${NEWTAG} into ${PROJECTPATH} ####"
if [ ! -z $SQUASH ]; then
git merge --log --squash "${NEWTAG}"
if [ $? -eq 1 ]; then read; fi
if ! git diff --cached --exit-code > /dev/null; then
git commit --no-edit
OLD_MSG=$(git log --format=%B -n1)
git commit --amend -m "[DNM] Squash of ${STAGINGBRANCH}" -m "$OLD_MSG"
fi
else
git merge --log "${NEWTAG}"
if [ $? -eq 1 ]; then read; fi
fi
done