mirror of
https://github.com/NixOS/nix
synced 2025-06-26 11:41:15 +02:00
Misc changes from the flakes branch
This commit is contained in:
parent
c85097da7c
commit
0a10854f85
22 changed files with 110 additions and 60 deletions
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -476,10 +476,11 @@ string base64Decode(const string & s);
|
|||
/* Get a value for the specified key from an associate container, or a
|
||||
default value if the key doesn't exist. */
|
||||
template <class T>
|
||||
std::optional<std::string> get(const T & map, const std::string & key)
|
||||
std::optional<typename T::mapped_type> get(const T & map, const typename T::key_type & key)
|
||||
{
|
||||
auto i = map.find(key);
|
||||
return i == map.end() ? std::optional<std::string>() : i->second;
|
||||
if (i == map.end()) return {};
|
||||
return std::optional<typename T::mapped_type>(i->second);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue