Skip to content

Commit 317931e

Browse files
committed
Support git-lfs (large file storage)
1 parent f588510 commit 317931e

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
name = "Git"
22
uuid = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
3-
version = "1.4.0"
43
authors = ["Dilum Aluthge", "contributors"]
4+
version = "1.5.0"
55

66
[deps]
7+
Git_LFS_jll = "020c3dae-16b3-5ae5-87b3-4cb189e250b2"
78
Git_jll = "f8c6e375-362e-5223-8a59-34ff63f689eb"
89
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
910
OpenSSH_jll = "9bd350c2-7e96-507f-8002-3f2e150b4e1b"
1011

1112
[compat]
13+
Git_LFS_jll = "3.7"
1214
Git_jll = "2.44"
1315
JLLWrappers = "1.1"
1416
OpenSSH_jll = "9, 10"

src/git_function.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using OpenSSH_jll: OpenSSH_jll
2+
using Git_LFS_jll: Git_LFS_jll
23
using JLLWrappers: pathsep, LIBPATH_env
34

45
"""
@@ -52,8 +53,8 @@ function git(; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true)
5253
end
5354

5455
# Use OpenSSH from the JLL: <https://github.com/JuliaVersionControl/Git.jl/issues/51>.
56+
path = split(get(ENV, "PATH", ""), pathsep)
5557
if !Sys.iswindows() && OpenSSH_jll.is_available()
56-
path = split(get(ENV, "PATH", ""), pathsep)
5758
libpath = split(get(ENV, LIBPATH_env, ""), pathsep)
5859

5960
path = vcat(dirname(OpenSSH_jll.ssh_path), path)
@@ -67,6 +68,11 @@ function git(; adjust_PATH::Bool = true, adjust_LIBPATH::Bool = true)
6768
git_cmd = addenv(git_cmd, "PATH" => join(path, pathsep), LIBPATH_env => join(libpath, pathsep))
6869
end
6970

71+
# Add git-lfs
72+
if Git_LFS_jll.is_available()
73+
path = vcat(dirname(Git_LFS_jll.git_lfs_path), path)
74+
git_cmd = addenv(git_cmd, "PATH" => join(path, pathsep))
75+
end
7076
return git_cmd
7177
end
7278

test/runtests.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ end
3434
@test isdir("Git.jl")
3535
@test isfile(joinpath("Git.jl", "Project.toml"))
3636
end
37+
38+
# git-lfs tests
39+
withtempdir() do tmp_dir
40+
rname = "repo-with-large-file-storage"
41+
@test !isdir(rname)
42+
@test !isfile(joinpath(rname, "LargeFile.zip"))
43+
run(`$(git()) clone https://github.com/Apress/repo-with-large-file-storage`)
44+
run(`$(git()) -C $rname lfs install --local`)
45+
run(`$(git()) -C $rname lfs pull`)
46+
@test isdir(rname)
47+
@test isfile(joinpath(rname, "LargeFile.zip"))
48+
# Test filesize to make sure we got real file and not small LFS pointer file
49+
@test filesize(joinpath(rname, "LargeFile.zip")) > 10^6
50+
end
3751
end
3852

3953
@testset "Safety" begin

0 commit comments

Comments
 (0)