blob: ef80b2bfef4522836b7d217843fb99c048f63314 [file] [log] [blame]
Alex Buynytskyy55de6632022-11-30 21:44:29 +00001#!/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
9function 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
23function 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 Buynytskyyce635962022-12-02 05:19:07 +000029 repo upload --cbr --no-verify -o nokeycheck -t -y . ;
Alex Buynytskyy55de6632022-11-30 21:44:29 +000030 git clean -fdx ; git reset --hard ;
31 fi'
32}
33
34function finalize_step_2_main() {
Alex Buynytskyy5837cc22022-12-15 17:19:53 +000035 # deprecated, do not use
36 exit 1
37
Alex Buynytskyy55de6632022-11-30 21:44:29 +000038 local top="$(dirname "$0")"/../..
39
40 repo selfupdate
41
42 revert_to_unfinalized_state
43
44 # vndk etc finalization
45 source $top/build/make/finalize-aidl-vndk-sdk-resources.sh
46
47 # move all changes to fina-step1 branch and commit with a robot message
48 commit_changes
49}
50
51finalize_step_2_main