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

Remove too strict check for root manifest reload #1168

Merged
merged 2 commits into from
Sep 14, 2022
Merged
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
8 changes: 8 additions & 0 deletions src/alire/alire-roots-editable.adb
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ package body Alire.Roots.Editable is
is (Directories.Find_Relative_Path_To (Path) = "..");

begin
-- When adding a pin from a folder other than the root, notify about it.
-- It's likely that the user is confused about what is going on.
if Directories.Current /= +This.Orig.Path then
Put_Warning ("Adding pin to " & TTY.URL (Path)
& " in crate " & Utils.TTY.Name (This.Orig.Name)
& " rooted at " & TTY.URL (+This.Orig.Path));
end if;

if Crate.Is_Empty and then not Pin_Root.Is_Valid then
Raise_Checked_Error
("No crate name given and link target is not an Alire crate:"
Expand Down
4 changes: 1 addition & 3 deletions src/alire/alire-roots.ads
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
private with AAA.Caches.Files;
with Ada.Directories;
private with Ada.Finalization;

with AAA.Strings;
Expand Down Expand Up @@ -200,8 +199,7 @@ package Alire.Roots is
procedure Write_Manifest (This : Root);
-- Generates the crate.toml manifest at the appropriate location for Root

procedure Reload_Manifest (This : in out Root)
with Pre => This.Path = Ada.Directories.Current_Directory;
procedure Reload_Manifest (This : in out Root);
-- If changes have been done to the manifest, either via the dependency/pin
-- modification procedures, or somehow outside alire after This was
-- created, we need to reload the manifest. The solution remains
Expand Down
32 changes: 32 additions & 0 deletions testsuite/tests/pin/from-subdir/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""
Verify that requesting a pin from a dir which is not the root still works, but
the user gets a warning about it.
"""

import os, re

from drivers.alr import run_alr, init_local_crate
from drivers.asserts import assert_eq, assert_match
from drivers.helpers import dir_separator

# Create top crate
init_local_crate()

# Create nested crate
init_local_crate("child")

# Enter a subdir of the nested crate
os.mkdir("sub")
os.chdir("sub")

s = re.escape(dir_separator())

# Add the pin for the parent crate from the subdir of the child
p = run_alr("with", "xxx", f"--use=..{s}..", quiet=False)

# Check the warning
assert_match(f".*Adding pin to .*pin__from-subdir{s}xxx in crate child rooted"
f" at .*{s}pin__from-subdir{s}xxx{s}child",
p.out)

print('SUCCESS')
1 change: 1 addition & 0 deletions testsuite/tests/pin/from-subdir/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
driver: python-script