Skip to content

Commit 5dbdef4

Browse files
authored
[Wizard] Use BinaryBuilderBase.cached_git_clone to clone git repo (#1203)
1 parent d3a87f4 commit 5dbdef4

File tree

3 files changed

+13
-65
lines changed

3 files changed

+13
-65
lines changed

Manifest.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ version = "0.2.0"
3030
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
3131

3232
[[deps.BinaryBuilderBase]]
33-
deps = ["CodecZlib", "Downloads", "InteractiveUtils", "JSON", "LibGit2", "LibGit2_jll", "Libdl", "Logging", "OrderedCollections", "OutputCollectors", "Pkg", "Random", "SHA", "Scratch", "SimpleBufferStream", "TOML", "Tar", "UUIDs", "p7zip_jll", "pigz_jll"]
34-
git-tree-sha1 = "7076ed525d498038d44118ac3fa95b765d26a9d6"
33+
deps = ["CodecZlib", "Downloads", "InteractiveUtils", "JSON", "LibGit2", "LibGit2_jll", "Libdl", "Logging", "OrderedCollections", "OutputCollectors", "Pkg", "ProgressMeter", "Random", "SHA", "Scratch", "SimpleBufferStream", "TOML", "Tar", "UUIDs", "p7zip_jll", "pigz_jll"]
34+
git-tree-sha1 = "515d28b82ab1a721b31ddb6a11f8fa5662fc9e91"
3535
repo-rev = "master"
3636
repo-url = "https://github.com/JuliaPackaging/BinaryBuilderBase.jl.git"
3737
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
38-
version = "1.8.0"
38+
version = "1.10.1"
3939

4040
[[deps.CodecZlib]]
4141
deps = ["TranscodingStreams", "Zlib_jll"]
@@ -45,9 +45,9 @@ version = "0.7.0"
4545

4646
[[deps.Compat]]
4747
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
48-
git-tree-sha1 = "96b0bc6c52df76506efc8a441c6cf1adcb1babc4"
48+
git-tree-sha1 = "b153278a25dd42c65abbf4e62344f9d22e59191b"
4949
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
50-
version = "3.42.0"
50+
version = "3.43.0"
5151

5252
[[deps.CompilerSupportLibraries_jll]]
5353
deps = ["Artifacts", "Libdl"]
@@ -260,9 +260,9 @@ version = "0.1.1"
260260

261261
[[deps.Parsers]]
262262
deps = ["Dates"]
263-
git-tree-sha1 = "85b5da0fa43588c75bb1ff986493443f821c70b7"
263+
git-tree-sha1 = "621f4f3b4977325b9128d5fae7a8b4829a0c2222"
264264
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
265-
version = "2.2.3"
265+
version = "2.2.4"
266266

267267
[[deps.Pidfile]]
268268
deps = ["FileWatching", "Test"]
@@ -292,9 +292,9 @@ uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
292292

293293
[[deps.ProgressMeter]]
294294
deps = ["Distributed", "Printf"]
295-
git-tree-sha1 = "afadeba63d90ff223a6a48d2009434ecee2ec9e8"
295+
git-tree-sha1 = "d7a7aef8f8f2d537104f170139553b14dfe39fe9"
296296
uuid = "92933f4c-e287-5a05-a399-4b506db050ca"
297-
version = "1.7.1"
297+
version = "1.7.2"
298298

299299
[[deps.REPL]]
300300
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]

Project.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ ObjectFile = "d8793406-e978-5875-9003-1fc021f44a92"
2020
OutputCollectors = "6c11c7d4-943b-4e2b-80de-f2cfc2930a8c"
2121
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
2222
PkgLicenses = "fc669557-7ec9-5e45-bca9-462afbc28879"
23-
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
2423
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
2524
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2625
Registrator = "4418983a-e44d-11e8-3aec-9789530b3b3e"
@@ -34,7 +33,7 @@ ghr_jll = "07c12ed4-43bc-5495-8a2a-d5838ef8d533"
3433

3534
[compat]
3635
ArgParse = "1.1"
37-
BinaryBuilderBase = "1.4"
36+
BinaryBuilderBase = "1.10"
3837
GitHub = "5.1"
3938
HTTP = "0.8, 0.9"
4039
JLD2 = "0.1.6, 0.2, 0.3, 0.4"
@@ -44,7 +43,6 @@ LoggingExtras = "0.4"
4443
ObjectFile = "0.3.6"
4544
OutputCollectors = "0.1"
4645
PkgLicenses = "0.2"
47-
ProgressMeter = "1"
4846
Registrator = "1.1"
4947
RegistryTools = "1.3.4"
5048
Scratch = "1.0"

src/wizard/obtain_source.jl

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
using BinaryBuilderBase: available_gcc_builds, available_llvm_builds, enable_apple_file, macos_sdk_already_installed, accept_apple_sdk
2-
using ProgressMeter
1+
using BinaryBuilderBase: available_gcc_builds, available_llvm_builds, enable_apple_file, macos_sdk_already_installed, accept_apple_sdk, cached_git_clone
32
import Downloads
4-
const update! = ProgressMeter.update!
53

64
"""
75
Canonicalize a GitHub repository URL
@@ -36,53 +34,6 @@ function canonicalize_file_url(url)
3634
url
3735
end
3836

39-
struct GitTransferProgress
40-
total_objects::Cuint
41-
indexed_objects::Cuint
42-
received_objects::Cuint
43-
local_objects::Cuint
44-
total_deltas::Cuint
45-
indexed_deltas::Cuint
46-
received_bytes::Csize_t
47-
end
48-
49-
function transfer_progress(progress::Ptr{GitTransferProgress}, p::Any)
50-
progress = unsafe_load(progress)
51-
p.n = progress.total_objects
52-
if progress.total_deltas != 0
53-
p.desc = "Resolving Deltas: "
54-
p.n = progress.total_deltas
55-
update!(p, Int(max(1, progress.indexed_deltas)))
56-
else
57-
update!(p, Int(max(1, progress.received_objects)))
58-
end
59-
return Cint(0)
60-
end
61-
62-
"""
63-
clone(url::String, source_path::String)
64-
65-
Clone a git repository hosted at `url` into `source_path`, with a progress bar
66-
displayed to stdout.
67-
"""
68-
function clone(url::String, source_path::String)
69-
# Clone with a progress bar
70-
p = Progress(0, 1, "Cloning: ")
71-
GC.@preserve p begin
72-
callbacks = LibGit2.RemoteCallbacks(
73-
transfer_progress=@cfunction(
74-
transfer_progress,
75-
Cint,
76-
(Ptr{GitTransferProgress}, Any)
77-
),
78-
payload = p
79-
)
80-
fetch_opts = LibGit2.FetchOptions(callbacks=callbacks)
81-
clone_opts = LibGit2.CloneOptions(fetch_opts=fetch_opts, bare = Cint(true))
82-
return LibGit2.clone(url, source_path, clone_opts)
83-
end
84-
end
85-
8637
"""
8738
download_source(state::WizardState)
8839
@@ -130,13 +81,12 @@ function download_source(state::WizardState)
13081
println(state.outs)
13182
end
13283

133-
# Record the source path and the source hash
134-
source_path = joinpath(state.workspace, basename(url))
13584
local source_hash
13685

13786
if endswith(url, ".git") || startswith(url, "git://")
87+
source_path = cached_git_clone(url; progressbar=true, verbose=true)
13888
# Clone the URL, record the current gitsha for the given branch
139-
repo = clone(url, source_path)
89+
repo = GitRepo(source_path)
14090

14191
msg = "You have selected a git repository. Please enter a branch, commit or tag to use.\n" *
14292
"Please note that for reproducibility, the exact commit will be recorded, \n" *

0 commit comments

Comments
 (0)