mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Add git submodule fixes from @bjornfor
This fixes fetching repositories with no submodules and also cleans up .git files in checkouts.
This commit is contained in:
parent
ea861be292
commit
c8d33de777
3 changed files with 10 additions and 3 deletions
|
@ -9,6 +9,7 @@ libexpr_SOURCES := $(wildcard $(d)/*.cc) $(wildcard $(d)/primops/*.cc) $(d)/lexe
|
||||||
libexpr_LIBS = libutil libstore libnixrust
|
libexpr_LIBS = libutil libstore libnixrust
|
||||||
|
|
||||||
libexpr_LDFLAGS =
|
libexpr_LDFLAGS =
|
||||||
|
|
||||||
ifneq ($(OS), FreeBSD)
|
ifneq ($(OS), FreeBSD)
|
||||||
libexpr_LDFLAGS += -ldl
|
libexpr_LDFLAGS += -ldl
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
#include "tarfile.hh"
|
#include "tarfile.hh"
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
@ -182,9 +183,13 @@ GitInfo exportGit(ref<Store> store, const std::string & uri,
|
||||||
|
|
||||||
runProgram("git", true, { "-C", tmpDir, "checkout", "--quiet", "FETCH_HEAD" });
|
runProgram("git", true, { "-C", tmpDir, "checkout", "--quiet", "FETCH_HEAD" });
|
||||||
runProgram("git", true, { "-C", tmpDir, "remote", "add", "origin", uri });
|
runProgram("git", true, { "-C", tmpDir, "remote", "add", "origin", uri });
|
||||||
runProgram("git", true, { "-C", tmpDir, "submodule", "--quiet", "update", "--init" });
|
runProgram("git", true, { "-C", tmpDir, "submodule", "--quiet", "update", "--init", "--recursive" });
|
||||||
|
|
||||||
deletePath(tmpDir + "/.git");
|
for (const auto& p : std::filesystem::recursive_directory_iterator(tmpDir)) {
|
||||||
|
if (p.path().filename() == ".git") {
|
||||||
|
std::filesystem::remove_all(p.path());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gitInfo.submodules = true;
|
gitInfo.submodules = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -47,4 +47,5 @@ pathWithSubmodules=$(nix eval --raw "(builtins.fetchGit { url = file://$rootRepo
|
||||||
[[ ! -e $pathWithoutSubmodules/sub/content ]]
|
[[ ! -e $pathWithoutSubmodules/sub/content ]]
|
||||||
[[ -e $pathWithSubmodules/sub/content ]]
|
[[ -e $pathWithSubmodules/sub/content ]]
|
||||||
|
|
||||||
|
# No .git directory or submodule reference files must be left
|
||||||
|
test "$(find "$pathWithSubmodules" -name .git)" = ""
|
||||||
|
|
Loading…
Reference in a new issue