aboutsummaryrefslogtreecommitdiff
path: root/bpkg/manifest-utility.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-02-22 15:02:15 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-02-22 17:27:41 +0300
commitf619db022734dff6b988c514e3a292a5c7babaf0 (patch)
tree73ab481eeb0ed524168e00f89d55dc2d3a91b9bd /bpkg/manifest-utility.cxx
parent6ec24eebcb42c0db205f9fff3f2716b84c6fcabf (diff)
Invent repository_state() function
Diffstat (limited to 'bpkg/manifest-utility.cxx')
-rw-r--r--bpkg/manifest-utility.cxx18
1 files changed, 18 insertions, 0 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 ();
+ }
}