Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lfs support on windows #28

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docker/Dockerfile.windows.1803
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $Progress
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-lfs/git-lfs/releases/download/v2.12.0/git-lfs-windows-amd64-v2.12.0.zip -OutFile git-lfs.zip; `
Expand-Archive git-lfs.zip -DestinationPath C:\git\lfs;

FROM mcr.microsoft.com/powershell:nanoserver-1803
COPY --from=git /git /git
Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.windows.1809
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $Progress
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-lfs/git-lfs/releases/download/v2.12.0/git-lfs-windows-amd64-v2.12.0.zip -OutFile git-lfs.zip; `
Expand-Archive git-lfs.zip -DestinationPath C:\git\lfs;

FROM mcr.microsoft.com/powershell:nanoserver-1809
COPY --from=git /git /git
Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.windows.1903
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $Progress
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-lfs/git-lfs/releases/download/v2.12.0/git-lfs-windows-amd64-v2.12.0.zip -OutFile git-lfs.zip; `
Expand-Archive git-lfs.zip -DestinationPath C:\git\lfs;

FROM mcr.microsoft.com/powershell:nanoserver-1903
COPY --from=git /git /git
Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile.windows.1909
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $Progress
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-lfs/git-lfs/releases/download/v2.12.0/git-lfs-windows-amd64-v2.12.0.zip -OutFile git-lfs.zip; `
Expand-Archive git-lfs.zip -DestinationPath C:\git\lfs;

FROM mcr.microsoft.com/powershell:nanoserver-1909
COPY --from=git /git /git
Expand Down
25 changes: 25 additions & 0 deletions docker/Dockerfile.windows.ltsc2022
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# escape=`

FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS git
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
Expand-Archive git.zip -DestinationPath C:\git;
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest -UseBasicParsing https://github.com/git-lfs/git-lfs/releases/download/v2.12.0/git-lfs-windows-amd64-v2.12.0.zip -OutFile git-lfs.zip; `
Expand-Archive git-lfs.zip -DestinationPath C:\git\lfs;

FROM mcr.microsoft.com/powershell:windowsserver-ltsc2022
COPY --from=git /git /git

ADD windows/* /bin/

# https://github.com/PowerShell/PowerShell/issues/6211#issuecomment-367477137
USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell;c:\git\lfs\;c:\git\cmd"

SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]

LABEL org.opencontainers.image.source=https://github.com/johanvdw/drone-git/
11 changes: 3 additions & 8 deletions windows/clone-commit.ps1
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@

Set-Variable -Name "FLAGS" -Value ""
if ($Env:PLUGIN_DEPTH) {
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
}

if (!(Test-Path .git)) {
Write-Host 'git init';
git init
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
git remote add origin $Env:DRONE_REMOTE_URL
}

Write-Host "git fetch $FLAGS origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
Write-Host "git fetch origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
git fetch origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
Write-Host "git checkout $Env:DRONE_COMMIT_SHA -f $Env:DRONE_COMMIT_BRANCH";
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;
git lfs logs last
7 changes: 1 addition & 6 deletions windows/clone-tag.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@

Set-Variable -Name "FLAGS" -Value ""
if ($Env:PLUGIN_DEPTH) {
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
}

if (!(Test-Path .git)) {
git init
git remote add origin $Env:DRONE_REMOTE_URL
}

git fetch $FLAGS origin "+refs/tags/${Env:DRONE_TAG}:"
git fetch origin "+refs/tags/${Env:DRONE_TAG}:"
git checkout -qf FETCH_HEAD
11 changes: 9 additions & 2 deletions windows/clone.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
$ErrorActionPreference = 'Stop';

# HACK: no clue how to set the PATH inside the Dockerfile,
# so am setting it here instead. This is not idea.
$Env:PATH += ';C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin'
# so am setting it here instead. This is not ideal.
$Env:PATH += ';C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin;c:\git\lfs\git-lfs-2.12.0'

# if the workspace is set we should make sure
# it is the current working directory.
Expand All @@ -21,6 +21,13 @@ login $Env:DRONE_NETRC_USERNAME
password $Env:DRONE_NETRC_PASSWORD
"@ > (Join-Path $Env:USERPROFILE '_netrc');
}
if ($Env:DRONE_NETRC_MACHINE) {
@"
machine $Env:DRONE_NETRC_MACHINE
login $Env:DRONE_NETRC_USERNAME
password $Env:DRONE_NETRC_PASSWORD
"@ > (Join-Path $Env:USERPROFILE '.netrc');
}

# configure git global behavior and parameters via the
# following environment variables:
Expand Down