Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs around installing packages via git* #158

Closed
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
3 changes: 2 additions & 1 deletion lib/igniter/project/deps.ex
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ defmodule Igniter.Project.Deps do

"github:" <> requirement ->
if String.contains?(requirement, "@") do
case String.split(requirement, ["/", "@"], trim: true) do
# adding parts will allow for branch names with forward slashes
case String.split(requirement, ["/", "@"], trim: true, parts: 3) do
Comment on lines +315 to +316
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I'll make sure this is added and tested in the other PR.

[org, project, ref] ->
[github: "#{org}/#{project}", ref: ref, override: true]

Expand Down
6 changes: 4 additions & 2 deletions lib/mix/tasks/igniter.install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ defmodule Mix.Tasks.Igniter.Install do
* `package@version` - The package will be installed at the specified version.
If the version given is generic, like `3.0`, it will be pinned as described above.
if it is specific, like `3.0.1`, it will be pinned at that *exact* version with `==`.
* `package@git:git_url` - The package will be installed from the specified git url.
* `package@github:project/repo` - The package will be installed from the specified github repo.
* `package@git:https://project/repo.git@git_ref` - The package will be installed from the
specified git url and `ref` option will be set to `git_ref`. `ref` can be a branch, tag or commit SHA.
* `package@github:project/repo@git_ref` - The package will be installed from the specified
github repo and `ref` option will be set to `git_ref`. `ref` can be a branch, tag or commit SHA.
* `package@path:path/to/dep` - The package will be installed from the specified path.

## Switches
Expand Down
35 changes: 35 additions & 0 deletions test/igniter/project/deps_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,39 @@ defmodule Igniter.Project.DepsTest do
""")
end
end

describe "determine_dep_type_and_version" do
test "package" do
{package, version_info} = Igniter.Project.Deps.determine_dep_type_and_version("ash")
assert package == :ash
assert String.contains?(version_info, "~>") == true
end

test "package@version" do
assert Igniter.Project.Deps.determine_dep_type_and_version("ash@2") == {:ash, "~> 2.0"}
end

test "package@git" do
assert Igniter.Project.Deps.determine_dep_type_and_version(
"package@git:https://project/repo.git@git_ref"
) == {:package, [git: "https://project/repo.git", ref: "git_ref", override: true]}
end

test "package@github" do
assert Igniter.Project.Deps.determine_dep_type_and_version(
"package@github:project/repo@git_ref"
) == {:package, [github: "project/repo", ref: "git_ref", override: true]}

assert Igniter.Project.Deps.determine_dep_type_and_version(
"package@github:project/repo@git/ref/with/slashes/work"
) ==
{:package,
[github: "project/repo", ref: "git/ref/with/slashes/work", override: true]}
end

test "package@path" do
assert Igniter.Project.Deps.determine_dep_type_and_version("package@path:path/to/dep") ==
{:package, [path: "path/to/dep", override: true]}
end
end
end