From 76c59bfbdecacd9edfbedd00e960b2bf665c5b0a Mon Sep 17 00:00:00 2001 From: Jon-Paul Sullivan Date: Tue, 20 May 2014 10:49:15 +0100 Subject: [PATCH] Add support for source-repos gerrit refs Add the ability to supply a gerrit ref in DIB_REPOREF_* and have that reference fetched from the remote and checked out for building within the image. Closes-Bug: #1314021 Change-Id: I5e5742c4cbff98e14121c50dde5e512f192b5415 Co-Authored-By: Robert Collins --- .../extra-data.d/98-source-repositories | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/elements/source-repositories/extra-data.d/98-source-repositories b/elements/source-repositories/extra-data.d/98-source-repositories index aba19cc2a..5b4727659 100755 --- a/elements/source-repositories/extra-data.d/98-source-repositories +++ b/elements/source-repositories/extra-data.d/98-source-repositories @@ -97,7 +97,21 @@ function get_repos_for_element(){ HAS_REF=$(git --git-dir=$CACHE_PATH/.git name-rev $REPOREF 2>/dev/null || true) if [ -z "$DIB_OFFLINE" -o -z "$HAS_REF" ] ; then echo "Updating cache of $REPOLOCATION in $CACHE_PATH with ref $REPOREF" - git --git-dir=$CACHE_PATH/.git fetch --update-head-ok $REPOLOCATION +refs/heads/*:refs/heads/* + # Copy named refs (which might be outside the usual heads + # pattern) - e.g. gerrit + if ! git --git-dir=$CACHE_PATH/.git fetch --update-head-ok $REPOLOCATION \ + +${REPOREF}:${REPOREF} ; then + # Copy all heads from the remote repository - this permits + # using a SHA1 object reference so long as the object + # reference is reachable from one of the heads. git does + # not permit arbitrary sha fetching from remote servers. + # This is a separate fetch to the prior one as the prior + # one will fail when REPOREF is a SHA1. + git --git-dir=$CACHE_PATH/.git fetch --update-head-ok $REPOLOCATION \ + +refs/heads/*:refs/heads/* + fi + # Ensure that we have a reference to the revision. + git --git-dir=$CACHE_PATH/.git rev-parse -q --verify $REPOREF^{commit} fi echo "Cloning from $REPONAME cache and applying ref $REPOREF"