mirror of
https://github.com/NixOS/nix
synced 2025-07-06 05:01:48 +02:00
Automatically do git/hg add on flake.lock
This commit is contained in:
parent
f83acbbfe3
commit
d5334c466b
5 changed files with 47 additions and 23 deletions
|
@ -62,6 +62,9 @@ struct Input : std::enable_shared_from_this<Input>
|
|||
|
||||
virtual std::optional<Path> getSourcePath() const { return {}; }
|
||||
|
||||
// FIXME: should merge with getSourcePath().
|
||||
virtual void markChangedFile(std::string_view file) const { assert(false); }
|
||||
|
||||
virtual void clone(const Path & destDir) const
|
||||
{
|
||||
throw Error("do not know how to clone input '%s'", to_string());
|
||||
|
|
|
@ -165,6 +165,18 @@ struct GitInput : Input
|
|||
return {};
|
||||
}
|
||||
|
||||
void markChangedFile(std::string_view file) const override
|
||||
{
|
||||
auto sourcePath = getSourcePath();
|
||||
assert(sourcePath);
|
||||
runProgram("git", true,
|
||||
{ "-C", *sourcePath, "add",
|
||||
"--force",
|
||||
"--intent-to-add",
|
||||
std::string(file)
|
||||
});
|
||||
}
|
||||
|
||||
std::pair<bool, std::string> getActualUrl() const
|
||||
{
|
||||
// Don't clone file:// URIs (but otherwise treat them the
|
||||
|
|
|
@ -84,6 +84,17 @@ struct MercurialInput : Input
|
|||
return {};
|
||||
}
|
||||
|
||||
void markChangedFile(std::string_view file) const override
|
||||
{
|
||||
auto sourcePath = getSourcePath();
|
||||
assert(sourcePath);
|
||||
// FIXME: shut up if file is already tracked.
|
||||
runProgram("hg", true,
|
||||
{ "add",
|
||||
*sourcePath + "/" + std::string(file)
|
||||
});
|
||||
}
|
||||
|
||||
std::pair<bool, std::string> getActualUrl() const
|
||||
{
|
||||
bool isLocal = url.scheme == "file";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue