diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2018-02-13 23:12:23 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2018-02-15 10:21:24 +0300 |
commit | 02458785b93094dfc65b31a4ecf2a8e690143b03 (patch) | |
tree | 81522d1b1602d82dbe0ee51915f8f8bb32c3b1bf /libbpkg/manifest.cxx | |
parent | 4ea1f6680b6b740220fc25a2c971560fde4d6392 (diff) |
Assume git repo URL fragment of 40 hex digits is a commit id
Diffstat (limited to 'libbpkg/manifest.cxx')
-rw-r--r-- | libbpkg/manifest.cxx | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libbpkg/manifest.cxx b/libbpkg/manifest.cxx index 81a9b8c..1c0650e 100644 --- a/libbpkg/manifest.cxx +++ b/libbpkg/manifest.cxx @@ -11,7 +11,7 @@ #include <cstring> // strncmp(), strcmp() #include <utility> // move() #include <cstdint> // uint16_t, UINT16_MAX -#include <algorithm> // find(), replace() +#include <algorithm> // find(), find_if_not(), replace() #include <stdexcept> // invalid_argument #include <libbutl/path.mxx> @@ -1961,7 +1961,20 @@ namespace bpkg commit = string (s, p + 1); } else if (!s.empty ()) - branch = s; + { + // A 40-characters fragment that consists of only hexadecimal digits is + // assumed to be a commit id. + // + if (s.size () == 40 && + find_if_not (s.begin (), s.end (), + + // Resolve the required overload. + // + static_cast<bool (*)(char)> (xdigit)) == s.end ()) + commit = s; + else + branch = s; + } } if (!branch && !commit) |