aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/manifest-utility.cxx18
-rw-r--r--bpkg/manifest-utility.hxx13
-rw-r--r--bpkg/pkg-checkout.cxx4
-rw-r--r--bpkg/rep-fetch.cxx11
-rw-r--r--tests/rep-add.test8
-rw-r--r--tests/rep-fetch-git-branch.test6
-rw-r--r--tests/rep-fetch-git-commit.test8
-rw-r--r--tests/rep-info.test6
8 files changed, 50 insertions, 24 deletions
diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx
index 27e2553..ed50298 100644
--- a/bpkg/manifest-utility.cxx
+++ b/bpkg/manifest-utility.cxx
@@ -4,6 +4,8 @@
#include <bpkg/manifest-utility.hxx>
+#include <libbutl/sha256.mxx>
+
#include <bpkg/diagnostics.hxx>
using namespace std;
@@ -124,4 +126,20 @@ namespace bpkg
{
fail << "failed to guess repository type for '" << s << "': " << e << endf;
}
+
+ dir_path
+ repository_state (const repository_location& l)
+ {
+ switch (l.type ())
+ {
+ case repository_type::bpkg: return dir_path (); // No state.
+ case repository_type::git:
+ {
+ return dir_path (sha256 (l.canonical_name ()).abbreviated_string (16));
+ }
+ }
+
+ assert (false); // Can't be here.
+ return dir_path ();
+ }
}
diff --git a/bpkg/manifest-utility.hxx b/bpkg/manifest-utility.hxx
index f4dadb4..f672ba7 100644
--- a/bpkg/manifest-utility.hxx
+++ b/bpkg/manifest-utility.hxx
@@ -40,6 +40,19 @@ namespace bpkg
//
repository_location
parse_location (const char*, optional<repository_type>);
+
+ // Return the repository state subdirectory for the specified location as it
+ // appears under .bpkg/repositories/ in the bpkg configuration. Return empty
+ // directory if the repository type doesn't have any state.
+ //
+ // Note that the semantics used to produce this name is repository type-
+ // specific and can base on the repository canonical name or (potentially a
+ // subset of) the location URL. In particular, a state directory could be
+ // shared by multiple repository locations of the same type (@@ TODO: if we
+ // ever do this, then we will need to complicate the removal logic).
+ //
+ dir_path
+ repository_state (const repository_location&);
}
#endif // BPKG_MANIFEST_UTILITY_HXX
diff --git a/bpkg/pkg-checkout.cxx b/bpkg/pkg-checkout.cxx
index 7377b8e..f068b54 100644
--- a/bpkg/pkg-checkout.cxx
+++ b/bpkg/pkg-checkout.cxx
@@ -4,8 +4,6 @@
#include <bpkg/pkg-checkout.hxx>
-#include <libbutl/sha256.mxx>
-
#include <libbpkg/manifest.hxx>
#include <bpkg/package.hxx>
@@ -118,7 +116,7 @@ namespace bpkg
//
dir_path sd (c / repos_dir);
- sd /= dir_path (sha256 (rl.canonical_name ()).abbreviated_string (16));
+ sd /= repository_state (rl);
sd /= dir_path (pl->fragment);
sd /= path_cast<dir_path> (pl->location);
diff --git a/bpkg/rep-fetch.cxx b/bpkg/rep-fetch.cxx
index fc59ed9..3956c5a 100644
--- a/bpkg/rep-fetch.cxx
+++ b/bpkg/rep-fetch.cxx
@@ -4,7 +4,6 @@
#include <bpkg/rep-fetch.hxx>
-#include <libbutl/sha256.mxx>
#include <libbutl/process.mxx>
#include <libbutl/process-io.mxx> // operator<<(ostream, process_path)
#include <libbutl/manifest-parser.mxx>
@@ -15,6 +14,7 @@
#include <bpkg/package-odb.hxx>
#include <bpkg/database.hxx>
#include <bpkg/diagnostics.hxx>
+#include <bpkg/manifest-utility.hxx>
using namespace std;
using namespace butl;
@@ -152,12 +152,9 @@ namespace bpkg
// Clone or fetch the repository.
//
- // If changing the repository directory naming scheme, then don't forget
- // to also update pkg_checkout().
- //
- dir_path h (sha256 (rl.canonical_name ()).abbreviated_string (16));
+ dir_path sd (repository_state (rl));
- auto_rmdir rm (temp_dir / h);
+ auto_rmdir rm (temp_dir / sd);
dir_path& td (rm.path);
if (exists (td))
@@ -170,7 +167,7 @@ namespace bpkg
bool fetch (false);
if (conf != nullptr)
{
- rd = *conf / repos_dir / h;
+ rd = *conf / repos_dir / sd;
if (exists (rd))
{
diff --git a/tests/rep-add.test b/tests/rep-add.test
index a84f725..be72b51 100644
--- a/tests/rep-add.test
+++ b/tests/rep-add.test
@@ -66,14 +66,14 @@
:
$clone_cfg;
$* 'git://example.org/repo#master' 2>>EOE
- added repository git:example.org/repo
+ added repository git:example.org/repo#master
EOE
: http-git
:
$clone_cfg;
$* 'http://example.org/repo.git#master' 2>>EOE
- added repository git:example.org/repo
+ added repository git:example.org/repo#master
EOE
: http-bpkg
@@ -151,10 +151,10 @@
$clone_cfg;
$* 'git://example.org/testing#master' 2>>~%EOE%;
- %added repository git:example.org/testing%
+ %added repository git:example.org/testing#master%
EOE
$* 'git://www.example.org/testing#master' 2>>~%EOE% != 0
- %error: git:example.org/testing is already a repository of this configuration%
+ %error: git:example.org/testing#master is already a repository of this configuration%
EOE
}
diff --git a/tests/rep-fetch-git-branch.test b/tests/rep-fetch-git-branch.test
index 86f5cb1..61699bb 100644
--- a/tests/rep-fetch-git-branch.test
+++ b/tests/rep-fetch-git-branch.test
@@ -39,7 +39,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
end;
$* 2>>~"%EOE%"
- %fetching git:.+libfoo%
+ %fetching git:.+libfoo#$branch%
$warn1
%Cloning into '.+$branch'.+%
%Submodule 'doc/style' .+ registered for path 'doc/style'%
@@ -79,7 +79,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
end;
$* 2>>~"%EOE%"
- %fetching git:.+libfoo%
+ %fetching git:.+libfoo#$branch%
$warn
%Fetching in '.+$branch'.+%
1 package\(s\) in 1 repository\(s\)
@@ -132,7 +132,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
end;
$* 2>>~"%EOE%" 1>&2;
- %fetching git:.+libfoo%
+ %fetching git:.+libfoo#$branch%
$warn1
%Fetching in '.+$branch'.+%
%warning: unable to rmdir '?libbar'?:.+%
diff --git a/tests/rep-fetch-git-commit.test b/tests/rep-fetch-git-commit.test
index 3547010..ba05de5 100644
--- a/tests/rep-fetch-git-commit.test
+++ b/tests/rep-fetch-git-commit.test
@@ -41,7 +41,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
end;
$* 2>>~"%EOE%"
- %fetching git:.+style-basic%
+ %fetching git:.+style-basic#@$commit%
$warn
%Cloning into '.+$abbr_commit'.+%
$fetch
@@ -70,7 +70,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
end;
$* 2>>~"%EOE%"
- %fetching git:.+style-basic%
+ %fetching git:.+style-basic#stable@$commit%
$warn
%Cloning into '.+$abbr_commit'.+%
$fetch
@@ -99,7 +99,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
end;
$* 2>>~"%EOE%"
- %fetching git:.+style-basic%
+ %fetching git:.+style-basic#@$commit%
$warn
%Cloning into '.+$abbr_commit'.+%
$fetch
@@ -119,7 +119,7 @@ warning: fetching over dumb HTTP, no progress will be shown'
end;
$* 2>>~"%EOE%"
- %fetching git:.+style-basic%
+ %fetching git:.+style-basic#stable@$commit%
$warn
%Cloning into '.+$abbr_commit'.+%
1 package\(s\) in 1 repository\(s\)
diff --git a/tests/rep-info.test b/tests/rep-info.test
index 32b77fb..ce0c6d4 100644
--- a/tests/rep-info.test
+++ b/tests/rep-info.test
@@ -153,7 +153,7 @@ else
: Version module is enabled for the project.
:
$* "$rep/style-basic.git#master" >>~%EOO%
- %git:.+style-basic .+style-basic.git#master%
+ %git:.+style-basic#master .+style-basic.git#master%
%style-basic/1\.1\.0-a\.0\..+%
EOO
@@ -163,8 +163,8 @@ else
: The packages and repositories files are present in the repository root.
:
$* "$rep/libbar.git#master" >>~%EOO%
- %git:.+libbar .+libbar.git#master%
- %prerequisite git:.+style-basic .+style-basic.git#stable%
+ %git:.+libbar#master .+libbar.git#master%
+ %prerequisite git:.+style-basic#stable .+style-basic.git#stable%
libbar/1.0.0
libmbar/1.0.0