diff options
author | Michael Hoang <enzime@users.noreply.github.com> | 2021-10-14 23:44:45 +1100 |
---|---|---|
committer | Michael Hoang <enzime@users.noreply.github.com> | 2023-06-24 14:17:25 +1000 |
commit | a7b49086c76bc181ab1cf1d3c7fba44b06d2f1dd (patch) | |
tree | 63bad3884a9a0ea16fa4e587d0afb41ba9ea7d83 /src/libfetchers | |
parent | 940e9eb8dd6deacb2e41aca91d65bd0e616011d6 (diff) |
Add `dirtyRev` and `dirtyShortRev` to `fetchGit`
Fixes #4682
Diffstat (limited to 'src/libfetchers')
-rw-r--r-- | src/libfetchers/git.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index 47282f6c4..be5842d53 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -243,6 +243,13 @@ std::pair<StorePath, Input> fetchFromWorkdir(ref<Store> store, Input & input, co "lastModified", workdirInfo.hasHead ? std::stoull(runProgram("git", true, { "-C", actualPath, "--git-dir", gitDir, "log", "-1", "--format=%ct", "--no-show-signature", "HEAD" })) : 0); + if (workdirInfo.hasHead) { + input.attrs.insert_or_assign("dirtyRev", chomp( + runProgram("git", true, { "-C", actualPath, "--git-dir", gitDir, "rev-parse", "--verify", "HEAD" })) + "-dirty"); + input.attrs.insert_or_assign("dirtyShortRev", chomp( + runProgram("git", true, { "-C", actualPath, "--git-dir", gitDir, "rev-parse", "--verify", "--short", "HEAD" })) + "-dirty"); + } + return {std::move(storePath), input}; } } // end namespace @@ -283,7 +290,7 @@ struct GitInputScheme : InputScheme if (maybeGetStrAttr(attrs, "type") != "git") return {}; for (auto & [name, value] : attrs) - if (name != "type" && name != "url" && name != "ref" && name != "rev" && name != "shallow" && name != "submodules" && name != "lastModified" && name != "revCount" && name != "narHash" && name != "allRefs" && name != "name") + if (name != "type" && name != "url" && name != "ref" && name != "rev" && name != "shallow" && name != "submodules" && name != "lastModified" && name != "revCount" && name != "narHash" && name != "allRefs" && name != "name" && name != "dirtyRev" && name != "dirtyShortRev") throw Error("unsupported Git input attribute '%s'", name); parseURL(getStrAttr(attrs, "url")); |