72 lines
2.2 KiB
Ada
72 lines
2.2 KiB
Ada
package body Alire.Index is
|
|
|
|
use all type Version;
|
|
|
|
------------
|
|
-- Exists --
|
|
------------
|
|
|
|
function Exists (Project : Project_Name;
|
|
Version : Semantic_Versioning.Version)
|
|
return Boolean is
|
|
begin
|
|
for R of Catalog loop
|
|
if R.Project = Project and then R.Version = Version then
|
|
return True;
|
|
end if;
|
|
end loop;
|
|
|
|
return False;
|
|
end Exists;
|
|
|
|
----------
|
|
-- Find --
|
|
----------
|
|
|
|
function Find (Project : Project_Name;
|
|
Version : Semantic_Versioning.Version) return Release is
|
|
begin
|
|
for R of Catalog loop
|
|
if R.Project = Project and then R.Version = Version then
|
|
return R;
|
|
end if;
|
|
end loop;
|
|
|
|
raise Constraint_Error with "Not in index: " & Project & "=" & Semantic_Versioning.Image (Version);
|
|
end Find;
|
|
|
|
--------------
|
|
-- Register --
|
|
--------------
|
|
|
|
function Register (-- Mandatory
|
|
Project : Project_Name;
|
|
Version : Semantic_Versioning.Version;
|
|
Description : Project_Description;
|
|
Origin : Origins.Origin;
|
|
-- Optional
|
|
Depends_On : Release_Dependencies := No_Dependencies;
|
|
Properties : Release_Properties := No_Properties;
|
|
Available_When : Alire.Requisites.Tree := No_Requisites)
|
|
return Release
|
|
is
|
|
begin
|
|
return Rel : constant Alire.Releases.Release :=
|
|
Alire.Releases.New_Release (Project,
|
|
Description,
|
|
Version,
|
|
Origin,
|
|
Depends_On,
|
|
Properties => Properties,
|
|
Available => Available_When)
|
|
do
|
|
if Catalog.Contains (Rel) then
|
|
Log ("Attempt to register duplicate versions: " & Rel.Milestone.Image, Warning);
|
|
else
|
|
Catalog.Insert (Rel);
|
|
end if;
|
|
end return;
|
|
end Register;
|
|
|
|
end Alire.Index;
|