cozybit/distro11s — pull request #11 by jasonabele (2013-08-01 22:04:22+00:00)
Title: [PATCH] distro11s: allow FORCE_BUILD of fetch.sh

```
From caf396a7899bc73bea6bca3425ec447d0cb4e7d7 Mon Sep 17 00:00:00 2001
From: Jason Abele
Date: Thu, 1 Aug 2013 14:52:04 -0700
Subject: [PATCH] distro11s: allow FORCE_BUILD of fetch.sh

For jenkins specifically (and perhaps other users sometimes) it is
important to be able to reset the source dirs specified in pkglist to
the remote url, branch and tag specified in the pkglist.

This patch allows this with the following invocation:
FORCE_BUILD=1 ./scripts/fetch.sh

WARNING: Using FORCE_BUILD with fetch with local changes risks loosing
work. Please ensure all commits from SRCDIR are pushed elsewhere before
using FORCE_BUILD=1 with fetch.

Signed-off-by: Jason Abele
---
scripts/common.sh | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/scripts/common.sh b/scripts/common.sh
index 161ae6b..cb759d9 100644
--- a/scripts/common.sh
+++ b/scripts/common.sh
@@ -49,7 +49,26 @@ function update_pkg {
if [ ${VCS} = "git" ]; then
Q pushd ${SRCDIR}
CURR_HEAD=`git log --oneline -n1 | awk '{print $1}'`
-	[ "${TAG}" == "" ] && git pull --rebase
+	if [ "${BRANCH}" != `git rev-parse --abbrev-ref HEAD` ]; then
+	if [ ${FORCE_BUILD} -eq 1 ]; then
+	git remote rm origin
+	git remote add origin ${URL}
+	git remote update origin
+	if [ "${BRANCH}" = "" ]; then
+	git branch -D ${BRANCH}
+	git checkout -b ${BRANCH} origin/${BRANCH}
+	else
+	git branch -D master
+	git checkout -b ${BRANCH} origin/master
+	fi
+	else
+	echo "WARNING: skipping update of ${NAME} in ${SRCDIR}"
+	echo "	${SRCDIR} not presently on ${BRANCH}"
+	echo "	use FORCE_BUILD=1 to override or cleanup manually"
+	fi
+	elif [ "${TAG}" == "" ]; then
+	git pull --rebase
+	fi
NEW_HEAD=`git log --oneline -n1 | awk '{print $1}'`
else
echo "Unsupported version control system ${VCS}"
--
1.7.9.5

```