1#!/bin/bash 2 3# Copyright (C) 2020 The Android Open Source Project 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 17echo "An example to clone minimal git projects for the tests app development by Android Studio." 18 19if [[ -z $GIT_REPO_URL ]]; then 20 echo 'Error: you need to specify GIT_REPO_URL="target-url"' 21 exit 22fi 23echo "GIT_REPO_URL=$GIT_REPO_URL" 24 25if [[ -z $BRANCH ]]; then 26 echo 'Error: you need to specify BRANCH="target-branch"' 27 exit 28fi 29echo "BRANCH=$BRANCH" 30 31if [[ -z $WORK_DIR ]]; then 32 export WORK_DIR="$PWD/Car" 33fi 34echo "WORK_DIR=$WORK_DIR" 35 36mkdir -p $WORK_DIR 37cd $WORK_DIR 38 39PROJECTS=0 40SECONDS=0 41echo "Cloning Car/libs" 42git clone -b $BRANCH "$GIT_REPO_URL/platform/packages/apps/Car/libs" 43let "PROJECTS++" 44cd "$WORK_DIR/libs" 45f=`git rev-parse --git-dir`/hooks/commit-msg ; mkdir -p $(dirname $f) ; curl -Lo $f https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x $f 46cd $WORK_DIR 47echo 48 49echo "Cloning Car/libs" 50git clone -b $BRANCH "$GIT_REPO_URL/platform/packages/apps/Car/tests" 51let "PROJECTS++" 52cd "$WORK_DIR/tests" 53f=`git rev-parse --git-dir`/hooks/commit-msg ; mkdir -p $(dirname $f) ; curl -Lo $f https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x $f 54cd $WORK_DIR 55echo 56 57ls -l "$WORK_DIR" 58 59echo " 60 61Cloning $PROJECTS projects takes: $SECONDS sec. 62 63Do your magic and then get the change pushed for review, e.g.: 64git add -u 65git commit 66git push origin HEAD:refs/for/$BRANCH 67" 68