From 70cc5225fb83fbfd03f94cac312fc8a949241578 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Mon, 19 Feb 2024 13:37:03 +0100 Subject: [PATCH] Improvements to messages during dependency updates (#1569) * Fix bugs causing spurious diffs on update Solutions were the same, but some types internally where using pointers instead of pointed objects for comparison. WIP * Don't attempt redundant system package installation * Inform of pin checkouts/updates as for regular crates * Ensure created folders remain the same * Fix testsuite index for deterministic make version --- src/alire/alire-origins-deployers-system.ads | 12 +++++++ src/alire/alire-releases.adb | 31 +++++++++++++------ src/alire/alire-user_pins.adb | 11 +++++++ src/alire/alire-vcss-git.ads | 3 ++ .../gnat_external/gnat_external-external.toml | 5 ++- 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/alire/alire-origins-deployers-system.ads b/src/alire/alire-origins-deployers-system.ads index c9d4c28c5..e3769bb7d 100644 --- a/src/alire/alire-origins-deployers-system.ads +++ b/src/alire/alire-origins-deployers-system.ads @@ -68,6 +68,11 @@ package Alire.Origins.Deployers.System is function Platform_Deployer (Package_Name : String) return Deployer'Class is (Platform_Deployer (Origins.New_System (Package_Name))); + -- Classwide facilities + + function Already_Installed (This : Origins.Origin) return Boolean + with Pre => This.Is_System; + function Executable_Name return String; -- Returns the simple name of the executable package manager on the system @@ -81,4 +86,11 @@ private Ask_Permission : Boolean := True; end record; + ----------------------- + -- Already_Installed -- + ----------------------- + + function Already_Installed (This : Origins.Origin) return Boolean + is (Platform_Deployer (This).Already_Installed); + end Alire.Origins.Deployers.System; diff --git a/src/alire/alire-releases.adb b/src/alire/alire-releases.adb index 4341e42e7..2b80486e6 100644 --- a/src/alire/alire-releases.adb +++ b/src/alire/alire-releases.adb @@ -7,7 +7,7 @@ with Alire.Directories; with Alire.Defaults; with Alire.Errors; with Alire.Flags; -with Alire.Origins.Deployers; +with Alire.Origins.Deployers.System; with Alire.Paths; with Alire.Properties.Bool; with Alire.Properties.Scenarios; @@ -316,23 +316,34 @@ package body Alire.Releases is Trace.Detail ("Skipping checkout of already available " & This.Milestone.Image); + elsif This.Origin.Kind not in Origins.Deployable_Kinds then + Was_There := True; + Trace.Detail ("External requires no deployment for " & + This.Milestone.Image); + + elsif This.Origin.Is_System + and then Origins.Deployers.System.Already_Installed (This.Origin) + then + Was_There := True; + Trace.Detail ("Skipping install of already available system origin " & + This.Milestone.Image); + else Was_There := False; Put_Info ("Deploying " & This.Milestone.TTY_Image & "..."); Alire.Origins.Deployers.Deploy (This, Folder).Assert; + end if; - -- For deployers that do nothing, we ensure the folder exists so all - -- dependencies leave a trace in the cache/dependencies folder, and - -- a place from where to run their actions by default. - - Ada.Directories.Create_Path (Folder); + -- For deployers that do nothing, we ensure the folder exists so all + -- dependencies leave a trace in the cache/dependencies folder, and + -- a place from where to run their actions by default. - -- Backup a potentially packaged manifest, so our authoritative - -- manifest from the index is always used. + Ada.Directories.Create_Path (Folder); - Backup_Upstream_Manifest; + -- Backup a potentially packaged manifest, so our authoritative + -- manifest from the index is always used. - end if; + Backup_Upstream_Manifest; -- Create manifest if requested diff --git a/src/alire/alire-user_pins.adb b/src/alire/alire-user_pins.adb index 966774620..ea0c9ffc3 100644 --- a/src/alire/alire-user_pins.adb +++ b/src/alire/alire-user_pins.adb @@ -158,6 +158,14 @@ package body Alire.User_Pins is -- Check out the branch or commit + Put_Info ("Deploying " & Utils.TTY.Name (Crate) + & (if Commit /= "" + then " commit " & TTY.URL (VCSs.Git.Short_Commit (Commit)) + elsif Branch /= "" + then " branch " & TTY.URL (Branch) + else " default branch") + & "..."); + if not VCSs.Git.Handler.Clone (From => URL (This) & (if Commit /= "" @@ -207,6 +215,9 @@ package body Alire.User_Pins is -- user in the manifest, the following call will also take care of -- it. + Put_Info ("Pulling " & Utils.TTY.Name (Crate) + & " branch " & TTY.URL (Branch) & "..."); + if not VCSs.Git.Handler.Update (Destination, Branch).Success then Raise_Checked_Error ("Update of repository at " & TTY.URL (Destination) diff --git a/src/alire/alire-vcss-git.ads b/src/alire/alire-vcss-git.ads index 30c52113a..da4d5d526 100644 --- a/src/alire/alire-vcss-git.ads +++ b/src/alire/alire-vcss-git.ads @@ -22,6 +22,9 @@ package Alire.VCSs.Git is function Git_Dir return Any_Path; -- ".git" unless overridden by GIT_DIR + function Short_Commit (Commit : Git_Commit) return String + is (Commit (Commit'First .. Commit'First + 7)); + type VCS (<>) is new VCSs.VCS with private; function Handler return VCS; diff --git a/testsuite/fixtures/system_index/gn/gnat_external/gnat_external-external.toml b/testsuite/fixtures/system_index/gn/gnat_external/gnat_external-external.toml index f1171a6ba..6a899f8d1 100644 --- a/testsuite/fixtures/system_index/gn/gnat_external/gnat_external-external.toml +++ b/testsuite/fixtures/system_index/gn/gnat_external/gnat_external-external.toml @@ -6,7 +6,6 @@ maintainers-logins = ["mosteo"] [[external]] kind = "version-output" -# We look for make instead that should be always installed. -version-command = ["make", "--version"] -version-regexp = ".*Make ([\\d\\.]+).*" +version-command = ["echo", "1.0"] +version-regexp = "([\\d\\.]+).*" provides = "gnat"