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 car/tools project to operate AVDs."
18
19if [[ -z $GIT_REPO_URL ]]; then
20	GIT_REPO_URL="https://android.googlesource.com"
21fi
22echo "GIT_REPO_URL=$GIT_REPO_URL"
23
24if [[ -z $BRANCH ]]; then
25    echo 'You may set BRANCH="target-branch"'
26fi
27echo "BRANCH=$BRANCH"
28
29if [[ -z $WORK_DIR ]]; then
30    export WORK_DIR="$PWD"
31fi
32echo "WORK_DIR=$WORK_DIR"
33
34mkdir -p $WORK_DIR
35cd $WORK_DIR
36
37echo "git clone https://android.googlesource.com/device/generic/car"
38PROJECTS=0
39SECONDS=0
40PROJECT_PATH="device/generic/car"
41if [[ -z $BRANCH ]]; then
42    git clone "$GIT_REPO_URL/$PROJECT_PATH"
43else
44	git clone -b $BRANCH "$GIT_REPO_URL/$PROJECT_PATH"
45fi
46let "PROJECTS++"
47cd "$WORK_DIR/car"
48f=`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
49cd "$WORK_DIR"
50echo
51
52ls -l "$WORK_DIR"
53
54echo "
55
56Cloning $PROJECTS projects takes: $SECONDS sec.
57
58Do your magic and then get the change pushed for review, e.g.:
59git add -u
60git commit
61git push origin HEAD:refs/for/BRANCH
62"
63