From e766dced55b6c507efdec397d263b3689aeb2490 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Wed, 20 Sep 2023 12:30:21 +0000 Subject: [PATCH] Store `url` in SetupSource Otherwise the wizard needs to keep a separate 1-1 mapping of the urls, which is somewhat silly. --- src/Sources.jl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Sources.jl b/src/Sources.jl index ba1ea202..e39c545b 100644 --- a/src/Sources.jl +++ b/src/Sources.jl @@ -128,28 +128,29 @@ DirectorySource(path::String; target::String = "", follow_symlinks::Bool=false) DirectorySource(path, target, follow_symlinks) # Try to guess if a URL is a Git repository -isgitrepo(url::AbstractString) = endswith(url, ".git") || startswith(url, "git://") +isgitrepo(url::AbstractString) = endswith(url, ".git") || startswith(url, "git://") || startswith(url, "ssh://") # This is not meant to be used as source in the `build_tarballs.jl` scripts but # only to set up the source in the workspace. struct SetupSource{T<:AbstractSource} + url::Union{String, Nothing} path::String hash::String target::String follow_symlinks::Bool end # `follow_symlinks` is used only for DirectorySource, let's have a method without it. -SetupSource{T}(path::String, hash::String, target::String) where {T} = - SetupSource{T}(path, hash, target, false) +SetupSource{T}(url::Nothing, path::String, hash::String, target::String) where {T} = + SetupSource{T}(url, path, hash, target, false) # This is used in wizard/obtain_source.jl to automatically guess the parameter # of SetupSource from the URL function SetupSource(url::String, path::String, hash::String, target::String) if isgitrepo(url) - return SetupSource{GitSource}(path, hash, target) + return SetupSource{GitSource}(url, path, hash, target) elseif any(endswith(path, ext) for ext in archive_extensions) - return SetupSource{ArchiveSource}(path, hash, target) + return SetupSource{ArchiveSource}(url, path, hash, target) else - return SetupSource{FileSource}(path, hash, target) + return SetupSource{FileSource}(url, path, hash, target) end end @@ -173,7 +174,7 @@ function download_source(source::T; verbose::Bool = false, downloads_dir = stora src_path = joinpath(downloads_dir, string(source.hash, "-", basename(source.url))) download_verify(source.url, source.hash, src_path) end - return SetupSource{T}(src_path, source.hash, gettarget(source)) + return SetupSource{T}(source.url, src_path, source.hash, gettarget(source)) end struct GitTransferProgress @@ -245,7 +246,7 @@ end function download_source(source::GitSource; kwargs...) src_path = cached_git_clone(source.url; hash_to_check=source.hash, kwargs...) - return SetupSource{GitSource}(src_path, source.hash, source.unpack_target) + return SetupSource{GitSource}(source.url, src_path, source.hash, source.unpack_target) end function download_source(source::DirectorySource; verbose::Bool = false) @@ -255,7 +256,7 @@ function download_source(source::DirectorySource; verbose::Bool = false) if verbose @info "Directory \"$(source.path)\" found" end - return SetupSource{DirectorySource}(abspath(source.path), "", source.target, source.follow_symlinks) + return SetupSource{DirectorySource}(nothing, abspath(source.path), "", source.target, source.follow_symlinks) end """