Skip to content

Commit 1ee6c22

Browse files
Support --base and --head options in workspace.list task (#10)
1 parent cf2ff07 commit 1ee6c22

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

workspace/lib/mix/tasks/workspace.list.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ defmodule Mix.Tasks.Workspace.List do
4949
:excluded_tags,
5050
:dependency,
5151
:dependent,
52-
:show_status
52+
:show_status,
53+
:base,
54+
:head
5355
],
5456
opts
5557
)

workspace/test/mix/tasks/workspace.list_test.exs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,4 +377,45 @@ defmodule Mix.Tasks.Workspace.ListTest do
377377
end
378378
)
379379
end
380+
381+
@tag :tmp_dir
382+
test "prints the workspace projects when base and head are set", %{tmp_dir: tmp_dir} do
383+
Workspace.Test.with_workspace(
384+
tmp_dir,
385+
[],
386+
:default,
387+
fn ->
388+
Workspace.Test.modify_project(tmp_dir, "package_c")
389+
Workspace.Test.commit_changes(tmp_dir)
390+
391+
expected = """
392+
Found 11 workspace projects matching the given options.
393+
* :package_a ● package_a/mix.exs :shared, area:core
394+
* :package_b ✔ package_b/mix.exs - a dummy project
395+
* :package_c ✚ package_c/mix.exs
396+
* :package_d ✔ package_d/mix.exs
397+
* :package_e ✔ package_e/mix.exs
398+
* :package_f ✔ package_f/mix.exs
399+
* :package_g ✔ package_g/mix.exs
400+
* :package_h ✔ package_h/mix.exs
401+
* :package_i ✔ package_i/mix.exs
402+
* :package_j ✔ package_j/mix.exs
403+
* :package_k ✔ nested/package_k/mix.exs
404+
"""
405+
406+
assert capture_io(fn ->
407+
ListTask.run([
408+
"--workspace-path",
409+
tmp_dir,
410+
"--show-status",
411+
"--base",
412+
"HEAD~1",
413+
"--head",
414+
"HEAD"
415+
])
416+
end) == expected
417+
end,
418+
git: true
419+
)
420+
end
380421
end

0 commit comments

Comments
 (0)