Skip to content

Commit

Permalink
Display pins in show/with commands (#940)
Browse files Browse the repository at this point in the history
* Display pins in show/with commands

* Tweaks to testsuite for new output
  • Loading branch information
mosteo authored Feb 15, 2022
1 parent 33edc47 commit 9cb832b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/alire/alire-releases.adb
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,12 @@ package body Alire.Releases is
Sorted => True,
And_Or => R.Dependencies.Contains_ORs);
end if;

-- PINS
if not R.Pins.Is_Empty then
Put_Line ("Pins (direct):");
R.Pins.Print (Prefix => " ");
end if;
end Print;

--------------
Expand Down
16 changes: 16 additions & 0 deletions src/alire/alire-user_pins-maps.adb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
with Ada.Text_IO;

package body Alire.User_Pins.Maps is

---------------
Expand Down Expand Up @@ -43,4 +45,18 @@ package body Alire.User_Pins.Maps is

end From_TOML;

-----------
-- Print --
-----------

procedure Print (This : Map; Prefix : String := "") is
use Ada.Text_IO;
begin
for I in This.Iterate loop
Put_Line (Prefix
& This (I)
.To_Manifest_Line (Crate => Pin_Maps.Key (I)));
end loop;
end Print;

end Alire.User_Pins.Maps;
3 changes: 3 additions & 0 deletions src/alire/alire-user_pins-maps.ads
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ package Alire.User_Pins.Maps is
or else raise Checked_Error
with Errors.Set ("array expected but got a " & This.Unwrap.Kind'Image);

procedure Print (This : Map; Prefix : String := "");
-- Print to stdout each Pin.To_Manifest_Line

end Alire.User_Pins.Maps;
5 changes: 5 additions & 0 deletions src/alr/alr-commands-withing.adb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ package body Alr.Commands.Withing is
And_Or => Root_Release.Dependencies.Contains_ORs,
Sorted => True);

if not Root_Release.Pins.Is_Empty then
Put_Line ("Pins (direct):");
Root_Release.Pins.Print (Prefix => " ");
end if;

if Cmd.Solve then
Cmd.Requires_Full_Index; -- Load possible hints
Cmd.Root.Solution.Print (Root_Release,
Expand Down
4 changes: 4 additions & 0 deletions testsuite/tests/pin/circularity/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
dep2*
dep3*
dep4*
Pins (direct):
dep2 = { path='../dep2' }
dep3 = { path='../dep3' }
dep4 = { path='../dep4' }
Dependencies (solution):
dep2=0.0.0 (pinned) (origin: ../dep2)
dep3=0.0.0 (pinned) (origin: ../dep3)
Expand Down
6 changes: 4 additions & 2 deletions testsuite/tests/pin/unneeded-held/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@

# Check that there are no dependencies
p = run_alr('with')
assert_eq('Dependencies (direct):\n'
' (empty)\n',
assert_eq("Dependencies (direct):\n"
" (empty)\n"
"Pins (direct):\n"
" libchild = { version='0.2.0' }\n",
p.out)

# But the pinned release is still in the solution
Expand Down
2 changes: 2 additions & 0 deletions testsuite/tests/pin/version/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
assert_eq("""\
Dependencies (direct):
hello*
Pins (direct):
hello = { version='7.7.7' }
Dependencies (external):
hello=7.7.7 (direct,missed,pin=7.7.7) (pinned)
Dependencies (graph):
Expand Down

0 comments on commit 9cb832b

Please sign in to comment.