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

Refactor Alire.Features.Index to Alire.Index_On_Disk.Loading #992

Merged
merged 1 commit into from
Apr 15, 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
9 changes: 0 additions & 9 deletions src/alire/alire-features.ads

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ with Ada.Directories;

with Alire.Config.Edit;
with Alire.Index;
with Alire.OS_Lib;
with Alire.Warnings;

with GNAT.OS_Lib;

with TOML;
with TOML.File_IO;

package body Alire.Features.Index is
package body Alire.Index_On_Disk.Loading is

-- Forward declarations

Expand Down Expand Up @@ -198,14 +197,14 @@ package body Alire.Features.Index is
Force : Boolean := False)
is
Result : Outcome;
Indexes : Features.Index.Index_On_Disk_Set;
Indexes : Index_On_Disk_Set;
begin
if Alire.Index.Crate_Count /= 0 and then not Force then
Trace.Detail ("Index already loaded, loading skipped");
return;
end if;

Indexes := Features.Index.Find_All (From, Result);
Indexes := Find_All (From, Result);
if not Result.Success then
Raise_Checked_Error (Message (Result));
return;
Expand All @@ -215,8 +214,7 @@ package body Alire.Features.Index is
Trace.Detail
("No indexes configured, adding default community index");
declare
Outcome : constant Alire.Outcome :=
Features.Index.Add_Or_Reset_Community;
Outcome : constant Alire.Outcome := Add_Or_Reset_Community;
begin
if not Outcome.Success then
Raise_Checked_Error
Expand All @@ -227,7 +225,7 @@ package body Alire.Features.Index is
end if;

declare
Outcome : constant Alire.Outcome := Features.Index.Load_All
Outcome : constant Alire.Outcome := Load_All
(From => Alire.Config.Edit.Indexes_Directory,
Strict => Strict);
begin
Expand All @@ -254,7 +252,6 @@ package body Alire.Features.Index is
---------------

procedure Check_One (Dir : Dirs.Directory_Entry_Type) is
use OS_Lib.Operators;
Metafile : constant String :=
Dirs.Full_Name (Dir) / Index_On_Disk.Metadata_Filename;
Metadata : TOML.TOML_Value;
Expand Down Expand Up @@ -388,4 +385,4 @@ package body Alire.Features.Index is
return Outcome_Success;
end Update_All;

end Alire.Features.Index;
end Alire.Index_On_Disk.Loading;
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
with Ada.Containers.Indefinite_Ordered_Sets;

with Alire.Index_On_Disk;

package Alire.Features.Index is
package Alire.Index_On_Disk.Loading is

-------------------
-- Index loading --
Expand Down Expand Up @@ -52,4 +50,4 @@ package Alire.Features.Index is
-- re-adds it at the required branch by Index.Community_Branch with the
-- same priority (i.e., maintaining the relative ordering);

end Alire.Features.Index;
end Alire.Index_On_Disk.Loading;
7 changes: 4 additions & 3 deletions src/alire/alire-publish.adb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ with Alire.Config.Edit;
with Alire.Crates;
with Alire.Directories;
with Alire.Errors;
with Alire.Features.Index;
with Alire.Index_On_Disk.Loading;
with Alire.GitHub;
with Alire.Hashes;
with Alire.Index;
Expand Down Expand Up @@ -183,8 +183,9 @@ package body Alire.Publish is

-- Check not duplicated

Features.Index.Setup_And_Load (From => Config.Edit.Indexes_Directory,
Strict => True);
Index_On_Disk.Loading.Setup_And_Load
(From => Config.Edit.Indexes_Directory,
Strict => True);
if Index.Exists (Release.Name, Release.Version) then
Raise_Checked_Error
("Target release " & Release.Milestone.TTY_Image
Expand Down
20 changes: 10 additions & 10 deletions src/alr/alr-commands-index.adb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
with AAA.Table_IO;

with Alire.Config.Edit;
with Alire.Features.Index;
with Alire.Index_On_Disk;
with Alire.Index_On_Disk.Loading;
with Alire.Utils;

package body Alr.Commands.Index is

package Index_Load renames Alire.Index_On_Disk.Loading;

-- Forward declarations

procedure Add (Cmd : Command);
Expand All @@ -25,7 +26,7 @@ package body Alr.Commands.Index is
Before : constant String := Cmd.Bfr.all;

Result : constant Alire.Outcome :=
Alire.Features.Index.Add
Alire.Index_On_Disk.Loading.Add
(Origin => Cmd.Add.all,
Name => Cmd.Name.all,
Under => Alire.Config.Edit.Indexes_Directory,
Expand All @@ -44,8 +45,8 @@ package body Alr.Commands.Index is

procedure Delete (Name : String) is
Result : Alire.Outcome;
Indexes : constant Alire.Features.Index.Index_On_Disk_Set :=
Alire.Features.Index.Find_All
Indexes : constant Index_Load.Index_On_Disk_Set :=
Index_Load.Find_All
(Alire.Config.Edit.Indexes_Directory, Result);
Found : Boolean := False;
begin
Expand Down Expand Up @@ -147,8 +148,8 @@ package body Alr.Commands.Index is
use Alire;

Result : Alire.Outcome;
Indexes : constant Alire.Features.Index.Index_On_Disk_Set :=
Alire.Features.Index.Find_All
Indexes : constant Index_Load.Index_On_Disk_Set :=
Index_Load.Find_All
(Alire.Config.Edit.Indexes_Directory, Result);

Table : AAA.Table_IO.Table;
Expand Down Expand Up @@ -212,8 +213,7 @@ package body Alr.Commands.Index is
---------------------

procedure Reset_Community is
Result : constant Alire.Outcome :=
Alire.Features.Index.Add_Or_Reset_Community;
Result : constant Alire.Outcome := Index_Load.Add_Or_Reset_Community;
begin
if not Result.Success then
Reportaise_Command_Failed (Result.Message);
Expand Down Expand Up @@ -291,7 +291,7 @@ package body Alr.Commands.Index is

procedure Update_All is
Result : constant Alire.Outcome :=
Alire.Features.Index.Update_All
Index_Load.Update_All
(Alire.Config.Edit.Indexes_Directory);
begin
if not Result.Success then
Expand Down
6 changes: 3 additions & 3 deletions src/alr/alr-commands-version.adb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
with Alire.Config.Edit;
with Alire.Features.Index;
with Alire.Index;
with Alire.Index_On_Disk.Loading;
with Alire.Milestones;
with Alire.Properties;
with Alire.Roots.Optional;
Expand Down Expand Up @@ -30,8 +30,8 @@ package body Alr.Commands.Version is
use all type Alire.Roots.Optional.States;
Table : Alire.Utils.Tables.Table;
Index_Outcome : Alire.Outcome;
Indexes : constant Alire.Features.Index.Index_On_Disk_Set :=
Alire.Features.Index.Find_All
Indexes : constant Alire.Index_On_Disk.Loading.Index_On_Disk_Set :=
Alire.Index_On_Disk.Loading.Find_All
(Alire.Config.Edit.Indexes_Directory, Index_Outcome);
Root : constant Alire.Roots.Optional.Root :=
Alire.Roots.Optional.Search_Root (Alire.Directories.Current);
Expand Down
4 changes: 2 additions & 2 deletions src/alr/alr-commands.adb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ with Alire.Platforms;
with Alire_Early_Elaboration;
with Alire.Config.Edit;
with Alire.Errors;
with Alire.Features.Index;
with Alire.Index_On_Disk.Loading;
with Alire.Lockfiles;
with Alire.Paths;
with Alire.Platforms.Current;
Expand Down Expand Up @@ -245,7 +245,7 @@ package body Alr.Commands is
Force_Reload : Boolean := False) is
pragma Unreferenced (Cmd);
begin
Alire.Features.Index.Setup_And_Load
Alire.Index_On_Disk.Loading.Setup_And_Load
(From => Alire.Config.Edit.Indexes_Directory,
Strict => Strict,
Force => Force_Reload);
Expand Down