Skip to content

Commit e766dce

Browse files
committed
Store url in SetupSource
Otherwise the wizard needs to keep a separate 1-1 mapping of the urls, which is somewhat silly.
1 parent 18e421f commit e766dce

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/Sources.jl

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,29 @@ DirectorySource(path::String; target::String = "", follow_symlinks::Bool=false)
128128
DirectorySource(path, target, follow_symlinks)
129129

130130
# Try to guess if a URL is a Git repository
131-
isgitrepo(url::AbstractString) = endswith(url, ".git") || startswith(url, "git://")
131+
isgitrepo(url::AbstractString) = endswith(url, ".git") || startswith(url, "git://") || startswith(url, "ssh://")
132132

133133
# This is not meant to be used as source in the `build_tarballs.jl` scripts but
134134
# only to set up the source in the workspace.
135135
struct SetupSource{T<:AbstractSource}
136+
url::Union{String, Nothing}
136137
path::String
137138
hash::String
138139
target::String
139140
follow_symlinks::Bool
140141
end
141142
# `follow_symlinks` is used only for DirectorySource, let's have a method without it.
142-
SetupSource{T}(path::String, hash::String, target::String) where {T} =
143-
SetupSource{T}(path, hash, target, false)
143+
SetupSource{T}(url::Nothing, path::String, hash::String, target::String) where {T} =
144+
SetupSource{T}(url, path, hash, target, false)
144145
# This is used in wizard/obtain_source.jl to automatically guess the parameter
145146
# of SetupSource from the URL
146147
function SetupSource(url::String, path::String, hash::String, target::String)
147148
if isgitrepo(url)
148-
return SetupSource{GitSource}(path, hash, target)
149+
return SetupSource{GitSource}(url, path, hash, target)
149150
elseif any(endswith(path, ext) for ext in archive_extensions)
150-
return SetupSource{ArchiveSource}(path, hash, target)
151+
return SetupSource{ArchiveSource}(url, path, hash, target)
151152
else
152-
return SetupSource{FileSource}(path, hash, target)
153+
return SetupSource{FileSource}(url, path, hash, target)
153154
end
154155
end
155156

@@ -173,7 +174,7 @@ function download_source(source::T; verbose::Bool = false, downloads_dir = stora
173174
src_path = joinpath(downloads_dir, string(source.hash, "-", basename(source.url)))
174175
download_verify(source.url, source.hash, src_path)
175176
end
176-
return SetupSource{T}(src_path, source.hash, gettarget(source))
177+
return SetupSource{T}(source.url, src_path, source.hash, gettarget(source))
177178
end
178179

179180
struct GitTransferProgress
@@ -245,7 +246,7 @@ end
245246

246247
function download_source(source::GitSource; kwargs...)
247248
src_path = cached_git_clone(source.url; hash_to_check=source.hash, kwargs...)
248-
return SetupSource{GitSource}(src_path, source.hash, source.unpack_target)
249+
return SetupSource{GitSource}(source.url, src_path, source.hash, source.unpack_target)
249250
end
250251

251252
function download_source(source::DirectorySource; verbose::Bool = false)
@@ -255,7 +256,7 @@ function download_source(source::DirectorySource; verbose::Bool = false)
255256
if verbose
256257
@info "Directory \"$(source.path)\" found"
257258
end
258-
return SetupSource{DirectorySource}(abspath(source.path), "", source.target, source.follow_symlinks)
259+
return SetupSource{DirectorySource}(nothing, abspath(source.path), "", source.target, source.follow_symlinks)
259260
end
260261

261262
"""

0 commit comments

Comments
 (0)