| #!/bin/bash |
| |
| # Copyright 2018 Fairphone B.V. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| # |
| |
| # Check https://partner-android.googlesource.com on how to set up access |
| |
| AOSP_PARTNER_REF=${AOSP_PARTNER_REF:-security-aosp-nyc-mr2-release} |
| AOSP_PARTNER_BASE_URL=https://partner-android.googlesource.com |
| |
| url=${AOSP_PARTNER_BASE_URL}/${REPO_PROJECT}.git |
| git ls-remote --exit-code ${url} ${AOSP_PARTNER_REF} > /dev/null 2>&1 |
| case $? in |
| 0) |
| echo "INFO: Fetching AOSP-Partner ref. (${AOSP_PARTNER_REF})…" |
| git remote add aosp-partner ${url} 2> /dev/null || true |
| git fetch --quiet aosp-partner ${AOSP_PARTNER_REF}:${AOSP_PARTNER_REF} |
| if test $? -ne 0; then |
| echo "ERROR: Could not fetch ${AOSP_PARTNER_REF} from remote AOSP-Partner." >&2 |
| exit 1 |
| fi |
| aosp_partner_ref_commit=$(git rev-list -n1 ${AOSP_PARTNER_REF} 2> /dev/null) |
| echo "INFO: Pushing AOSP-Partner ref to origin…" |
| git push origin ${AOSP_PARTNER_REF}:refs/heads/${AOSP_PARTNER_REF} |
| if test $? -ne 0; then |
| echo "ERROR: Could not push ${AOSP_PARTNER_REF} to origin." >&2 |
| exit 1 |
| fi |
| ;; |
| 2) |
| echo "WARNING: Skipping remote AOSP-Partner, ${AOSP_PARTNER_REF} does not exist on remote, ignoring project." >&2 |
| exit 0 |
| ;; |
| 128) |
| echo "WARNING: Skipping remote AOSP-Partner, ${url} is not a valid remote, ignoring project." >&2 |
| exit 0 |
| ;; |
| *) |
| echo "ERROR: Skipping remote AOSP-Partner, could not list ${url}." >&2 |
| exit 1 |
| ;; |
| esac |