-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure repo.url points to a git repo before adding (#451)
* Check that repo urls point to a git repo * Move `validate_repo_url` to `GitTools` module * Add Pkg-specific error messages to GitTools `clone` and `fetch` * Alter a test to be Windows-compatible (cherry picked from commit 046bde4d660715291f6a84eaba3cd08917dc7cee)
- Loading branch information
1 parent
3bd8ce0
commit a3fa396
Showing
2 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -371,6 +371,44 @@ temp_pkg_dir() do project_path | |
end # @testset | ||
end | ||
|
||
temp_pkg_dir() do project_path | ||
@testset "invalid repo url" begin | ||
cd(project_path) do | ||
@test_throws CommandError Pkg.add("https://github.com") | ||
Pkg.generate("FooBar") | ||
@test_throws CommandError Pkg.add("./Foobar") | ||
end | ||
end | ||
end | ||
|
||
temp_pkg_dir() do project_path | ||
function with_dummy_env(f) | ||
TEST_SIG = LibGit2.Signature("TEST", "[email protected]", round(time()), 0) | ||
env_path = joinpath(mktempdir(), "Dummy") | ||
Pkg.generate(env_path) | ||
repo = LibGit2.init(env_path) | ||
LibGit2.add!(repo, "*") | ||
LibGit2.commit(repo, "initial commit"; author=TEST_SIG, committer=TEST_SIG) | ||
Pkg.activate(env_path) | ||
try | ||
f() | ||
finally | ||
Pkg.activate() | ||
end | ||
end | ||
# pkg assumes `Example.jl` is still a git repo, it will try to fetch on `update` | ||
# `fetch` should warn that it is no longer a git repo | ||
with_dummy_env() do | ||
@testset "inconsistent repo state" begin | ||
package_path = joinpath(project_path, "Example") | ||
LibGit2.clone("https://github.com/JuliaLang/Example.jl", package_path) | ||
Pkg.add(package_path) | ||
rm(joinpath(package_path, ".git"); force=true, recursive=true) | ||
@test_throws CommandError Pkg.up() | ||
end | ||
end | ||
end | ||
|
||
include("repl.jl") | ||
|
||
end # module |