Skip to content

Commit

Permalink
remove ability to give a git revision to devved packages (#581)
Browse files Browse the repository at this point in the history
* remove ability to give a git revision to devved packages

* wip
  • Loading branch information
KristofferC committed Aug 4, 2018
1 parent d738134 commit 43a0285
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 26 deletions.
6 changes: 3 additions & 3 deletions stdlib/Pkg/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 6 additions & 1 deletion stdlib/Pkg/src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion stdlib/Pkg/src/REPLMode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions stdlib/Pkg/src/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions stdlib/Pkg/test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 1 addition & 14 deletions stdlib/Pkg/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 43a0285

Please sign in to comment.