Skip to content

Commit

Permalink
Change the copyright post-build-lint to require a regular file. (#584)
Browse files Browse the repository at this point in the history
* Make sure file is a file / directory

* Don't error on copyright is dir

* Apply diff

* Avoid multiple fs calls

* Format diff

* Merge localized msg

Co-authored-by: Billy O'Neal <[email protected]>
  • Loading branch information
Thomas1664 and BillyONeal authored Jul 20, 2022
1 parent e132afb commit a8de335
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/vcpkg/base/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ namespace vcpkg
"{command_line}\n"
"failed with the following results:");
DECLARE_MESSAGE(CompressFolderFailed, (msg::path), "", "Failed to compress folder \"{path}\":");
DECLARE_MESSAGE(CopyrightIsDir, (msg::path), "", "`{path}` being a directory is deprecated.");
DECLARE_MESSAGE(CouldNotDeduceNugetIdAndVersion,
(msg::path),
"",
Expand Down
1 change: 1 addition & 0 deletions locales/messages.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"CmakeTargetsExcluded": "note: {count} additional targets are not displayed.",
"CommandFailed": "command:\n{command_line}\nfailed with the following results:",
"CompressFolderFailed": "Failed to compress folder \"{path}\":",
"CopyrightIsDir": "`{path}` being a directory is deprecated.",
"CouldNotDeduceNugetIdAndVersion": "Could not deduce nuget id and version from filename: {path}",
"CreatedNuGetPackage": "Created nupkg: \"{path}\"",
"CurlReportedUnexpectedResults": "curl has reported unexpected results to vcpkg and vcpkg cannot continue.\nPlease review the following text for sensitive information and open an issue on the Microsoft/vcpkg GitHub to help fix this problem!\ncmd: {command_line}\n=== curl output ===\n{actual}\n=== end curl output ===",
Expand Down
2 changes: 2 additions & 0 deletions locales/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
"_CommandFailed.comment": "An example of {command_line} is vcpkg install zlib.",
"CompressFolderFailed": "Failed to compress folder \"{path}\":",
"_CompressFolderFailed.comment": "An example of {path} is /foo/bar.",
"CopyrightIsDir": "`{path}` being a directory is deprecated.",
"_CopyrightIsDir.comment": "An example of {path} is /foo/bar.",
"CouldNotDeduceNugetIdAndVersion": "Could not deduce nuget id and version from filename: {path}",
"_CouldNotDeduceNugetIdAndVersion.comment": "An example of {path} is /foo/bar.",
"CreatedNuGetPackage": "Created nupkg: \"{path}\"",
Expand Down
1 change: 1 addition & 0 deletions src/vcpkg/base/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ namespace vcpkg
REGISTER_MESSAGE(CMakeTargetsUsageHeuristicMessage);
REGISTER_MESSAGE(CMakeToolChainFile);
REGISTER_MESSAGE(CommandFailed);
REGISTER_MESSAGE(CopyrightIsDir);
REGISTER_MESSAGE(CompressFolderFailed);
REGISTER_MESSAGE(CouldNotDeduceNugetIdAndVersion);
REGISTER_MESSAGE(CreatedNuGetPackage);
Expand Down
2 changes: 1 addition & 1 deletion src/vcpkg/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ namespace vcpkg
std::error_code ec;

auto usage_file = installed.usage_file(bpgh.spec);
if (fs.exists(usage_file, IgnoreErrors{}))
if (fs.is_regular_file(usage_file))
{
ret.usage_file = true;
auto contents = fs.read_contents(usage_file, ec);
Expand Down
8 changes: 6 additions & 2 deletions src/vcpkg/postbuildlint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,14 @@ namespace vcpkg::PostBuildLint
{
const auto packages_dir = paths.packages() / spec.dir();
const auto copyright_file = packages_dir / "share" / spec.name() / "copyright";
if (fs.exists(copyright_file, IgnoreErrors{}))

switch (fs.status(copyright_file, IgnoreErrors{}))
{
return LintStatus::SUCCESS;
case FileType::regular: return LintStatus::SUCCESS; break;
case FileType::directory: msg::println_warning(msgCopyrightIsDir, msg::path = "copyright"); break;
default: break;
}

const auto current_buildtrees_dir = paths.build_dir(spec);
const auto current_buildtrees_dir_src = current_buildtrees_dir / "src";

Expand Down

0 comments on commit a8de335

Please sign in to comment.