summaryrefslogtreecommitdiff
path: root/scripts/utils
blob: b88d4a44c89057901cc5ff7db5f4dbe6c0cda1c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# vim: ft=sh

# Simple echo wrapper for stage marking
echo_stage() {
	echo "========== $@ =========="
}

# Fetch git repository to WORKSPACE and create workspace in current directory
# First agument has to be a source URL
# Second argument is name of directory to which will be directory cloned in.
# Second argument is optional and should be branch name (master is used if not
# provided).
git_fetch() {
	local BRANCH="$3"
	[ -n "$BRANCH" ] || BRANCH=master
	local GITARGS="--git-dir='$WORKSPACE/$2' --bare"
	if [ ! -d "$WORKSPACE/$2" ]; then
		git clone --bare "$1" "$WORKSPACE/$2"
	else
		git $GITARGS fetch --prune --prune-tags --force "$1" "$BRANCH:$BRANCH"
	fi
	git $GITARGS worktree add --detach $2 $BRANCH
}