Optimize and re-use an existing repository
Instead of cloning osmocom-bb three times this will allow us to
re-use the repository. Simply change the directory, set the new
origin and fetch.
Change-Id: I63f103b2f70559e969e8c66477ab9ee7f2886832
diff --git a/contrib/jenkins-build-common.sh b/contrib/jenkins-build-common.sh
index bfe8d73..ceee5c0 100644
--- a/contrib/jenkins-build-common.sh
+++ b/contrib/jenkins-build-common.sh
@@ -75,10 +75,14 @@
fi
cd "$base"
- rm -rf "$repo"
- git clone "$git_url/$repo" "$repo"
+ if [ -d "$repo" ]; then
+ cd "$repo"
+ git fetch
+ else
+ git clone "$git_url/$repo" "$repo"
+ cd "$repo"
+ fi
- cd "$repo"
# Figure out whether we need to prepend origin/ to find branches in upstream.
# Doing this allows using git hashes instead of a branch name.
@@ -86,7 +90,7 @@
branch="origin/$branch"
fi
- git checkout -b build_branch "$branch"
+ git checkout -B build_branch "$branch"
rm -rf *
git reset --hard "$branch"