mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 09:06:15 +02:00
fetchTree: Disallow combination of submodules and exportIgnore for now
This commit is contained in:
parent
71d08af15b
commit
692e9197bc
3 changed files with 32 additions and 13 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#include "libfetchers/attrs.hh"
|
||||||
#include "primops.hh"
|
#include "primops.hh"
|
||||||
#include "eval-inline.hh"
|
#include "eval-inline.hh"
|
||||||
#include "eval-settings.hh"
|
#include "eval-settings.hh"
|
||||||
|
@ -139,9 +140,7 @@ static void fetchTree(
|
||||||
state.symbols[attr.name], showType(*attr.value)));
|
state.symbols[attr.name], showType(*attr.value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.isFetchGit && !attrs.contains("exportIgnore")) {
|
if (params.isFetchGit && !attrs.contains("exportIgnore") && (!attrs.contains("submodules") || !*fetchers::maybeGetBoolAttr(attrs, "submodules"))) {
|
||||||
// Default value; user attrs are assigned later.
|
|
||||||
// FIXME: exportIgnore := !submodules
|
|
||||||
attrs.emplace("exportIgnore", Explicit<bool>{true});
|
attrs.emplace("exportIgnore", Explicit<bool>{true});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,8 +161,7 @@ static void fetchTree(
|
||||||
fetchers::Attrs attrs;
|
fetchers::Attrs attrs;
|
||||||
attrs.emplace("type", "git");
|
attrs.emplace("type", "git");
|
||||||
attrs.emplace("url", fixGitURL(url));
|
attrs.emplace("url", fixGitURL(url));
|
||||||
if (!attrs.contains("exportIgnore")) {
|
if (!attrs.contains("exportIgnore") && (!attrs.contains("submodules") || !*fetchers::maybeGetBoolAttr(attrs, "submodules"))) {
|
||||||
// FIXME: exportIgnore := !submodules
|
|
||||||
attrs.emplace("exportIgnore", Explicit<bool>{true});
|
attrs.emplace("exportIgnore", Explicit<bool>{true});
|
||||||
}
|
}
|
||||||
input = fetchers::Input::fromAttrs(std::move(attrs));
|
input = fetchers::Input::fromAttrs(std::move(attrs));
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "error.hh"
|
||||||
#include "fetchers.hh"
|
#include "fetchers.hh"
|
||||||
#include "users.hh"
|
#include "users.hh"
|
||||||
#include "cache.hh"
|
#include "cache.hh"
|
||||||
|
@ -739,6 +740,16 @@ struct GitInputScheme : InputScheme
|
||||||
|
|
||||||
auto repoInfo = getRepoInfo(input);
|
auto repoInfo = getRepoInfo(input);
|
||||||
|
|
||||||
|
if (getExportIgnoreAttr(input)
|
||||||
|
&& getSubmodulesAttr(input)) {
|
||||||
|
/* In this situation, we don't have a git CLI behavior that we can copy.
|
||||||
|
`git archive` does not support submodules, so it is unclear whether
|
||||||
|
rules from the parent should affect the submodule or not.
|
||||||
|
When git may eventually implement this, we need Nix to match its
|
||||||
|
behavior. */
|
||||||
|
throw UnimplementedError("exportIgnore and submodules are not supported together yet");
|
||||||
|
}
|
||||||
|
|
||||||
auto [accessor, final] =
|
auto [accessor, final] =
|
||||||
input.getRef() || input.getRev() || !repoInfo.isLocal
|
input.getRef() || input.getRev() || !repoInfo.isLocal
|
||||||
? getAccessorFromCommit(store, repoInfo, std::move(input))
|
? getAccessorFromCommit(store, repoInfo, std::move(input))
|
||||||
|
|
|
@ -124,12 +124,16 @@ git -C $rootRepo/sub config user.email "foobar@example.com"
|
||||||
git -C $rootRepo/sub config user.name "Foobar"
|
git -C $rootRepo/sub config user.name "Foobar"
|
||||||
|
|
||||||
echo "/exclude-from-root export-ignore" >> $rootRepo/.gitattributes
|
echo "/exclude-from-root export-ignore" >> $rootRepo/.gitattributes
|
||||||
|
# TBD possible semantics for submodules + exportIgnore
|
||||||
|
# echo "/sub/exclude-deep export-ignore" >> $rootRepo/.gitattributes
|
||||||
echo nope > $rootRepo/exclude-from-root
|
echo nope > $rootRepo/exclude-from-root
|
||||||
git -C $rootRepo add .gitattributes exclude-from-root
|
git -C $rootRepo add .gitattributes exclude-from-root
|
||||||
git -C $rootRepo commit -m "Add export-ignore"
|
git -C $rootRepo commit -m "Add export-ignore"
|
||||||
|
|
||||||
echo "/exclude-from-sub export-ignore" >> $rootRepo/sub/.gitattributes
|
echo "/exclude-from-sub export-ignore" >> $rootRepo/sub/.gitattributes
|
||||||
echo nope > $rootRepo/sub/exclude-from-sub
|
echo nope > $rootRepo/sub/exclude-from-sub
|
||||||
|
# TBD possible semantics for submodules + exportIgnore
|
||||||
|
# echo aye > $rootRepo/sub/exclude-from-root
|
||||||
git -C $rootRepo/sub add .gitattributes exclude-from-sub
|
git -C $rootRepo/sub add .gitattributes exclude-from-sub
|
||||||
git -C $rootRepo/sub commit -m "Add export-ignore (sub)"
|
git -C $rootRepo/sub commit -m "Add export-ignore (sub)"
|
||||||
|
|
||||||
|
@ -138,15 +142,21 @@ git -C $rootRepo commit -m "Update submodule"
|
||||||
|
|
||||||
git -C $rootRepo status
|
git -C $rootRepo status
|
||||||
|
|
||||||
# exportIgnore can be used with submodules
|
# # TBD: not supported yet, because semantics are undecided and current implementation leaks rules from the root to submodules
|
||||||
pathWithExportIgnore=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = file://$rootRepo; submodules = true; exportIgnore = true; }).outPath")
|
# # exportIgnore can be used with submodules
|
||||||
# find $pathWithExportIgnore
|
# pathWithExportIgnore=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = file://$rootRepo; submodules = true; exportIgnore = true; }).outPath")
|
||||||
# git -C $rootRepo archive --format=tar HEAD | tar -t
|
# # find $pathWithExportIgnore
|
||||||
# cp -a $rootRepo /tmp/rootRepo
|
# # git -C $rootRepo archive --format=tar HEAD | tar -t
|
||||||
|
# # cp -a $rootRepo /tmp/rootRepo
|
||||||
|
|
||||||
|
# [[ -e $pathWithExportIgnore/sub/content ]]
|
||||||
|
# [[ ! -e $pathWithExportIgnore/exclude-from-root ]]
|
||||||
|
# [[ ! -e $pathWithExportIgnore/sub/exclude-from-sub ]]
|
||||||
|
# TBD possible semantics for submodules + exportIgnore
|
||||||
|
# # root .gitattribute has no power across submodule boundary
|
||||||
|
# [[ -e $pathWithExportIgnore/sub/exclude-from-root ]]
|
||||||
|
# [[ -e $pathWithExportIgnore/sub/exclude-deep ]]
|
||||||
|
|
||||||
[[ -e $pathWithExportIgnore/sub/content ]]
|
|
||||||
[[ ! -e $pathWithExportIgnore/exclude-from-root ]]
|
|
||||||
[[ ! -e $pathWithExportIgnore/sub/exclude-from-sub ]]
|
|
||||||
|
|
||||||
# exportIgnore can be explicitly disabled with submodules
|
# exportIgnore can be explicitly disabled with submodules
|
||||||
pathWithoutExportIgnore=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = file://$rootRepo; submodules = true; exportIgnore = false; }).outPath")
|
pathWithoutExportIgnore=$(nix eval --impure --raw --expr "(builtins.fetchGit { url = file://$rootRepo; submodules = true; exportIgnore = false; }).outPath")
|
||||||
|
|
Loading…
Reference in a new issue