Create new branch on bare clone for LOCI

This commit will force a branch creation on a bare clone of the locally
cloned repo so LOCI can use it afterwards to build images. The aim is to
prevent images from being build with code different from what is
checked-in on the local repo. That way we can avoid controlling branches
in two places (manifest and loci files).

Story: 2003907
Task: 42364
Signed-off-by: Thiago Brito <thiago.brito@windriver.com>
Change-Id: I863ac450ddfaec3115f3ecbc2789fc5d7c9d887f
This commit is contained in:
Thiago Brito 2021-08-24 12:24:19 -03:00 committed by Thiago Paiva Brito
parent 625d3506f1
commit cff8bde1a0
1 changed files with 20 additions and 6 deletions

View File

@ -358,12 +358,26 @@ function build_image_loci {
\rm -rf ${CLONE_DIR}
echo "Creating bare clone of ${PROJECT_REPO} for ${LABEL} build..."
git clone --bare ${PROJECT_REPO} ${CLONE_DIR} \
&& mv ${CLONE_DIR}/hooks/post-update.sample ${CLONE_DIR}/hooks/post-update \
&& chmod a+x ${CLONE_DIR}/hooks/post-update \
&& cd ${CLONE_DIR} \
&& git update-server-info \
&& cd ${ORIGWD}
if [ -n "${PROJECT_REF}" ]; then
echo "PROJECT_REF specified is ${PROJECT_REF}..."
git clone --bare ${PROJECT_REPO} ${CLONE_DIR} \
&& cd ${PROJECT_REPO} \
&& git push --force ${CLONE_DIR} HEAD:refs/heads/${PROJECT_REF} \
&& mv ${CLONE_DIR}/hooks/post-update.sample ${CLONE_DIR}/hooks/post-update \
&& chmod a+x ${CLONE_DIR}/hooks/post-update \
&& cd ${CLONE_DIR} \
&& git update-server-info \
&& cd ${ORIGWD}
else
git clone --bare ${PROJECT_REPO} ${CLONE_DIR} \
&& cd ${PROJECT_REPO} \
&& mv ${CLONE_DIR}/hooks/post-update.sample ${CLONE_DIR}/hooks/post-update \
&& chmod a+x ${CLONE_DIR}/hooks/post-update \
&& cd ${CLONE_DIR} \
&& git update-server-info \
&& cd ${ORIGWD}
fi
if [ $? -ne 0 ]; then
echo "Failed to clone ${PROJECT_REPO}... Aborting ${LABEL} build"
RESULTS_FAILED+=(${LABEL})