mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Merge pull request #12385 from DeterminateSystems/fix-git-workdir-path-display
Fix duplicate setPathDisplay()
This commit is contained in:
commit
340eae1f23
6 changed files with 30 additions and 22 deletions
|
@ -508,7 +508,10 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
|
||||||
*/
|
*/
|
||||||
ref<GitSourceAccessor> getRawAccessor(const Hash & rev);
|
ref<GitSourceAccessor> getRawAccessor(const Hash & rev);
|
||||||
|
|
||||||
ref<SourceAccessor> getAccessor(const Hash & rev, bool exportIgnore) override;
|
ref<SourceAccessor> getAccessor(
|
||||||
|
const Hash & rev,
|
||||||
|
bool exportIgnore,
|
||||||
|
std::string displayPrefix) override;
|
||||||
|
|
||||||
ref<SourceAccessor> getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError e) override;
|
ref<SourceAccessor> getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError e) override;
|
||||||
|
|
||||||
|
@ -627,7 +630,7 @@ struct GitRepoImpl : GitRepo, std::enable_shared_from_this<GitRepoImpl>
|
||||||
|
|
||||||
Hash treeHashToNarHash(const Hash & treeHash) override
|
Hash treeHashToNarHash(const Hash & treeHash) override
|
||||||
{
|
{
|
||||||
auto accessor = getAccessor(treeHash, false);
|
auto accessor = getAccessor(treeHash, false, "");
|
||||||
|
|
||||||
fetchers::Cache::Key cacheKey{"treeHashToNarHash", {{"treeHash", treeHash.gitRev()}}};
|
fetchers::Cache::Key cacheKey{"treeHashToNarHash", {{"treeHash", treeHash.gitRev()}}};
|
||||||
|
|
||||||
|
@ -1194,16 +1197,18 @@ ref<GitSourceAccessor> GitRepoImpl::getRawAccessor(const Hash & rev)
|
||||||
return make_ref<GitSourceAccessor>(self, rev);
|
return make_ref<GitSourceAccessor>(self, rev);
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<SourceAccessor> GitRepoImpl::getAccessor(const Hash & rev, bool exportIgnore)
|
ref<SourceAccessor> GitRepoImpl::getAccessor(
|
||||||
|
const Hash & rev,
|
||||||
|
bool exportIgnore,
|
||||||
|
std::string displayPrefix)
|
||||||
{
|
{
|
||||||
auto self = ref<GitRepoImpl>(shared_from_this());
|
auto self = ref<GitRepoImpl>(shared_from_this());
|
||||||
ref<GitSourceAccessor> rawGitAccessor = getRawAccessor(rev);
|
ref<GitSourceAccessor> rawGitAccessor = getRawAccessor(rev);
|
||||||
if (exportIgnore) {
|
rawGitAccessor->setPathDisplay(std::move(displayPrefix));
|
||||||
|
if (exportIgnore)
|
||||||
return make_ref<GitExportIgnoreSourceAccessor>(self, rawGitAccessor, rev);
|
return make_ref<GitExportIgnoreSourceAccessor>(self, rawGitAccessor, rev);
|
||||||
}
|
else
|
||||||
else {
|
|
||||||
return rawGitAccessor;
|
return rawGitAccessor;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<SourceAccessor> GitRepoImpl::getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError makeNotAllowedError)
|
ref<SourceAccessor> GitRepoImpl::getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError makeNotAllowedError)
|
||||||
|
@ -1236,7 +1241,7 @@ std::vector<std::tuple<GitRepoImpl::Submodule, Hash>> GitRepoImpl::getSubmodules
|
||||||
/* Read the .gitmodules files from this revision. */
|
/* Read the .gitmodules files from this revision. */
|
||||||
CanonPath modulesFile(".gitmodules");
|
CanonPath modulesFile(".gitmodules");
|
||||||
|
|
||||||
auto accessor = getAccessor(rev, exportIgnore);
|
auto accessor = getAccessor(rev, exportIgnore, "");
|
||||||
if (!accessor->pathExists(modulesFile)) return {};
|
if (!accessor->pathExists(modulesFile)) return {};
|
||||||
|
|
||||||
/* Parse it and get the revision of each submodule. */
|
/* Parse it and get the revision of each submodule. */
|
||||||
|
|
|
@ -86,7 +86,10 @@ struct GitRepo
|
||||||
|
|
||||||
virtual bool hasObject(const Hash & oid) = 0;
|
virtual bool hasObject(const Hash & oid) = 0;
|
||||||
|
|
||||||
virtual ref<SourceAccessor> getAccessor(const Hash & rev, bool exportIgnore) = 0;
|
virtual ref<SourceAccessor> getAccessor(
|
||||||
|
const Hash & rev,
|
||||||
|
bool exportIgnore,
|
||||||
|
std::string displayPrefix) = 0;
|
||||||
|
|
||||||
virtual ref<SourceAccessor> getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError makeNotAllowedError) = 0;
|
virtual ref<SourceAccessor> getAccessor(const WorkdirInfo & wd, bool exportIgnore, MakeNotAllowedError makeNotAllowedError) = 0;
|
||||||
|
|
||||||
|
|
|
@ -672,9 +672,7 @@ struct GitInputScheme : InputScheme
|
||||||
verifyCommit(input, repo);
|
verifyCommit(input, repo);
|
||||||
|
|
||||||
bool exportIgnore = getExportIgnoreAttr(input);
|
bool exportIgnore = getExportIgnoreAttr(input);
|
||||||
auto accessor = repo->getAccessor(rev, exportIgnore);
|
auto accessor = repo->getAccessor(rev, exportIgnore, "«" + input.to_string() + "»");
|
||||||
|
|
||||||
accessor->setPathDisplay("«" + input.to_string() + "»");
|
|
||||||
|
|
||||||
/* If the repo has submodules, fetch them and return a mounted
|
/* If the repo has submodules, fetch them and return a mounted
|
||||||
input accessor consisting of the accessor for the top-level
|
input accessor consisting of the accessor for the top-level
|
||||||
|
@ -737,8 +735,6 @@ struct GitInputScheme : InputScheme
|
||||||
exportIgnore,
|
exportIgnore,
|
||||||
makeNotAllowedError(repoInfo.locationToArg()));
|
makeNotAllowedError(repoInfo.locationToArg()));
|
||||||
|
|
||||||
accessor->setPathDisplay(repoInfo.locationToArg());
|
|
||||||
|
|
||||||
/* If the repo has submodules, return a mounted input accessor
|
/* If the repo has submodules, return a mounted input accessor
|
||||||
consisting of the accessor for the top-level repo and the
|
consisting of the accessor for the top-level repo and the
|
||||||
accessors for the submodule workdirs. */
|
accessors for the submodule workdirs. */
|
||||||
|
|
|
@ -294,9 +294,10 @@ struct GitArchiveInputScheme : InputScheme
|
||||||
#endif
|
#endif
|
||||||
input.attrs.insert_or_assign("lastModified", uint64_t(tarballInfo.lastModified));
|
input.attrs.insert_or_assign("lastModified", uint64_t(tarballInfo.lastModified));
|
||||||
|
|
||||||
auto accessor = getTarballCache()->getAccessor(tarballInfo.treeHash, false);
|
auto accessor = getTarballCache()->getAccessor(
|
||||||
|
tarballInfo.treeHash,
|
||||||
accessor->setPathDisplay("«" + input.to_string() + "»");
|
false,
|
||||||
|
"«" + input.to_string() + "»");
|
||||||
|
|
||||||
return {accessor, input};
|
return {accessor, input};
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,8 @@ DownloadFileResult downloadFile(
|
||||||
|
|
||||||
static DownloadTarballResult downloadTarball_(
|
static DownloadTarballResult downloadTarball_(
|
||||||
const std::string & url,
|
const std::string & url,
|
||||||
const Headers & headers)
|
const Headers & headers,
|
||||||
|
const std::string & displayPrefix)
|
||||||
{
|
{
|
||||||
Cache::Key cacheKey{"tarball", {{"url", url}}};
|
Cache::Key cacheKey{"tarball", {{"url", url}}};
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ static DownloadTarballResult downloadTarball_(
|
||||||
.treeHash = treeHash,
|
.treeHash = treeHash,
|
||||||
.lastModified = (time_t) getIntAttr(infoAttrs, "lastModified"),
|
.lastModified = (time_t) getIntAttr(infoAttrs, "lastModified"),
|
||||||
.immutableUrl = maybeGetStrAttr(infoAttrs, "immutableUrl"),
|
.immutableUrl = maybeGetStrAttr(infoAttrs, "immutableUrl"),
|
||||||
.accessor = getTarballCache()->getAccessor(treeHash, false),
|
.accessor = getTarballCache()->getAccessor(treeHash, false, displayPrefix),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -371,9 +372,10 @@ struct TarballInputScheme : CurlInputScheme
|
||||||
{
|
{
|
||||||
auto input(_input);
|
auto input(_input);
|
||||||
|
|
||||||
auto result = downloadTarball_(getStrAttr(input.attrs, "url"), {});
|
auto result = downloadTarball_(
|
||||||
|
getStrAttr(input.attrs, "url"),
|
||||||
result.accessor->setPathDisplay("«" + input.to_string() + "»");
|
{},
|
||||||
|
"«" + input.to_string() + "»");
|
||||||
|
|
||||||
if (result.immutableUrl) {
|
if (result.immutableUrl) {
|
||||||
auto immutableInput = Input::fromURL(*input.settings, *result.immutableUrl);
|
auto immutableInput = Input::fromURL(*input.settings, *result.immutableUrl);
|
||||||
|
|
|
@ -37,6 +37,7 @@ nix-instantiate --eval -E "builtins.readFile ((builtins.fetchGit file://$TEST_RO
|
||||||
|
|
||||||
# Fetch a worktree.
|
# Fetch a worktree.
|
||||||
unset _NIX_FORCE_HTTP
|
unset _NIX_FORCE_HTTP
|
||||||
|
expectStderr 0 nix eval -vvvv --impure --raw --expr "(builtins.fetchGit file://$TEST_ROOT/worktree).outPath" | grepQuiet "copying '$TEST_ROOT/worktree/' to the store"
|
||||||
path0=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$TEST_ROOT/worktree).outPath")
|
path0=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$TEST_ROOT/worktree).outPath")
|
||||||
path0_=$(nix eval --impure --raw --expr "(builtins.fetchTree { type = \"git\"; url = file://$TEST_ROOT/worktree; }).outPath")
|
path0_=$(nix eval --impure --raw --expr "(builtins.fetchTree { type = \"git\"; url = file://$TEST_ROOT/worktree; }).outPath")
|
||||||
[[ $path0 = $path0_ ]]
|
[[ $path0 = $path0_ ]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue