aboutsummaryrefslogtreecommitdiff
path: root/src/libfetchers
diff options
context:
space:
mode:
authorThéophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>2023-06-24 14:55:31 +0200
committerGitHub <noreply@github.com>2023-06-24 14:55:31 +0200
commit60f06a1714a74bf144eb9ccad9643578248bdfc4 (patch)
tree5f2c4badd53cd83e2ca027832a992d0e81a8ca6e /src/libfetchers
parentfd4f03b8fdcb0f33552730c786139019e29f5dbe (diff)
parenta7b49086c76bc181ab1cf1d3c7fba44b06d2f1dd (diff)
Merge pull request #5385 from Enzime/add/dirty-rev
Add `dirtyRev` and `dirtyShortRev` to `fetchGit`
Diffstat (limited to 'src/libfetchers')
-rw-r--r--src/libfetchers/git.cc9
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"));