Skip to content

Commit

Permalink
Fix bad refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Sep 9, 2020
1 parent 570ddb7 commit 7025c4e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/alire/alire-publish.adb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ package body Alire.Publish is

type Data is limited record
Origin : Origins.Origin := Origins.New_External ("undefined");
-- We use external as "undefined" until a proper URL is provided.
-- We use external as "undefined" until a proper origin is provided.

Tmp_Deploy_Dir : Directories.Temp_File;
-- Place to check the sources
Expand Down Expand Up @@ -91,7 +91,7 @@ package body Alire.Publish is

procedure Deploy_Sources (Context : in out Data) with
Pre => Context.Origin.Kind not in Origins.External;
-- Extract URL to a temporary location, to compute hash, read user
-- Extract origin to a temporary location, to compute hash, read user
-- manifest and verify buildability.

procedure Deploy_Sources (Context : in out Data) is
Expand All @@ -103,7 +103,7 @@ package body Alire.Publish is

Deployer.Fetch (Context.Tmp_Deploy_Dir.Filename).Assert;

-- Compute hashes in supported URL kinds (e.g. source archives)
-- Compute hashes in supported origin kinds (e.g. source archives)

if Deployer.Supports_Hashing then
for Kind in Hashes.Kinds loop
Expand Down Expand Up @@ -132,7 +132,7 @@ package body Alire.Publish is

procedure Generate_Index_Manifest (Context : in out Data) with
Pre => GNAT.OS_Lib.Is_Directory (Context.Tmp_Deploy_Dir.Filename);
-- Bind the user manifest with the URL TOML object and create the index
-- Bind the user manifest with the origin TOML object and create the index
-- manifest.

procedure Generate_Index_Manifest (Context : in out Data) is
Expand Down Expand Up @@ -185,7 +185,7 @@ package body Alire.Publish is
Ada.Directories.Copy_File (User_Manifest, Index_Manifest);

-- Take the user manifest and bundle it under the proper index
-- manifest name with the URL we are being provided with:
-- manifest name with the origin we are being provided with:

Open (Index_File, Append_File, Index_Manifest);
New_Line (Index_File);
Expand Down Expand Up @@ -309,7 +309,7 @@ package body Alire.Publish is
procedure Verify_Origin (Context : in out Data) is
begin

-- Ensure the URL is remote
-- Ensure the origin is remote

if URI.Scheme
(case Context.Origin.Kind is
Expand Down Expand Up @@ -384,7 +384,7 @@ package body Alire.Publish is
----------------------

procedure Local_Repository (Path : Any_Path := ".";
Revision : String := "")
Revision : String := "HEAD")
is
Root : constant Roots.Optional.Root := Roots.Optional.Search_Root (Path);
use all type VCSs.Git.States;
Expand Down Expand Up @@ -433,7 +433,7 @@ package body Alire.Publish is
& TTY.Emph (Revision));
end if;

Remote_Origin
Publish.Remote_Origin
(URL => Git.Fetch_URL (Root.Value.Path),
Commit => Commit);
end;
Expand Down
9 changes: 4 additions & 5 deletions src/alire/alire-publish.ads
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ with Alire.URI;
package Alire.Publish is

procedure Local_Repository (Path : Any_Path := ".";
Revision : String := "") with
Revision : String := "HEAD") with
Pre => URI.Scheme (Path) in URI.File_Schemes;
-- Check that given Path is an up-to-date git repo with URL in the
-- whitelist. If so, proceed with remote repo verification. If no revision
-- given use the HEAD commit, otherwise use the revision (tag, branch,
-- commit) commit.
-- Check that given Path is an up-to-date git repo. If so, proceed with
-- remote repo verification. If no revision given use the HEAD commit,
-- otherwise use the revision (tag, branch, commit) commit.

procedure Remote_Origin (URL : Alire.URL;
Commit : String := "");
Expand Down
8 changes: 5 additions & 3 deletions src/alire/alire-vcss-git.adb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ package body Alire.VCSs.Git is
Guard : Directories.Guard (Directories.Enter (Into))
with Unreferenced;
begin
-- Checkout a specific Rev.
-- Checkout a specific commit.
-- "-q" needed to avoid the "detached HEAD" warning from git
Run_Git (Empty_Vector & "checkout" & "-q" & Commit (From));

Expand Down Expand Up @@ -141,6 +141,7 @@ package body Alire.VCSs.Git is
Origin : String := "origin")
return URL
is
pragma Unreferenced (This);
Guard : Directories.Guard (Directories.Enter (Repo)) with Unreferenced;
Output : constant Utils.String_Vector :=
Run_Git_And_Capture (Empty_Vector & "config" & "--list");
Expand Down Expand Up @@ -168,8 +169,8 @@ package body Alire.VCSs.Git is
begin

-- When a repo is in detached head state (e.g. after checking out a
-- Rev instead of a branch), 'git status' will have as the first line
-- "HEAD detached at <Rev>". Other changes come next.
-- commit instead of a branch), 'git status' will have as the first line
-- "HEAD detached at <commit>". Other changes come next.

return not Output.Is_Empty
and then Utils.Contains (Output.First_Element, "HEAD detached");
Expand All @@ -180,6 +181,7 @@ package body Alire.VCSs.Git is
------------

function Remote (This : VCS; Path : Directory_Path) return String is
pragma Unreferenced (This);
Guard : Directories.Guard (Directories.Enter (Path)) with Unreferenced;
begin
return Run_Git_And_Capture (Empty_Vector & "remote").First_Element;
Expand Down

0 comments on commit 7025c4e

Please sign in to comment.