diff options
Diffstat (limited to 'libbpkg/manifest.cxx')
-rw-r--r-- | libbpkg/manifest.cxx | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index a972793..d7cf7cf 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -1770,9 +1770,9 @@ namespace bpkg } case repository_type::git: { - if (!url_.fragment) - throw invalid_argument ("missing branch/tag for git repository"); - + // Verify the URL fragment. + // + git_reference r (url_.fragment); break; } } @@ -1942,6 +1942,37 @@ namespace bpkg canonical_name_ += cp; } + // git_reference + // + git_reference:: + git_reference (const optional<string>& frag) + { + if (frag) + { + const string& s (*frag); + + size_t p (s.find ('@')); + if (p != string::npos) + { + if (p != 0) + branch = string (s, 0, p); + + if (p + 1 != s.size ()) + commit = string (s, p + 1); + } + else if (!s.empty ()) + branch = s; + } + + if (!branch && !commit) + throw invalid_argument ( + "missing branch/tag or commit id for git repository"); + + if (commit && commit->size () != 40) + throw invalid_argument ( + "git repository commit id must be 40 characters long"); + } + // repository_manifest // repository_manifest:: |