Karsten Tausche | 1596bc4 | 2018-08-15 13:27:45 +0200 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright 2018 Fairphone B.V. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | |
| 18 | # Check https://partner-android.googlesource.com on how to set up access |
| 19 | |
| 20 | AOSP_PARTNER_REF=${AOSP_PARTNER_REF:-security-aosp-nyc-mr2-release} |
| 21 | AOSP_PARTNER_BASE_URL=https://partner-android.googlesource.com |
| 22 | |
| 23 | url=${AOSP_PARTNER_BASE_URL}/${REPO_PROJECT}.git |
| 24 | git ls-remote --exit-code ${url} ${AOSP_PARTNER_REF} > /dev/null 2>&1 |
| 25 | case $? in |
| 26 | 0) |
| 27 | echo "INFO: Fetching AOSP-Partner ref. (${AOSP_PARTNER_REF})…" |
| 28 | git remote add aosp-partner ${url} 2> /dev/null || true |
| 29 | git fetch --quiet aosp-partner ${AOSP_PARTNER_REF}:${AOSP_PARTNER_REF} |
| 30 | if test $? -ne 0; then |
| 31 | echo "ERROR: Could not fetch ${AOSP_PARTNER_REF} from remote AOSP-Partner." >&2 |
| 32 | exit 1 |
| 33 | fi |
| 34 | aosp_partner_ref_commit=$(git rev-list -n1 ${AOSP_PARTNER_REF} 2> /dev/null) |
| 35 | echo "INFO: Pushing AOSP-Partner ref to origin…" |
| 36 | git push origin ${AOSP_PARTNER_REF}:refs/heads/${AOSP_PARTNER_REF} |
| 37 | if test $? -ne 0; then |
| 38 | echo "ERROR: Could not push ${AOSP_PARTNER_REF} to origin." >&2 |
| 39 | exit 1 |
| 40 | fi |
| 41 | ;; |
| 42 | 2) |
| 43 | echo "WARNING: Skipping remote AOSP-Partner, ${AOSP_PARTNER_REF} does not exist on remote, ignoring project." >&2 |
| 44 | exit 0 |
| 45 | ;; |
| 46 | 128) |
| 47 | echo "WARNING: Skipping remote AOSP-Partner, ${url} is not a valid remote, ignoring project." >&2 |
| 48 | exit 0 |
| 49 | ;; |
| 50 | *) |
| 51 | echo "ERROR: Skipping remote AOSP-Partner, could not list ${url}." >&2 |
| 52 | exit 1 |
| 53 | ;; |
| 54 | esac |