diff --git a/stdlib/Pkg/docs/src/index.md b/stdlib/Pkg/docs/src/index.md index 34c8a570aae975..e905a126fc1958 100644 --- a/stdlib/Pkg/docs/src/index.md +++ b/stdlib/Pkg/docs/src/index.md @@ -347,13 +347,13 @@ If we try to `dev` a package at some branch that already exists at `~/.julia/dev For example: ``` -(v0.7) pkg> dev Example#master +(v0.7) pkg> dev Example Updating git-repo `https://github.com/JuliaLang/Example.jl.git` [ Info: Path `/Users/kristoffer/.julia/dev/Example` exists and looks like the correct package, using existing path instead of cloning ``` -Note the info message saying that it is using the existing path. This means that you cannot use `dev` to e.g. change branches of -an already developed package. +Note the info message saying that it is using the existing path. As a general rule, the package manager will +never touch files that are tracking a path. If `dev` is used on a local path, that path to that package is recorded and used when loading that package. The path will be recorded relative to the project file, unless it is given as an absolute path. diff --git a/stdlib/Pkg/src/API.jl b/stdlib/Pkg/src/API.jl index 76d067cce29c8a..a4cc2a363f682e 100644 --- a/stdlib/Pkg/src/API.jl +++ b/stdlib/Pkg/src/API.jl @@ -33,7 +33,12 @@ function add_or_develop(ctx::Context, pkgs::Vector{PackageSpec}; mode::Symbol, s # All developed packages should go through handle_repos_develop so just give them an empty repo for pkg in pkgs - mode == :develop && pkg.repo == nothing && (pkg.repo = Types.GitRepo()) + if mode == :develop + pkg.repo == nothing && (pkg.repo = Types.GitRepo()) + if !isempty(pkg.repo.rev) + pkgerror("git revision cannot be given to `develop`") + end + end end # if julia is passed as a package the solver gets tricked; diff --git a/stdlib/Pkg/src/REPLMode.jl b/stdlib/Pkg/src/REPLMode.jl index 6d18bca325a593..e3803371282b9c 100644 --- a/stdlib/Pkg/src/REPLMode.jl +++ b/stdlib/Pkg/src/REPLMode.jl @@ -397,6 +397,9 @@ function package_args(args::Vector{Token}, spec::CommandSpec)::Vector{PackageSpe elseif arg isa VersionRange pkgs[end].version = arg elseif arg isa Rev + if spec.kind == CMD_DEVELOP + pkgerror("a git revision cannot be given to `develop`") + end pkg = pkgs[end] if pkg.repo == nothing pkg.repo = Types.GitRepo("", arg.rev) @@ -1025,7 +1028,7 @@ pkg> add Example=7876af07-990d-54b4-ab0e-23690620f79a ("shared", OPT_SWITCH, :shared => true), ], md""" - develop [--shared|--local] pkg[=uuid] [#rev] ... + develop [--shared|--local] pkg[=uuid] ... Make a package available for development. If `pkg` is an existing local path that path will be recorded in the manifest and used. Otherwise, a full git clone of `pkg` at rev `rev` is made. The location of the clone is diff --git a/stdlib/Pkg/src/Types.jl b/stdlib/Pkg/src/Types.jl index 7bc60153f99f13..a09229597eb12d 100644 --- a/stdlib/Pkg/src/Types.jl +++ b/stdlib/Pkg/src/Types.jl @@ -545,13 +545,10 @@ function handle_repos_develop!(ctx::Context, pkgs::AbstractVector{PackageSpec}, project_path = mktempdir() cp(repo_path, project_path; force=true) LibGit2.with(LibGit2.GitRepo(project_path)) do repo - rev = pkg.repo.rev - if isempty(rev) - if LibGit2.isattached(repo) - rev = LibGit2.branch(repo) - else - rev = string(LibGit2.GitHash(LibGit2.head(repo))) - end + if LibGit2.isattached(repo) + rev = LibGit2.branch(repo) + else + rev = string(LibGit2.GitHash(LibGit2.head(repo))) end gitobject, isbranch = get_object_branch(repo, rev) try diff --git a/stdlib/Pkg/test/pkg.jl b/stdlib/Pkg/test/pkg.jl index 00f846619d5f99..32e1f8d18bb5cf 100644 --- a/stdlib/Pkg/test/pkg.jl +++ b/stdlib/Pkg/test/pkg.jl @@ -181,6 +181,7 @@ temp_pkg_dir() do project_path Pkg.rm(TEST_PKG.name) mktempdir() do devdir withenv("JULIA_PKG_DEVDIR" => devdir) do + @test_throws PkgError Pkg.develop(PackageSpec(url="bleh", rev="blurg")) Pkg.develop(TEST_PKG.name) @test isinstalled(TEST_PKG) @test Pkg.API.__installed()[TEST_PKG.name] > old_v diff --git a/stdlib/Pkg/test/repl.jl b/stdlib/Pkg/test/repl.jl index 3541ed8d00c651..7d1320bef268bf 100644 --- a/stdlib/Pkg/test/repl.jl +++ b/stdlib/Pkg/test/repl.jl @@ -42,16 +42,7 @@ temp_pkg_dir() do project_path Pkg.test("PackageWithBuildSpecificTestDeps") end - pkg"dev Example" - devdir = joinpath(DEPOT_PATH[1], "dev", "Example") - @test isdir(devdir) - rm(devdir; recursive=true) - @test !isdir(devdir) - pkg"dev Example#DO_NOT_REMOVE" - @test isdir(devdir) - LibGit2.with(LibGit2.GitRepo(devdir)) do repo - @test LibGit2.branch(repo) == "DO_NOT_REMOVE" - end + @test_throws PkgError pkg"dev Example#blergh" pkg"generate Foo" pkg"dev Foo" @@ -211,10 +202,6 @@ temp_pkg_dir() do project_path; cd(project_path) do @test Pkg.API.__installed()["UnregisteredWithoutProject"] == v"0.0.0" Pkg.test("UnregisteredWithoutProject") Pkg.test("UnregisteredWithProject") - - pkg"develop Example#c37b675" - @test Base.find_package("Example") == joinpath(tmp, "Example", "src", "Example.jl") - Pkg.test("Example") end finally empty!(DEPOT_PATH)