From 69de21ad15706184a89f00951e23f5059bfbebde Mon Sep 17 00:00:00 2001 From: Adam Rehn Date: Wed, 15 Dec 2021 12:28:37 +1000 Subject: [PATCH 1/3] Add the ability to clone a specific commit of the Unreal Engine --- .../dockerfiles/ue4-source/linux/Dockerfile | 17 ++++++++++++++--- .../dockerfiles/ue4-source/windows/Dockerfile | 9 +++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/ue4docker/dockerfiles/ue4-source/linux/Dockerfile b/ue4docker/dockerfiles/ue4-source/linux/Dockerfile index 73bab9b9..6ce382f6 100644 --- a/ue4docker/dockerfiles/ue4-source/linux/Dockerfile +++ b/ue4docker/dockerfiles/ue4-source/linux/Dockerfile @@ -22,7 +22,7 @@ COPY ${SOURCE_LOCATION} /home/ue4/UnrealEngine # The git repository that we will clone ARG GIT_REPO="" -# The git branch/tag that we will checkout +# The git branch/tag/commit that we will checkout ARG GIT_BRANCH="" {% if credential_mode == "secrets" %} @@ -38,7 +38,13 @@ RUN chmod +x /tmp/git-credential-helper-secrets.sh ARG CHANGELIST RUN --mount=type=secret,id=username,uid=1000,required \ --mount=type=secret,id=password,uid=1000,required \ - CHANGELIST="$CHANGELIST" git clone --progress --depth=1 -b $GIT_BRANCH $GIT_REPO {{ clone_opts }} /home/ue4/UnrealEngine + CHANGELIST="$CHANGELIST" \ + mkdir /home/ue4/UnrealEngine && \ + cd /home/ue4/UnrealEngine && \ + git init && \ + git remote add origin "$GIT_REPO" && \ + git fetch --progress --depth 1 {{ clone_opts }} origin "$GIT_BRANCH" && \ + git checkout FETCH_HEAD {% else %} @@ -56,7 +62,12 @@ ENV GIT_ASKPASS=/tmp/git-credential-helper-endpoint.sh RUN chmod +x /tmp/git-credential-helper-endpoint.sh # Clone the UE4 git repository using the endpoint-supplied credentials -RUN git clone --progress --depth=1 -b $GIT_BRANCH $GIT_REPO {{ clone_opts }} /home/ue4/UnrealEngine +RUN mkdir /home/ue4/UnrealEngine && \ + cd /home/ue4/UnrealEngine && \ + git init && \ + git remote add origin "$GIT_REPO" && \ + git fetch --progress --depth 1 {{ clone_opts }} origin "$GIT_BRANCH" && \ + git checkout FETCH_HEAD {% endif %} diff --git a/ue4docker/dockerfiles/ue4-source/windows/Dockerfile b/ue4docker/dockerfiles/ue4-source/windows/Dockerfile index c4de71fa..43377ce1 100644 --- a/ue4docker/dockerfiles/ue4-source/windows/Dockerfile +++ b/ue4docker/dockerfiles/ue4-source/windows/Dockerfile @@ -23,7 +23,7 @@ COPY ${SOURCE_LOCATION} C:\UnrealEngine # The git repository that we will clone ARG GIT_REPO="" -# The git branch/tag that we will checkout +# The git branch/tag/commit that we will checkout ARG GIT_BRANCH="" # Retrieve the address for the host that will supply git credentials @@ -40,7 +40,12 @@ ENV GIT_ASKPASS=C:\git-credential-helper.bat # Clone the UE4 git repository using the host-supplied credentials WORKDIR C:\ -RUN git clone --progress --depth=1 -b %GIT_BRANCH% %GIT_REPO% {{ clone_opts }} C:\UnrealEngine +RUN mkdir C:\UnrealEngine && \ + cd C:\UnrealEngine && \ + git init && \ + git remote add origin %GIT_REPO% && \ + git fetch --progress --depth 1 {{ clone_opts }} origin %GIT_BRANCH% && \ + git checkout FETCH_HEAD {% endif %} From 4db4b3b3adb010ec733fb322eea17b82b020153d Mon Sep 17 00:00:00 2001 From: Adam Rehn Date: Wed, 15 Dec 2021 15:47:33 +1000 Subject: [PATCH 2/3] Add ability to specify git config options --- ue4docker/dockerfiles/ue4-source/linux/Dockerfile | 14 ++++++++++++-- .../dockerfiles/ue4-source/windows/Dockerfile | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/ue4docker/dockerfiles/ue4-source/linux/Dockerfile b/ue4docker/dockerfiles/ue4-source/linux/Dockerfile index 6ce382f6..83389431 100644 --- a/ue4docker/dockerfiles/ue4-source/linux/Dockerfile +++ b/ue4docker/dockerfiles/ue4-source/linux/Dockerfile @@ -42,8 +42,13 @@ RUN --mount=type=secret,id=username,uid=1000,required \ mkdir /home/ue4/UnrealEngine && \ cd /home/ue4/UnrealEngine && \ git init && \ + {% if git_config %} + {% for key, value in git_config.items() %} + git config {{ key }} {{ value }} && \ + {% endfor %} + {% endif %} git remote add origin "$GIT_REPO" && \ - git fetch --progress --depth 1 {{ clone_opts }} origin "$GIT_BRANCH" && \ + git fetch --progress --depth 1 {{ fetch_opts }} origin "$GIT_BRANCH" && \ git checkout FETCH_HEAD {% else %} @@ -65,8 +70,13 @@ RUN chmod +x /tmp/git-credential-helper-endpoint.sh RUN mkdir /home/ue4/UnrealEngine && \ cd /home/ue4/UnrealEngine && \ git init && \ + {% if git_config %} + {% for key, value in git_config.items() %} + git config {{ key }} {{ value }} && \ + {% endfor %} + {% endif %} git remote add origin "$GIT_REPO" && \ - git fetch --progress --depth 1 {{ clone_opts }} origin "$GIT_BRANCH" && \ + git fetch --progress --depth 1 {{ fetch_opts }} origin "$GIT_BRANCH" && \ git checkout FETCH_HEAD {% endif %} diff --git a/ue4docker/dockerfiles/ue4-source/windows/Dockerfile b/ue4docker/dockerfiles/ue4-source/windows/Dockerfile index 43377ce1..25c6b101 100644 --- a/ue4docker/dockerfiles/ue4-source/windows/Dockerfile +++ b/ue4docker/dockerfiles/ue4-source/windows/Dockerfile @@ -43,8 +43,13 @@ WORKDIR C:\ RUN mkdir C:\UnrealEngine && \ cd C:\UnrealEngine && \ git init && \ + {% if git_config %} + {% for key, value in git_config.items() %} + git config {{ key }} {{ value }} && \ + {% endfor %} + {% endif %} git remote add origin %GIT_REPO% && \ - git fetch --progress --depth 1 {{ clone_opts }} origin %GIT_BRANCH% && \ + git fetch --progress --depth 1 {{ fetch_opts }} origin %GIT_BRANCH% && \ git checkout FETCH_HEAD {% endif %} From 9ba09bca96f6d1e9d3d3ea2b215f94a5142a8afb Mon Sep 17 00:00:00 2001 From: Adam Rehn Date: Wed, 15 Dec 2021 15:55:39 +1000 Subject: [PATCH 3/3] Remove option to pass extra flags to `git fetch` --- ue4docker/dockerfiles/ue4-source/linux/Dockerfile | 4 ++-- ue4docker/dockerfiles/ue4-source/windows/Dockerfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ue4docker/dockerfiles/ue4-source/linux/Dockerfile b/ue4docker/dockerfiles/ue4-source/linux/Dockerfile index 83389431..c95badf3 100644 --- a/ue4docker/dockerfiles/ue4-source/linux/Dockerfile +++ b/ue4docker/dockerfiles/ue4-source/linux/Dockerfile @@ -48,7 +48,7 @@ RUN --mount=type=secret,id=username,uid=1000,required \ {% endfor %} {% endif %} git remote add origin "$GIT_REPO" && \ - git fetch --progress --depth 1 {{ fetch_opts }} origin "$GIT_BRANCH" && \ + git fetch --progress --depth 1 origin "$GIT_BRANCH" && \ git checkout FETCH_HEAD {% else %} @@ -76,7 +76,7 @@ RUN mkdir /home/ue4/UnrealEngine && \ {% endfor %} {% endif %} git remote add origin "$GIT_REPO" && \ - git fetch --progress --depth 1 {{ fetch_opts }} origin "$GIT_BRANCH" && \ + git fetch --progress --depth 1 origin "$GIT_BRANCH" && \ git checkout FETCH_HEAD {% endif %} diff --git a/ue4docker/dockerfiles/ue4-source/windows/Dockerfile b/ue4docker/dockerfiles/ue4-source/windows/Dockerfile index 25c6b101..62ee9dc5 100644 --- a/ue4docker/dockerfiles/ue4-source/windows/Dockerfile +++ b/ue4docker/dockerfiles/ue4-source/windows/Dockerfile @@ -49,7 +49,7 @@ RUN mkdir C:\UnrealEngine && \ {% endfor %} {% endif %} git remote add origin %GIT_REPO% && \ - git fetch --progress --depth 1 {{ fetch_opts }} origin %GIT_BRANCH% && \ + git fetch --progress --depth 1 origin %GIT_BRANCH% && \ git checkout FETCH_HEAD {% endif %}