|
|
|
vcs_git() {
|
|
|
|
local rev='master'
|
|
|
|
local setver=true
|
|
|
|
local clone=true
|
|
|
|
|
|
|
|
local OPTIND=1
|
|
|
|
local opt
|
|
|
|
while getopts 'r:VC' opt; do case "$opt" in
|
|
|
|
r) local rev="$OPTARG" ;;
|
|
|
|
V) local setver=false ;;
|
|
|
|
C) local clone=false ;;
|
|
|
|
esac; done
|
|
|
|
shift $(expr $OPTIND - 1)
|
|
|
|
[ "$#" -ge 1 ] && [ "$1" = '--' ] && shift || true
|
|
|
|
|
|
|
|
local reponame="$(basename "$1")"
|
|
|
|
local dir="$dir_source/$name/$reponame"
|
|
|
|
mkdir -p "$dir"
|
|
|
|
|
|
|
|
cd "$dir"
|
|
|
|
|
|
|
|
if [ ! -f HEAD ]; then
|
|
|
|
# Create new repo
|
|
|
|
git init --bare
|
|
|
|
git remote add --mirror=fetch origin "$1"
|
|
|
|
elif [ "$1" != "$(git config --get remote.origin.url)" ]; then
|
|
|
|
# Update the URL
|
|
|
|
git remote remove origin
|
|
|
|
git remote add --mirror=fetch origin "$1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure we have the latest of whatever revision we want
|
|
|
|
git fetch --prune --depth=1 origin "$rev" || true
|
|
|
|
|
|
|
|
# Check if it's actually been updated
|
|
|
|
local commit="$(git rev-parse "$rev")"
|
|
|
|
if [ "$commit" != "$(cat "${dir}_rev_$name_sat" 2> /dev/null || true)" ]; then
|
|
|
|
echo "$commit" > "${dir}_rev_$name_sat"
|
|
|
|
vcs_compile=true
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Update the $version variable accordingly
|
|
|
|
[ "$setver" = true ] && version="$(git rev-parse --short "$rev")" || true
|
|
|
|
|
|
|
|
cd "$OLDPWD"
|
|
|
|
|
|
|
|
# Clone the repository
|
|
|
|
if [ "$download_only" = false -a "$clone" = true ]; then
|
|
|
|
vcs_git_clone -r "$rev" "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
vcs_git_clone() {
|
|
|
|
local rev='master'
|
|
|
|
local setver=true
|
|
|
|
|
|
|
|
local OPTIND=1
|
|
|
|
local opt
|
|
|
|
while getopts 'r:' opt; do case "$opt" in
|
|
|
|
r) local rev="$OPTARG" ;;
|
|
|
|
esac; done
|
|
|
|
shift $(expr $OPTIND - 1)
|
|
|
|
[ "$#" -ge 1 ] && [ "$1" = '--' ] && shift || true
|
|
|
|
|
|
|
|
local reponame="$(basename "$1")"
|
|
|
|
local dir="$dir_source/$name/$reponame"
|
|
|
|
[ "$#" -ge 2 ] && local dest="$2" || local dest="$reponame"
|
|
|
|
mkdir -p "$dest"
|
|
|
|
|
|
|
|
git clone "$dir" "$dest" 2> /dev/null
|
|
|
|
|
|
|
|
cd "$dest"
|
|
|
|
|
|
|
|
git checkout "$rev" 2> /dev/null
|
|
|
|
|
|
|
|
cd "$OLDPWD"
|
|
|
|
}
|