mirror of
https://github.com/NixOS/nix.git
synced 2025-11-30 14:10:59 +01:00
fetchTree: Support applying patches
You can now write
fetchTree {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
rev = "0f316e4d72daed659233817ffe52bf08e081b5de";
patches = [ ./thunderbird-1.patch ./thunderbird-2.patch ];
};
to apply a list of patches to a tree. These are applied lazily - the
patched tree is not materialized unless you do something that causes
the entire tree to be copied to the store (like 'src = fetchTree {
... }'). The equivalent of '-p1' is implied.
File additions/deletions/renames are not yet handled.
Issue #3920.
This commit is contained in:
parent
9075644631
commit
4b313ceb9e
6 changed files with 195 additions and 0 deletions
|
|
@ -311,6 +311,42 @@ namespace nix {
|
|||
ASSERT_THROW(base64Decode("cXVvZCBlcm_0IGRlbW9uc3RyYW5kdW0="), Error);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* getLine
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
||||
TEST(getLine, all) {
|
||||
{
|
||||
auto [line, rest] = getLine("foo\nbar\nxyzzy");
|
||||
ASSERT_EQ(line, "foo");
|
||||
ASSERT_EQ(rest, "bar\nxyzzy");
|
||||
}
|
||||
|
||||
{
|
||||
auto [line, rest] = getLine("foo\r\nbar\r\nxyzzy");
|
||||
ASSERT_EQ(line, "foo");
|
||||
ASSERT_EQ(rest, "bar\r\nxyzzy");
|
||||
}
|
||||
|
||||
{
|
||||
auto [line, rest] = getLine("foo\n");
|
||||
ASSERT_EQ(line, "foo");
|
||||
ASSERT_EQ(rest, "");
|
||||
}
|
||||
|
||||
{
|
||||
auto [line, rest] = getLine("foo");
|
||||
ASSERT_EQ(line, "foo");
|
||||
ASSERT_EQ(rest, "");
|
||||
}
|
||||
|
||||
{
|
||||
auto [line, rest] = getLine("");
|
||||
ASSERT_EQ(line, "");
|
||||
ASSERT_EQ(rest, "");
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* toLower
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -1564,6 +1564,21 @@ std::string stripIndentation(std::string_view s)
|
|||
}
|
||||
|
||||
|
||||
std::pair<std::string_view, std::string_view> getLine(std::string_view s)
|
||||
{
|
||||
auto newline = s.find('\n');
|
||||
|
||||
if (newline == s.npos) {
|
||||
return {s, ""};
|
||||
} else {
|
||||
auto line = s.substr(0, newline);
|
||||
if (!line.empty() && line[line.size() - 1] == '\r')
|
||||
line = line.substr(0, line.size() - 1);
|
||||
return {line, s.substr(newline + 1)};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -537,6 +537,12 @@ std::string base64Decode(std::string_view s);
|
|||
std::string stripIndentation(std::string_view s);
|
||||
|
||||
|
||||
/* Get the prefix of 's' up to and excluding the next line break (LF
|
||||
optionally preceded by CR), and the remainder following the line
|
||||
break. */
|
||||
std::pair<std::string_view, std::string_view> getLine(std::string_view s);
|
||||
|
||||
|
||||
/* Get a value for the specified key from an associate container. */
|
||||
template <class T>
|
||||
std::optional<typename T::mapped_type> get(const T & map, const typename T::key_type & key)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue