This commit is contained in:
parent
c466d90eec
commit
f442caa888
6 changed files with 224 additions and 11 deletions
|
|
@ -396,6 +396,34 @@ Configuration* Crafter::GitProject(const GitProjectSpec& spec) {
|
|||
return ptr;
|
||||
}
|
||||
|
||||
fs::path Crafter::GitFetch(const GitSource& source) {
|
||||
std::string name = DeriveName(source);
|
||||
if (name.empty()) {
|
||||
throw std::runtime_error(std::format(
|
||||
"GitFetch: could not derive name from URL '{}'", source.url));
|
||||
}
|
||||
fs::path externalRoot = GetCacheDir() / "external";
|
||||
std::error_code ec;
|
||||
fs::create_directories(externalRoot, ec);
|
||||
if (ec) {
|
||||
throw std::runtime_error(std::format(
|
||||
"GitFetch: failed to create {}: {}", externalRoot.string(), ec.message()));
|
||||
}
|
||||
std::string keyMaterial = std::format("git|{}|{}|{}",
|
||||
source.url, source.branch, source.commit);
|
||||
std::size_t key = std::hash<std::string>{}(keyMaterial);
|
||||
fs::path cloneDir = externalRoot / std::format("{}-{:016x}", name, key);
|
||||
|
||||
{
|
||||
bool exists = fs::exists(cloneDir);
|
||||
Progress::Task task(std::format("{} {}", exists ? "Updating" : "Cloning", name));
|
||||
if (std::string err = FetchGit(source, cloneDir); !err.empty()) {
|
||||
throw std::runtime_error(std::format("GitFetch({}): {}", source.url, err));
|
||||
}
|
||||
}
|
||||
return cloneDir;
|
||||
}
|
||||
|
||||
Configuration* Crafter::LocalProject(const LocalProjectSpec& spec) {
|
||||
fs::path projectPath = fs::absolute(spec.projectFile).lexically_normal();
|
||||
if (!fs::exists(projectPath)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue