Skip to content
Merged
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
41 changes: 28 additions & 13 deletions src/REPLMode/argument_parsers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ let url = raw"((git|ssh|http(s)?)|(git@[\w\-\.]+))(:(//)?)([\w\.@\:/\-~]+)(\.git
name_uuid = raw"[^@\#\s:]+\s*=\s*[^@\#\s:]+",

# Match a `#BRANCH` branch or tag specifier.
branch = raw"\#\s*[^@\#\s]*",
branch = raw"\#\s*[^@^:\s]+",

# Match an `@VERSION` version specifier.
version = raw"@\s*[^@\#\s]*",
Expand Down Expand Up @@ -94,19 +94,34 @@ function parse_package_args(args::Vector{PackageToken}; add_or_dev=false)::Vecto
# check for and apply PackageSpec modifier (e.g. `#foo` or `@v1.0.2`)
function apply_modifier!(pkg::PackageSpec, args::Vector{PackageToken})
(isempty(args) || args[1] isa PackageIdentifier) && return
modifier = popfirst!(args)
if modifier isa Subdir
pkg.subdir = modifier.dir
(isempty(args) || args[1] isa PackageIdentifier) && return
parsed_subdir = false
parsed_version = false
parsed_rev = false
while !isempty(args)
modifier = popfirst!(args)
end

if modifier isa VersionToken
pkg.version = modifier.version
elseif modifier isa Rev
pkg.rev = modifier.rev
else
pkgerror("Package name/uuid must precede subdir specifier `$args`.")
if modifier isa Subdir
if parsed_subdir
pkgerror("Multiple subdir specifiers `$args` found.")
end
pkg.subdir = modifier.dir
(isempty(args) || args[1] isa PackageIdentifier) && return
modifier = popfirst!(args)
parsed_subdir = true
elseif modifier isa VersionToken
if parsed_version
pkgerror("Multiple version specifiers `$args` found.")
end
pkg.version = modifier.version
parsed_version = true
elseif modifier isa Rev
if parsed_rev
pkgerror("Multiple revision specifiers `$args` found.")
end
pkg.rev = modifier.rev
parsed_rev = true
else
pkgerror("Package name/uuid must precede subdir specifier `$args`.")
end
end
end

Expand Down
6 changes: 6 additions & 0 deletions test/new.jl
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,12 @@ end
arg = args[1]
@test arg.url == "https://github.com/JuliaLang/Pkg.jl"
@test arg.rev == "aa/gitlab"

api, args, opts = first(Pkg.pkg"add https://github.com/TimG1964/XLSX.jl#Bug-fixing-post-#289:subdir")
arg = args[1]
@test arg.url == "https://github.com/TimG1964/XLSX.jl"
@test arg.rev == "Bug-fixing-post-#289"
@test arg.subdir == "subdir"
end
end

Expand Down