# vim:syn=sh init() { # AOSP's gerrit doesn't like anonymous checkouts git config --global user.email &>/dev/null || git config --global user.email buildbot@linaro.org git config --global user.name &>/dev/null || git config --global user.name "Linaro Build Bot" } apply() { local REPO local DIR local SERVER if [ "$1" = "--linaro" ]; then SERVER="git://review.android.git.linaro.org/" shift elif [ "$1" = "--server" ]; then shift SERVER="$1" shift else SERVER="https://android.googlesource.com/" fi if echo "$1" |grep -q '^device/'; then REPO="$1" else REPO="platform/$1" fi DIR=`echo $2 |cut -d/ -f1 |rev |cut -b1-2 |rev` cd "$AOSP"/"$1" echo "=== Applying $2 ===" if ! git fetch "$SERVER$REPO" refs/changes/$DIR/"$2"; then echo "Failed to fetch $2, typo in script?" exit 1 fi if ! git cherry-pick FETCH_HEAD; then echo "$2 failed to apply, please fix" exit 1 fi PATCHES=$((PATCHES+1)) } cherrypick() { cd "$AOSP"/"$1" echo "=== Cherry-picking $2 ===" if ! git cherry-pick "$2"; then echo "$2 failed to apply, please fix" exit 1 fi PATCHES=$((PATCHES+1)) } revert() { local PATCH PATCH=false if [ "$1" == "--patch" -o "$1" == "-p" ]; then PATCH=true shift fi cd "$AOSP"/"$1" echo "=== Reverting $2 ===" if $PATCH; then if ! git show $2 |patch -p1 -R; then echo "$2 failed to revert by patching, please fix" exit 1 fi git commit -am "Revert $2" else if ! git revert --no-edit "$2"; then echo "$2 failed to revert, please fix" exit 1 fi fi PATCHES=$((PATCHES+1)) }