fix(package): never include the archive in itself; extend release-detail tests
This commit is contained in:
1 parent
691560a369
commit
2c4eeba945
7 files changed
+258
-1
No files matched your search
@@ -79,11 +79,27 @@ create_source_package(const std::filesystem::path &project_root,
|
||||
std::format("create_source_package: '{}' is not a directory", project_root.string()))};
|
||||
}
|
||||
|
||||
// The archive must never contain itself (or its in-progress staging file) when the output
|
||||
// lives inside the project tree, e.g. a custom build directory that is not named `build`.
|
||||
std::error_code output_ec;
|
||||
const auto canonical_output = std::filesystem::weakly_canonical(output_tar, output_ec);
|
||||
const bool have_output = !output_ec;
|
||||
const auto is_output_path = [&](const std::filesystem::path &path) {
|
||||
if (!have_output) {
|
||||
return false;
|
||||
}
|
||||
std::error_code candidate_ec;
|
||||
return std::filesystem::weakly_canonical(path, candidate_ec) == canonical_output;
|
||||
};
|
||||
|
||||
std::vector<ArchiveEntrySpec> entries;
|
||||
std::filesystem::recursive_directory_iterator it{
|
||||
canon, std::filesystem::directory_options::skip_permission_denied, ec};
|
||||
for (; !ec && it != std::filesystem::recursive_directory_iterator{}; it.increment(ec)) {
|
||||
const auto rel = it->path().lexically_relative(canon);
|
||||
if (is_output_path(it->path())) {
|
||||
continue;
|
||||
}
|
||||
if (is_excluded_package_path(rel)) {
|
||||
if (it->is_directory(ec)) {
|
||||
it.disable_recursion_pending();
|
||||
|
||||
Reference in new issue
Block a user