Alex Buynytskyy | 0842d21 | 2022-09-16 09:33:33 -0700 | [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 | |
Alex Buynytskyy | 92f501a | 2022-11-03 12:29:06 -0700 | [diff] [blame] | 9 | function revert_to_unfinalized_state() { |
Alex Buynytskyy | 0842d21 | 2022-09-16 09:33:33 -0700 | [diff] [blame] | 10 | repo forall -c '\ |
Alex Buynytskyy | 739a311 | 2022-11-02 20:01:30 +0000 | [diff] [blame] | 11 | git checkout . ; git revert --abort ; git clean -fdx ;\ |
Alex Buynytskyy | 0842d21 | 2022-09-16 09:33:33 -0700 | [diff] [blame] | 12 | git checkout @ ; git b fina-step1 -D ; git reset --hard; \ |
| 13 | repo start fina-step1 ; git checkout @ ; git b fina-step1 -D ;\ |
Alex Buynytskyy | 8361b3a | 2022-11-06 00:33:46 +0000 | [diff] [blame] | 14 | baselineHash="$(git log --format=%H --no-merges --max-count=1 --grep ^FINALIZATION_STEP_1_BASELINE_COMMIT)" ;\ |
| 15 | if [[ $baselineHash ]]; then |
| 16 | previousHash="$(git log --format=%H --no-merges --max-count=100 --grep ^FINALIZATION_STEP_1_SCRIPT_COMMIT $baselineHash..HEAD | tr \n \040)" ;\ |
| 17 | else |
| 18 | previousHash="$(git log --format=%H --no-merges --max-count=100 --grep ^FINALIZATION_STEP_1_SCRIPT_COMMIT | tr \n \040)" ;\ |
| 19 | fi ; \ |
Alex Buynytskyy | 92f501a | 2022-11-03 12:29:06 -0700 | [diff] [blame] | 20 | if [[ $previousHash ]]; then git revert --no-commit --strategy=ort --strategy-option=ours $previousHash ; fi ;' |
Alex Buynytskyy | 0842d21 | 2022-09-16 09:33:33 -0700 | [diff] [blame] | 21 | } |
| 22 | |
Alex Buynytskyy | 73e0f97 | 2022-09-23 11:09:21 -0700 | [diff] [blame] | 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_1_SCRIPT_COMMIT -m WILL_BE_AUTOMATICALLY_REVERTED ; |
| 29 | repo upload --cbr --no-verify -t -y . ; |
| 30 | git clean -fdx ; git reset --hard ; |
| 31 | fi' |
| 32 | } |
| 33 | |
Alex Buynytskyy | 0842d21 | 2022-09-16 09:33:33 -0700 | [diff] [blame] | 34 | function finalize_step_1_main() { |
| 35 | local top="$(dirname "$0")"/../.. |
| 36 | |
| 37 | repo selfupdate |
| 38 | |
Alex Buynytskyy | 92f501a | 2022-11-03 12:29:06 -0700 | [diff] [blame] | 39 | revert_to_unfinalized_state |
Alex Buynytskyy | 0842d21 | 2022-09-16 09:33:33 -0700 | [diff] [blame] | 40 | |
| 41 | # vndk etc finalization |
Alex Buynytskyy | 3bd1b91 | 2022-09-22 11:30:53 -0700 | [diff] [blame] | 42 | source $top/build/make/finalize-aidl-vndk-sdk-resources.sh |
Alex Buynytskyy | 0842d21 | 2022-09-16 09:33:33 -0700 | [diff] [blame] | 43 | |
| 44 | # move all changes to fina-step1 branch and commit with a robot message |
Alex Buynytskyy | 73e0f97 | 2022-09-23 11:09:21 -0700 | [diff] [blame] | 45 | commit_changes |
Alex Buynytskyy | 0842d21 | 2022-09-16 09:33:33 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | finalize_step_1_main |