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 17readme() { 18 echo ' 19Clone a git project for the unbundled development workflows in instead of 20 the whole Android repo 21e.g. 22GIT_REPO_URL="https://android.googlesource.com" \ 23 PROJECT="platform/tools/aadevtools" \ 24 WORK_DIR="$PWD" \ 25 ./aadevtools/dev/clone_proj.sh 26' 27} 28 29if [[ -z $GIT_REPO_URL ]]; then 30 readme 31 GIT_REPO_URL="https://android.googlesource.com" 32fi 33echo "GIT_REPO_URL=$GIT_REPO_URL" 34 35if [[ -z $PROJECT ]]; then 36 PROJECT="platform/tools/aadevtools" 37fi 38echo "PROJECT=$PROJECT" 39 40# e.g. taking "aadevtools" from "platform/tools/aadevtools" 41PROJECT_DIR=${PROJECT##*/} 42 43TODAY=$(date +"%y%m%d") 44if [[ -z $WORK_DIR ]]; then 45 export WORK_DIR="$PWD/$TODAY/$BRANCH" 46fi 47echo "WORK_DIR=$WORK_DIR" 48 49mkdir -p $WORK_DIR 50cd $WORK_DIR 51 52SECONDS=0 53echo "Cloning $PROJECT" 54 55if [[ -z $BRANCH ]]; then 56 git clone "$GIT_REPO_URL/$PROJECT" 57else 58 echo echo "BRANCH=$BRANCH" 59 git clone -b $BRANCH "$GIT_REPO_URL/$PROJECT" 60fi 61 62echo "Setup gerrit hooks" 63cd "$WORK_DIR/$PROJECT_DIR" 64f=`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 65 66cd $WORK_DIR 67ls -l 68 69echo " 70Cloned $PROJECT projects took $SECONDS sec. 71 72Do your magic and then get the change pushed for review, e.g.: 73git add . 74git commit 75git push origin HEAD:refs/for/'BRANCH' 76" 77