2015-02-09 00:16:00 +00:00
|
|
|
# vim: set ts=3 sw=3 noet ft=sh : bash
|
|
|
|
|
|
|
|
# FIXME: This doesn't belong here, move it
|
|
|
|
echo_cmd() {
|
|
|
|
echo "$@"
|
|
|
|
"$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-15 18:23:46 +00:00
|
|
|
# fetch_git
|
2015-02-09 00:16:00 +00:00
|
|
|
# Clones or pulls updates from a git repository into a local directory
|
|
|
|
#
|
|
|
|
# $1 The URI to fetch
|
|
|
|
# $2 The local directory to fetch to (relative)
|
2015-02-15 19:06:52 +00:00
|
|
|
# $3 The pretty name for the === Fetching line ("" to print nothing)
|
|
|
|
# $4 Set to clone --recursive
|
|
|
|
# $5 Set to pull --recursive
|
2015-02-15 18:23:46 +00:00
|
|
|
#
|
|
|
|
# NOTE: git _now_ has a -C argument that would replace the cd commands in
|
|
|
|
# this rule, but this is a fairly recent addition to git, so we can't
|
|
|
|
# use it here. --iKarith
|
2015-02-09 00:16:00 +00:00
|
|
|
fetch_git() {
|
|
|
|
fetch_dir="$WORKDIR/$2"
|
2015-02-15 19:06:52 +00:00
|
|
|
[ -n "$3" ] && echo "=== Fetching $3 ==="
|
2015-02-09 00:16:00 +00:00
|
|
|
if [ -d "$fetch_dir/.git" ]; then
|
2015-02-15 18:23:46 +00:00
|
|
|
echo_cmd cd "$fetch_dir"
|
|
|
|
echo_cmd git pull
|
2015-02-15 19:06:52 +00:00
|
|
|
[ -n "$5" ] && echo_cmd git submodule foreach git pull origin master
|
2015-02-09 00:16:00 +00:00
|
|
|
else
|
2015-02-15 18:23:46 +00:00
|
|
|
echo_cmd cd "$WORKDIR"
|
|
|
|
echo_cmd git clone "$1"
|
2015-02-15 19:06:52 +00:00
|
|
|
if [ -n "$4" ]; then
|
2015-02-15 18:23:46 +00:00
|
|
|
echo_cmd cd "$fetch_dir"
|
|
|
|
echo_cmd git submodule update --init
|
|
|
|
fi
|
2015-02-09 00:16:00 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-02-14 12:53:05 +00:00
|
|
|
# revision_git <local directory>
|
|
|
|
# Output the hash of the last commit in a git repository
|
|
|
|
revision_git() {
|
|
|
|
git -C "$WORKDIR/$1" log -n 1 --pretty=format:%H
|
|
|
|
}
|
|
|
|
|