Because of the daily build requirements, you need to download the code with a script to automate the compilation, which is a small piece of functionality throughout the system.
#!/bin/bash# @author liuyang# @date 2015-06-23function Help () {echo ' Usage: $ "echo" first argument should be th e git repository ' s address "echo" For example: [Email protected]:android/xiaomeidaojia.git "echo" s Econd argument should be the branch you want to checkout "echo" for Example:dev "echo" If the second AR Gument is not supplied, master would be used as default "}# Whether the given branch are in local branches.function Is_in_loc Al_branch () {git branch | grep $2>&1 >/dev/null return $?} # Whether The given branch is in remote Branches.function is_in_remote_branch () {git branch-r | grep origin/$1 2>& Amp;1 >/dev/null return $?} if [[$#! = 1 && $#! = 2]]; Then help exit 1fi# Judge whether the repository's address is valid.if [[$! = *.git]]; Then help exit 1fi# Split The project ' s Nameproject_name= ' echo $ (basename $) | Cut-d. -F 1 ' if [[!-D $project _name]]; Then git ClonE $1else cd $project _name git reset HEAD--hard git pull if [[[$ = =]]; Then exit fi is_in_local_branch if [[$? = = 0]]; Then git checkout $ exit fi is_in_remote_branch $ IF [[$ = = 0]]; Then git checkout-b $ origin/$2 Fifi
In the script, first determine if the GIT library exists and does not exist to clone the repository.
Otherwise, all changes are rolled back, then the pull operation is performed, and the final switch to the given branch.
A script that downloads git library code