some thoughts about post unachivation, nothing useful yet
This commit is contained in:
parent
5ee7ae7f73
commit
198677fc18
@ -44,7 +44,32 @@ bool Dependency::prepare(const std::filesystem::path& source, const std::filesys
|
||||
const std::string& owner = results[3];
|
||||
const std::string& repo = results[4];
|
||||
|
||||
return downloadRepo(destination, protocol, host, owner, repo);
|
||||
std::filesystem::path temp;
|
||||
bool success = downloadRepo(destination, protocol, host, owner, repo, temp);
|
||||
if (success) {
|
||||
Project::info("Successfully obtained project " + path);
|
||||
|
||||
switch (type) {
|
||||
case Type::automatic:
|
||||
if (std::filesystem::exists(temp/"mason.json"))
|
||||
type = Type::mason;
|
||||
else
|
||||
type = Type::simple;
|
||||
|
||||
break;
|
||||
case Type::mason:
|
||||
if (std::filesystem::exists(temp/"mason.json"))
|
||||
break;
|
||||
else
|
||||
Project::warn("Project " + path + " is supposed to me a mason project, but no mason.json was found in the project directory");
|
||||
|
||||
break;
|
||||
case Type::simple:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
} else {
|
||||
Project::info("checking project at path " + path);
|
||||
std::filesystem::directory_entry srcDir(source / path);
|
||||
@ -62,7 +87,8 @@ bool Dependency::downloadRepo(
|
||||
const std::string& protocol,
|
||||
const std::string& host,
|
||||
const std::string& owner,
|
||||
const std::string& repo
|
||||
const std::string& repo,
|
||||
std::filesystem::path& out
|
||||
) {
|
||||
nlohmann::json info;
|
||||
Project::info("Trying Gitea v1 API");
|
||||
@ -83,9 +109,17 @@ bool Dependency::downloadRepo(
|
||||
Project::info("Successfully downloaded " + archivePath.string());
|
||||
|
||||
res = extract(archivePath, destination/build);
|
||||
if (!res) {
|
||||
if (res) {
|
||||
out = destination/build/repo;
|
||||
if (!std::filesystem::is_directory(out)) {
|
||||
Project::error("Extracted archive " + fileName + " but the content is unexpected");
|
||||
res = false;
|
||||
}
|
||||
} else {
|
||||
Project::error("Couldn't extract archive " + fileName);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
res = false;
|
||||
@ -264,6 +298,9 @@ bool Dependency::extract(const std::filesystem::path& source, const std::filesys
|
||||
std::string fileName(archive_entry_pathname(entry));
|
||||
std::filesystem::path filePath = destination/fileName;
|
||||
Project::debug("Extracting " + filePath.string());
|
||||
if (std::filesystem::exists(filePath))
|
||||
Project::minor(filePath.string() + " exists, overwriting");
|
||||
|
||||
archive_entry_set_pathname_utf8(entry, filePath.c_str());
|
||||
|
||||
r = archive_write_header(ext, entry);
|
||||
|
@ -45,7 +45,8 @@ private:
|
||||
const std::string& protocol,
|
||||
const std::string& host,
|
||||
const std::string& owner,
|
||||
const std::string& repo
|
||||
const std::string& repo,
|
||||
std::filesystem::path& out
|
||||
);
|
||||
bool repoGiteaApi1(
|
||||
const std::string& protocol,
|
||||
|
@ -41,6 +41,8 @@ public:
|
||||
static void fatal(const std::string& message);
|
||||
static void printLog();
|
||||
|
||||
static void addProject(const std::filesystem::path& location, const std::filesystem::path& destination);
|
||||
|
||||
private:
|
||||
void parse(const nlohmann::json& json);
|
||||
void createDepencencyFromString(const std::string& entry);
|
||||
|
Loading…
Reference in New Issue
Block a user