From 8c9636f9a64d803b8224e4f808598eccf901ea47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 29 Aug 2018 10:40:21 +0200 Subject: Replace git_fetch with git_clone that does one-depth clone --- scripts/utils | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'scripts/utils') diff --git a/scripts/utils b/scripts/utils index 1c364a0..4f8fbec 100644 --- a/scripts/utils +++ b/scripts/utils @@ -58,7 +58,25 @@ git_fetch() { git_fetch_bare "$1" "$2" local BRANCH="$3" [ -n "$BRANCH" ] || BRANCH=master - git --git-dir="$WORKSPACE/$2" --bare worktree add --detach $2 $BRANCH + git --git-dir="$WORKSPACE/$2" --bare worktree add --detach "$2" "$BRANCH" +} + +# Clones one depth given repository with given branch/tag/hash +# 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_clone() { + local BRANCH="$3" + [ -n "$BRANCH" ] || BRANCH=master + ( + mkdir "$2" + cd "$2" + git init + git remote add origin "$1" + git fetch --depth 1 origin "$BRANCH" + git checkout FETCH_HEAD + ) } # Lock special lock for this job -- cgit v1.2.3