Alex Buynytskyy | 55de663 | 2022-11-30 21:44:29 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Automation for finalize_branch_for_release.sh. |
| 3 | # Sets up local environment, runs the finalization script and submits the results. |
| 4 | # WIP: |
| 5 | # - does not submit, only sends to gerrit. |
| 6 | |
| 7 | # set -ex |
| 8 | |
| 9 | function revert_to_unfinalized_state() { |
| 10 | repo forall -c '\ |
| 11 | git checkout . ; git revert --abort ; git clean -fdx ;\ |
| 12 | git checkout @ ; git branch fina-step2 -D ; git reset --hard; \ |
| 13 | repo start fina-step2 ; git checkout @ ; git b fina-step2 -D ;\ |
| 14 | baselineHash="$(git log --format=%H --no-merges --max-count=1 --grep ^FINALIZATION_STEP_2_BASELINE_COMMIT)" ;\ |
| 15 | if [[ $baselineHash ]]; then |
| 16 | previousHash="$(git log --format=%H --no-merges --max-count=100 --grep ^FINALIZATION_STEP_2_SCRIPT_COMMIT $baselineHash..HEAD | tr \n \040)" ;\ |
| 17 | else |
| 18 | previousHash="$(git log --format=%H --no-merges --max-count=100 --grep ^FINALIZATION_STEP_2_SCRIPT_COMMIT | tr \n \040)" ;\ |
| 19 | fi ; \ |
| 20 | if [[ $previousHash ]]; then git revert --no-commit --strategy=ort --strategy-option=ours $previousHash ; fi ;' |
| 21 | } |
| 22 | |
| 23 | function commit_changes() { |
| 24 | repo forall -c '\ |
| 25 | if [[ $(git status --short) ]]; then |
| 26 | repo start fina-step1 ; |
| 27 | git add -A . ; |
| 28 | git commit -m FINALIZATION_STEP_2_SCRIPT_COMMIT -m WILL_BE_AUTOMATICALLY_REVERTED ; |
Alex Buynytskyy | ce63596 | 2022-12-02 05:19:07 +0000 | [diff] [blame] | 29 | repo upload --cbr --no-verify -o nokeycheck -t -y . ; |
Alex Buynytskyy | 55de663 | 2022-11-30 21:44:29 +0000 | [diff] [blame] | 30 | git clean -fdx ; git reset --hard ; |
| 31 | fi' |
| 32 | } |
| 33 | |
| 34 | function finalize_step_2_main() { |
| 35 | local top="$(dirname "$0")"/../.. |
| 36 | |
| 37 | repo selfupdate |
| 38 | |
| 39 | revert_to_unfinalized_state |
| 40 | |
| 41 | # vndk etc finalization |
| 42 | source $top/build/make/finalize-aidl-vndk-sdk-resources.sh |
| 43 | |
| 44 | # move all changes to fina-step1 branch and commit with a robot message |
| 45 | commit_changes |
| 46 | } |
| 47 | |
| 48 | finalize_step_2_main |