summaryrefslogtreecommitdiffstats
path: root/build/cache.sh
diff options
context:
space:
mode:
authorStefan K. Berg <stefan.k.berg@ericsson.com>2015-12-18 12:53:46 +0100
committerJonas Bjurel <jonas.bjurel@ericsson.com>2015-12-21 17:52:48 +0000
commit23e7333bb4e4ec228596d994bec18dc8d0670b2e (patch)
treefb4a4aec4460b8b86ad0feddf4e99faa10bc7b48 /build/cache.sh
parente354b304952bb87547d9ee7298b8a5b78394e401 (diff)
Align all plugins with new method for cache id
The cache tool is now responsible for returning the commit ID of a branch, tag or commit. This change was first introduced in the bgpvpn plugin and now the rest of the plugins with a need for this are also using the same method. Without this, a plugin pointing to a commit ID on master would fail to build once the head of master is updated to point to a later commit... Change-Id: I7c32d5b41871741717ae42c1334e8557f0b0bedd Signed-off-by: Stefan K. Berg <stefan.k.berg@ericsson.com>
Diffstat (limited to 'build/cache.sh')
-rwxr-xr-xbuild/cache.sh23
1 files changed, 21 insertions, 2 deletions
diff --git a/build/cache.sh b/build/cache.sh
index ed900568a..07361d28a 100755
--- a/build/cache.sh
+++ b/build/cache.sh
@@ -96,13 +96,32 @@ validSHA1() {
# Figure out commit ID from URI and tag/branch/commit ID
getcommitid() {
- HEADMATCH=`git ls-remote $1 | grep "refs/heads/$2$" | awk '{ print $1 }'`
- TAGMATCH=`git ls-remote $1 | grep "refs/tags/$2$" | awk '{ print $1 }'`
+ if echo $2 | grep -q '^refs/changes/'; then
+ REF=`echo $2 | sed "s,refs\/changes\/\(.*\),\1,"`
+ else
+ REF=$2
+ fi
+
+ echo "Repo is $1, ref is ${REF}" >&2
+
+ HEADMATCH=`git ls-remote $1 | grep "refs/heads/${REF}$" | awk '{ print $1 }'`
+ TAGMATCH=`git ls-remote $1 | grep "refs/tags/${REF}$" | awk '{ print $1 }'`
+ CHANGEMATCH=`git ls-remote $1 | grep "refs/changes/${REF}$" | awk '{ print $1 }'`
if [ -n "$HEADMATCH" ]; then
echo "$HEADMATCH"
elif [ -n "$TAGMATCH" ]; then
echo "$TAGMATCH"
+ elif [ -n "$CHANGEMATCH" ]; then
+ echo "Warning: ${REF} is a change!" >&2
+ TMPDIR=`mktemp -d /tmp/cacheXXXXX`
+ cd $TMPDIR
+ git clone $1 &>/dev/null || errorexit "Could not clone $1"
+ cd * || errorexit "Could not enter clone of $1"
+ git fetch $1 refs/changes/$REF &>/dev/null || errorexit "Could not fetch change"
+ git checkout FETCH_HEAD &>/dev/null || errorexit "Could not checkout FETCH_HEAD"
+ git show HEAD &>/dev/null || errorexit "Could not find commit $2"
+ git show HEAD | head -1 | awk '{ print $2 }'
else
TMPDIR=`mktemp -d /tmp/cacheXXXXX`
cd $TMPDIR