diff --git a/src/alire/alire-index.ads b/src/alire/alire-index.ads index 2e581d033..485dc5501 100644 --- a/src/alire/alire-index.ads +++ b/src/alire/alire-index.ads @@ -49,21 +49,14 @@ package Alire.Index is -- The branch used for the community index. Must be updated when new index -- features are introduced. - Min_Compatible_Version : constant String := "1.1"; - -- Update as needed in case of backward-incompatible changes - - Max_Compatible_Version : constant String := - AAA.Strings.Tail (Community_Branch, '-'); + Min_Compatible_Version : constant Semantic_Versioning.Version; + -- Based on the constant defined in private section -- We store here the indexes we are able to load. As long as we do not -- break back compatibility, we can keep on simply updating the minor value - Valid_Versions : constant Semantic_Versioning.Extended.Version_Set := - Semantic_Versioning.Extended.Value - ("^" & Min_Compatible_Version - & " & <=" & Max_Compatible_Version); + Valid_Versions : constant Semantic_Versioning.Extended.Version_Set; - Version : constant Semantic_Versioning.Version := - Semantic_Versioning.New_Version (Max_Compatible_Version); + Version : constant Semantic_Versioning.Version; -- The index version understood by alire must match the one in the indexes -- being loaded. @@ -173,4 +166,28 @@ package Alire.Index is -- applied during load: -- * Whether some origin is not in our allowed hosting sites. +private + + -- The string constants for versions are kept in the private section to + -- avoid using them in command output or other message. The only option + -- is to use the Sementic_Versioning.Image function which will provide a + -- consistant output. + + Min_Compatible_Version_Str : constant String := "1.1"; + -- Update as needed in case of backward-incompatible changes + + Max_Compatible_Version_Str : constant String := + AAA.Strings.Tail (Community_Branch, '-'); + + Min_Compatible_Version : constant Semantic_Versioning.Version := + Semantic_Versioning.New_Version (Min_Compatible_Version_Str); + + Valid_Versions : constant Semantic_Versioning.Extended.Version_Set := + Semantic_Versioning.Extended.Value + ("^" & Min_Compatible_Version_Str + & " & <=" & Max_Compatible_Version_Str); + + Version : constant Semantic_Versioning.Version := + Semantic_Versioning.New_Version (Max_Compatible_Version_Str); + end Alire.Index; diff --git a/src/alire/alire-toml_index.adb b/src/alire/alire-toml_index.adb index 07c3aac60..b60e714b0 100644 --- a/src/alire/alire-toml_index.adb +++ b/src/alire/alire-toml_index.adb @@ -203,14 +203,13 @@ package body Alire.TOML_Index is & ") is newer than that expected by alr (" & Alire.Index.Version.Image & ")." & " You may have to update alr"); - elsif Loading_Index_Version < Semver.Parse - (Alire.Index.Min_Compatible_Version) + elsif Loading_Index_Version < Alire.Index.Min_Compatible_Version then Set_Error (Result, Filename, "index version (" & Loading_Index_Version.Image & ") is too old. The minimum compatible version is " - & Alire.Index.Min_Compatible_Version & ASCII.LF + & Alire.Index.Min_Compatible_Version.Image & ASCII.LF & (if Index.Name = Alire.Index.Community_Name then " Resetting the community index (" & TTY.Terminal ("alr index --reset-community")