Skip to content

Commit

Permalink
Enforce usage of Sementic_Versioning when printing Alire/Alr version
Browse files Browse the repository at this point in the history
To ensure a consistent formatting whatever the version.
The version string is now private, only the semver type is visible.
  • Loading branch information
Fabien-Chouteau committed Mar 14, 2024
1 parent e6e1021 commit 9519d65
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/alire/alire-github.adb
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ package body Alire.GitHub is
Args => "state" = "closed");
begin
Comment (Number,
"Closed using `alr " & Version.Current & "` with reason: "
"Closed using `alr " & Version.Current.Image & "` with reason: "
& Reason);
end Close;

Expand Down Expand Up @@ -423,7 +423,7 @@ package body Alire.GitHub is

Mutation : constant String
:= "mutation { markPullRequestReadyForReview (input: { "
& "clientMutationId: ""alr-" & Version.Current & """, "
& "clientMutationId: ""alr-" & Version.Current.Image & """, "
& "pullRequestId: ""PRID"" }) {clientMutationId}}";

Response : constant Minirest.Response
Expand Down
2 changes: 1 addition & 1 deletion src/alire/alire-publish-submit.adb
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ package body Alire.Publish.Submit is
Title => Context.PR_Name,
Message =>
"Created via `alr publish` with `alr "
& Version.Current & "`");
& Version.Current.Image & "`");
begin
Put_Success ("Pull request created successfully");
Put_Info ("Visit " & TTY.URL (States.Webpage (Number))
Expand Down
4 changes: 2 additions & 2 deletions src/alire/alire-settings-edit.adb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ with Alire.Platforms.Folders;
with Alire.Platforms.Current;
with Alire.Settings.Builtins;
with Alire.Utils.Text_Files;
with Alire.Version.Semver;
with Alire.Version;
with Alire.Warnings;

with CLIC.Config.Edit;
Expand Down Expand Up @@ -224,7 +224,7 @@ package body Alire.Settings.Edit is
begin
-- Warn or fail depending on version
if OS_Lib.Getenv (Environment.Config, Unset) /= Unset then
if Version.Semver.Current < Features.Config_Deprecated then
if Version.Current < Features.Config_Deprecated then
Warnings.Warn_Once (Msg, Level => Warning);
else
Raise_Checked_Error (Msg);
Expand Down
14 changes: 0 additions & 14 deletions src/alire/alire-version-semver.ads

This file was deleted.

16 changes: 14 additions & 2 deletions src/alire/alire-version.ads
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
package Alire.Version with Preelaborate is
with Semantic_Versioning;

package Alire.Version is

package Semver renames Semantic_Versioning;

subtype Version is Semver.Version;

Current : constant Version;

private

-- Remember to update Alire.Index branch if needed too

Current : constant String := "2.1-dev";
Current_Str : constant String := "2.1-dev";
-- 2.0.0: alr settings refactor and minor fixes
-- 2.0.0-rc1: release candidate for 2.0
-- 2.0.0-b1: first public release on the 2.0 branch
Expand All @@ -23,4 +33,6 @@ package Alire.Version with Preelaborate is
-- 0.8.1-dev: update to devel-0.5 index branch
-- 0.8.0-dev: post-0.7-beta changes

Current : constant Version := Semver.New_Version (Current_Str);

end Alire.Version;
4 changes: 2 additions & 2 deletions src/alire/alire_early_elaboration.adb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ with Ada.Directories;

with Alire.Features;
with Alire.Settings.Edit.Early_Load;
with Alire.Version.Semver;
with Alire.Version;

with GNAT.Command_Line;
with GNAT.OS_Lib;
Expand Down Expand Up @@ -110,7 +110,7 @@ package body Alire_Early_Elaboration is

use type Alire.Version.Semver.Version;
Config_Deprecated : constant Boolean
:= Alire.Version.Semver.Current >= Alire.Features.Config_Deprecated;
:= Alire.Version.Current >= Alire.Features.Config_Deprecated;

procedure Check_Config_Deprecated is
begin
Expand Down
8 changes: 5 additions & 3 deletions src/alr/alr-commands-version.adb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ with Alire.Properties;
with Alire.Roots.Optional;
with Alire.Toolchains;
with Alire.Utils.Tables;
with Alire.Version;

with Alr.Bootstrap;

Expand Down Expand Up @@ -61,9 +62,10 @@ package body Alr.Commands.Version is
end if;

Table.Append ("APPLICATION").Append ("").New_Row;
Table.Append ("alr version:").Append (Alire.Version.Current).New_Row;
Table.Append ("alr version:")
.Append (Alire.Version.Current.Image).New_Row;
Table.Append ("libalire version:")
.Append (Alire.Version.Current).New_Row;
.Append (Alire.Version.Current.Image).New_Row;
Table.Append ("compilation date:")
.Append (GNAT.Source_Info.Compilation_ISO_Date & " "
& GNAT.Source_Info.Compilation_Time).New_Row;
Expand Down Expand Up @@ -193,7 +195,7 @@ package body Alr.Commands.Version is

procedure Print_Version is
begin
Trace.Always ("alr " & Alire.Version.Current);
Trace.Always ("alr " & Alire.Version.Current.Image);
end Print_Version;

end Alr.Commands.Version;
3 changes: 1 addition & 2 deletions src/alr/alr-commands.adb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ with Alire.Platforms.Current;
with Alire.Root;
with Alire.Solutions;
with Alire.Toolchains;
with Alire.Version.Semver;

with Alr.Commands.Action;
with Alr.Commands.Build;
Expand Down Expand Up @@ -143,7 +142,7 @@ package body Alr.Commands is
use CLIC.Subcommand;
use type Alire.Version.Semver.Version;
begin
if Alire.Version.Semver.Current < Features.Config_Deprecated then
if Alire.Version.Current < Features.Config_Deprecated then
Define_Switch (Config,
Command_Line_Config_Path'Access,
"-c=", "--config=",
Expand Down
2 changes: 1 addition & 1 deletion src/alr/alr-commands.ads
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private

package Sub_Cmd is new CLIC.Subcommand.Instance
(Main_Command_Name => "alr",
Version => Alire.Version.Current,
Version => Alire.Version.Current.Image,
Put => GNAT.IO.Put,
Put_Line => GNAT.IO.Put_Line,
Put_Error => Put_Error,
Expand Down

0 comments on commit 9519d65

Please sign in to comment.