mirror of
https://github.com/NixOS/nix.git
synced 2024-11-21 22:32:26 +00:00
dropEmptyInitThenConcatStringsSep -> concatStringSep: shortRefs are not empty
This commit is contained in:
parent
608a425550
commit
d3e49ac881
@ -339,7 +339,7 @@ public:
|
||||
(narInfo ? narInfo->fileSize : 0, narInfo != 0 && narInfo->fileSize)
|
||||
(info->narHash.to_string(HashFormat::Nix32, true))
|
||||
(info->narSize)
|
||||
(dropEmptyInitThenConcatStringsSep(" ", info->shortRefs()))
|
||||
(concatStringsSep(" ", info->shortRefs()))
|
||||
(info->deriver ? std::string(info->deriver->to_string()) : "", (bool) info->deriver)
|
||||
(concatStringsSep(" ", info->sigs))
|
||||
(renderContentAddress(info->ca))
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "globals.hh"
|
||||
#include "nar-info.hh"
|
||||
#include "store-api.hh"
|
||||
#include "strings.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
@ -111,7 +112,7 @@ std::string NarInfo::to_string(const Store & store) const
|
||||
res += "NarHash: " + narHash.to_string(HashFormat::Nix32, true) + "\n";
|
||||
res += "NarSize: " + std::to_string(narSize) + "\n";
|
||||
|
||||
res += "References: " + dropEmptyInitThenConcatStringsSep(" ", shortRefs()) + "\n";
|
||||
res += "References: " + concatStringsSep(" ", shortRefs()) + "\n";
|
||||
|
||||
if (deriver)
|
||||
res += "Deriver: " + std::string(deriver->to_string()) + "\n";
|
||||
|
@ -171,6 +171,9 @@ struct ValidPathInfo : UnkeyedValidPathInfo {
|
||||
*/
|
||||
bool checkSignature(const Store & store, const PublicKeys & publicKeys, const std::string & sig) const;
|
||||
|
||||
/**
|
||||
* References as store path basenames, including a self reference if it has one.
|
||||
*/
|
||||
Strings shortRefs() const;
|
||||
|
||||
ValidPathInfo(const ValidPathInfo & other) = default;
|
||||
|
@ -26,9 +26,9 @@ static UnkeyedValidPathInfo makeEmpty()
|
||||
};
|
||||
}
|
||||
|
||||
static UnkeyedValidPathInfo makeFull(const Store & store, bool includeImpureInfo)
|
||||
static ValidPathInfo makeFullKeyed(const Store & store, bool includeImpureInfo)
|
||||
{
|
||||
UnkeyedValidPathInfo info = ValidPathInfo {
|
||||
ValidPathInfo info = ValidPathInfo {
|
||||
store,
|
||||
"foo",
|
||||
FixedOutputInfo {
|
||||
@ -57,6 +57,9 @@ static UnkeyedValidPathInfo makeFull(const Store & store, bool includeImpureInfo
|
||||
}
|
||||
return info;
|
||||
}
|
||||
static UnkeyedValidPathInfo makeFull(const Store & store, bool includeImpureInfo) {
|
||||
return makeFullKeyed(store, includeImpureInfo);
|
||||
}
|
||||
|
||||
#define JSON_TEST(STEM, OBJ, PURE) \
|
||||
TEST_F(PathInfoTest, PathInfo_ ## STEM ## _from_json) { \
|
||||
@ -86,4 +89,13 @@ JSON_TEST(empty_impure, makeEmpty(), true)
|
||||
JSON_TEST(pure, makeFull(*store, false), false)
|
||||
JSON_TEST(impure, makeFull(*store, true), true)
|
||||
|
||||
TEST_F(PathInfoTest, PathInfo_full_shortRefs) {
|
||||
ValidPathInfo it = makeFullKeyed(*store, true);
|
||||
// it.references = unkeyed.references;
|
||||
auto refs = it.shortRefs();
|
||||
ASSERT_EQ(refs.size(), 2);
|
||||
ASSERT_EQ(*refs.begin(), "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar");
|
||||
ASSERT_EQ(*++refs.begin(), "n5wkd9frr45pa74if5gpz9j7mifg27fh-foo");
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
|
Loading…
Reference in New Issue
Block a user