diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-03-24 14:26:13 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-03-24 14:34:47 +0100 |
commit | 0a10854f857e519d1455ff0f0be1f8401c40a11c (patch) | |
tree | 64cd9b1c0727eb0642574e4535c5ba61af497c3a /src/libutil/hash.hh | |
parent | c85097da7c1ef06e2f1912c922110ff358de3aa2 (diff) |
Misc changes from the flakes branch
Diffstat (limited to 'src/libutil/hash.hh')
-rw-r--r-- | src/libutil/hash.hh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh index ffa43ecf5..ea9fca3e7 100644 --- a/src/libutil/hash.hh +++ b/src/libutil/hash.hh @@ -80,6 +80,18 @@ struct Hash or base-64. By default, this is prefixed by the hash type (e.g. "sha256:"). */ std::string to_string(Base base = Base32, bool includeType = true) const; + + std::string gitRev() const + { + assert(type == htSHA1); + return to_string(Base16, false); + } + + std::string gitShortRev() const + { + assert(type == htSHA1); + return std::string(to_string(Base16, false), 0, 7); + } }; |