Merge pull request #5905 from lincolnauster/flake-update-custom-commit
Custom commit messages when commiting the lockfile
This commit is contained in:
commit
bc443511eb
3 changed files with 27 additions and 4 deletions
|
@ -9,3 +9,7 @@
|
||||||
as `lib.zipAttrsWith` from nixpkgs, but much more efficient.
|
as `lib.zipAttrsWith` from nixpkgs, but much more efficient.
|
||||||
* New command `nix store copy-log` to copy build logs from one store
|
* New command `nix store copy-log` to copy build logs from one store
|
||||||
to another.
|
to another.
|
||||||
|
* The `commit-lockfile-summary` option can be set to a non-empty string
|
||||||
|
to override the commit summary used when commiting an updated lockfile.
|
||||||
|
This may be used in conjunction with the nixConfig attribute in
|
||||||
|
`flake.nix` to better conform to repository conventions.
|
||||||
|
|
|
@ -633,12 +633,24 @@ LockedFlake lockFlake(
|
||||||
|
|
||||||
newLockFile.write(path);
|
newLockFile.write(path);
|
||||||
|
|
||||||
|
std::optional<std::string> commitMessage = std::nullopt;
|
||||||
|
if (lockFlags.commitLockFile) {
|
||||||
|
std::string cm;
|
||||||
|
|
||||||
|
cm = settings.commitLockFileSummary.get();
|
||||||
|
|
||||||
|
if (cm == "") {
|
||||||
|
cm = fmt("%s: %s", relPath, lockFileExists ? "Update" : "Add");
|
||||||
|
}
|
||||||
|
|
||||||
|
cm += "\n\nFlake lock file updates:\n\n";
|
||||||
|
cm += filterANSIEscapes(diff, true);
|
||||||
|
commitMessage = cm;
|
||||||
|
}
|
||||||
|
|
||||||
topRef.input.markChangedFile(
|
topRef.input.markChangedFile(
|
||||||
(topRef.subdir == "" ? "" : topRef.subdir + "/") + "flake.lock",
|
(topRef.subdir == "" ? "" : topRef.subdir + "/") + "flake.lock",
|
||||||
lockFlags.commitLockFile
|
commitMessage);
|
||||||
? std::optional<std::string>(fmt("%s: %s\n\nFlake lock file changes:\n\n%s",
|
|
||||||
relPath, lockFileExists ? "Update" : "Add", filterANSIEscapes(diff, true)))
|
|
||||||
: std::nullopt);
|
|
||||||
|
|
||||||
/* Rewriting the lockfile changed the top-level
|
/* Rewriting the lockfile changed the top-level
|
||||||
repo, so we should re-read it. FIXME: we could
|
repo, so we should re-read it. FIXME: we could
|
||||||
|
|
|
@ -966,6 +966,13 @@ public:
|
||||||
|
|
||||||
Setting<bool> acceptFlakeConfig{this, false, "accept-flake-config",
|
Setting<bool> acceptFlakeConfig{this, false, "accept-flake-config",
|
||||||
"Whether to accept nix configuration from a flake without prompting."};
|
"Whether to accept nix configuration from a flake without prompting."};
|
||||||
|
|
||||||
|
Setting<std::string> commitLockFileSummary{
|
||||||
|
this, "", "commit-lockfile-summary",
|
||||||
|
R"(
|
||||||
|
The commit summary to use when commiting changed flake lock files. If
|
||||||
|
empty, the summary is generated based on the action performed.
|
||||||
|
)"};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue