1+ #! /bin/bash
2+
3+ # TODO: Write better bash.
4+ # TODO: Handle grapheneos-gitlab remote.
5+ # TODO: Add `repo sync --tags -j8 --force-checkout --force-sync` to this?
6+
7+ set -o errexit -o nounset -o pipefail
8+ source " $( dirname ${BASH_SOURCE[0]} ) /../common.sh"
9+
10+ rebase () {
11+ git fetch -q --tags --all
12+
13+ # Allows us to run this script multiple times if something went wrong.
14+ git rebase --abort & > /dev/null || true
15+
16+ git checkout -q -B " ${developer_port_branch} " " ${tag} "
17+ git_exit=0
18+ git rebase -q --onto $aosp_tag $aosp_tag_old & > /dev/null || git_exit=$?
19+ if [[ " ${git_exit} " == 1 ]]; then
20+ echo " success, but requires manual conflict resolution"
21+ return 0
22+ elif [[ " ${git_exit} " != 0 ]]; then
23+ # If the rebase never begins due to bad tags then git exits with 128.
24+ echo " fail, unexpected error during rebase"
25+ exit 1
26+ fi
27+
28+ if [[ " ${REPO_REMOTE} " == " grapheneos" ]]; then
29+ if ! git push -q -f my-fork $developer_port_branch & > /dev/null
30+ then
31+ echo " fail, unexpected error during push"
32+ exit 2
33+ fi
34+ echo " success"
35+ else
36+ echo " success, but can't push due to hosted on GitLab"
37+ fi
38+ }
39+
40+ # We can't just check if $REPO_REMOTE == "grapheneos" because not all of our repos are AOSP forks. `repo` project groups
41+ # would allow us to simplify this so that we could just run `repo forall -g aosp-forks`.
42+ for graphene_repo in " ${aosp_forks[@]} " ; do
43+ if [[ " ${graphene_repo} " == " ${REPO_PROJECT} " ]] ; then
44+ rebase " ${graphene_repo} "
45+ exit 0
46+ fi
47+ done
0 commit comments