Skip to content
Draft
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9d0b2dd
Add command `lint-port`
autoantwort Sep 28, 2022
c5d5557
CR
autoantwort Sep 29, 2022
32ef8e0
fix bug
autoantwort Sep 30, 2022
689e47d
Adopt tests
autoantwort Sep 30, 2022
7a5a5bd
Merge branch 'main' into feature/lint-port
autoantwort Oct 25, 2022
4cae60d
Merge branch 'main' into feature/lint-port
autoantwort Nov 2, 2022
bfe12fe
Fix warning
autoantwort Nov 2, 2022
1bad290
Fix test
autoantwort Nov 2, 2022
d3668f3
Fix e2e tests
autoantwort Nov 2, 2022
c48fb10
Fix windows
autoantwort Nov 2, 2022
23a7459
Ignore more wrong ports
autoantwort Nov 5, 2022
6795b99
Merge branch 'main' into feature/lint-port
autoantwort Nov 10, 2022
a890651
Merge branch 'main' into feature/lint-port
autoantwort Nov 12, 2022
b0b4495
Apply format diff
autoantwort Nov 13, 2022
38b2a69
Merge branch 'main' into feature/lint-port
autoantwort Nov 25, 2022
686a36f
Make code more unit testable
autoantwort Nov 25, 2022
04ba447
Add helpers to MessageSink
autoantwort Nov 26, 2022
ea500f5
Apply code review and add tests
autoantwort Nov 26, 2022
8f56f8e
Replace usages of vcpkg_extract_source_archive_ex
autoantwort Nov 27, 2022
9e85bdd
format diff
autoantwort Nov 27, 2022
a8b28ea
Also replace REF with SOURCE_BASE in vcpkg_extract_source_archive
autoantwort Nov 29, 2022
7f2c55a
Fix Bug
autoantwort Nov 29, 2022
4e17669
Merge branch 'main' into feature/lint-port
autoantwort Dec 9, 2022
d967f73
Apply diff
autoantwort Dec 12, 2022
054858c
PACKAGE_NAME must also be used if the package name casing is different
autoantwort Dec 17, 2022
2b95b50
Format
autoantwort Dec 19, 2022
c320e6c
Revert "PACKAGE_NAME must also be used if the package name casing is …
autoantwort Dec 20, 2022
ed44a8d
Use functions to simplify code
autoantwort Dec 21, 2022
9eaf07d
Also check for vcpkg_check_features without FEATURES keyword
autoantwort Dec 21, 2022
d2d792d
Merge branch 'main' into feature/lint-port
autoantwort Jan 11, 2023
dbfd782
Add message file changes
autoantwort Jan 11, 2023
2ab739f
Merge branch 'main' into feature/lint-port
autoantwort Jan 13, 2023
68e6756
Fix command name
autoantwort Jan 29, 2023
a6f2608
Merge branch 'main' into feature/lint-port
autoantwort Feb 9, 2023
53df38b
Merge branch 'main' into feature/lint-port
autoantwort Feb 28, 2023
ee0fda1
Merge branch 'main' into feature/lint-port
autoantwort Mar 14, 2023
83b13a9
Improve performance
autoantwort Mar 14, 2023
89208e9
Merge branch 'main' into feature/lint-port
autoantwort Mar 19, 2023
0c5c4f1
Merge branch 'main' into feature/lint-port
autoantwort Apr 6, 2023
4cdcb30
Add missing include
autoantwort Apr 6, 2023
14f1b1f
Use right command arguments
autoantwort Apr 12, 2023
f596c5a
Merge branch 'main' into feature/lint-port
autoantwort Apr 26, 2023
53e95f4
Merge branch 'main' into feature/lint-port
autoantwort May 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion azure-pipelines/end-to-end-tests-dir/format-manifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $testProjects | % {
Write-Trace "test that format-manifest on $full produces $expectedPath"
[string]$expected = Get-Content $expectedPath -Raw
Copy-Item $asItem $tempItemPath
Run-Vcpkg format-manifest $tempItemPath
Run-Vcpkg format-manifest $tempItemPath | Out-Null
$actual = Get-Content $tempItemPath -Raw
if ($expected -ne $actual) {
throw "Expected formatting $full to produce $expectedPath but was $tempItemPath"
Expand All @@ -25,6 +25,9 @@ New-Item -Path $manifestDir -ItemType Directory | Out-Null
$ports = Get-ChildItem "$env:VCPKG_ROOT/ports"

$ports | % {
if (($_ | Split-Path -leaf) -in @("libuvc", "mlpack", "qt5-virtualkeyboard", "qtwebengine", "vamp-sdk")) {
return
}
Copy-Item "$_/vcpkg.json" "$manifestDir" | Out-Null
$x = Get-Content "$manifestDir/vcpkg.json" -Raw
Run-Vcpkg -EndToEndTestSilent format-manifest "$manifestDir/vcpkg.json" | Out-Null
Expand Down
14 changes: 7 additions & 7 deletions azure-pipelines/end-to-end-tests-dir/versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,35 @@ Throw-IfNotFailed

$CurrentTest = "x-add-version cat"
# Do not fail if there's nothing to update
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version cat
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version --skip-license-check cat
Throw-IfFailed

$CurrentTest = "x-add-version dog"
# Local version is not in baseline and versions file
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version dog
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version --skip-license-check dog
Throw-IfFailed

$CurrentTest = "x-add-version duck"
# Missing versions file
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version duck
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version --skip-license-check duck
Throw-IfFailed

$CurrentTest = "x-add-version ferret"
# Missing versions file and missing baseline entry
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version ferret
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version --skip-license-check ferret
Throw-IfFailed

$CurrentTest = "x-add-version fish (must fail)"
# Discrepancy between local SHA and SHA in fish.json. Requires --overwrite-version.
$out = Run-Vcpkg @portsRedirectArgsIncomplete x-add-version fish
$out = Run-Vcpkg @portsRedirectArgsIncomplete x-add-version --skip-license-check fish
Throw-IfNotFailed
$CurrentTest = "x-add-version fish --overwrite-version"
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version fish --overwrite-version --skip-version-format-check
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version fish --overwrite-version --skip-version-format-check --skip-license-check
Throw-IfFailed

$CurrentTest = "x-add-version mouse"
# Missing baseline entry
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version mouse
Run-Vcpkg @portsRedirectArgsIncomplete x-add-version --skip-license-check mouse
Throw-IfFailed
# Validate changes
Run-Vcpkg @portsRedirectArgsIncomplete x-ci-verify-versions --verbose
Expand Down
45 changes: 41 additions & 4 deletions include/vcpkg/base/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,20 @@ namespace vcpkg
(),
"",
"skipping detection of local changes due to unexpected format in git status output");
DECLARE_MESSAGE(AddVersionDisableCheck,
(msg::option),
"The -- before {option} must be preserved as they're part of the help message for the user.",
"Use --{option} to disable this check.");
DECLARE_MESSAGE(AddVersionFileNotFound, (msg::path), "", "couldn't find required file {path}");
DECLARE_MESSAGE(AddVersionFormatPortSuggestion, (msg::command_line), "", "Run `{command_line}` to format the file");
DECLARE_MESSAGE(AddVersionIgnoringOptionAll,
(msg::option),
"The -- before {option} must be preserved as they're part of the help message for the user.",
"ignoring --{option} since a port name argument was provided");
DECLARE_MESSAGE(AddVersionLintPort,
(msg::package_name),
"",
"You can run `./vcpkg x-lint-port --fix {package_name}` to fix these issues.");
DECLARE_MESSAGE(AddVersionLoadPortFailed, (msg::package_name), "", "can't load port {package_name}");
DECLARE_MESSAGE(AddVersionNewFile, (), "", "(new file)");
DECLARE_MESSAGE(AddVersionNewShaIs, (msg::value), "{value} is a 40-digit hexadecimal SHA", "new SHA: {value}");
Expand Down Expand Up @@ -522,11 +530,40 @@ namespace vcpkg
(msg::package_name),
"",
"{package_name} is not properly formatted");
DECLARE_MESSAGE(AddVersionSuggestNewVersionScheme,
(msg::new_scheme, msg::old_scheme, msg::package_name, msg::option),
"The -- before {option} must be preserved as they're part of the help message for the user.",
DECLARE_MESSAGE(
LintDeprecatedFunction,
(msg::package_name, msg::actual, msg::expected),
"{actual} is the currently used deprecated function, {expected} is the function that should be used",
"The deprecated function \"{actual}\" is used inside the port \"{package_name}\". Use the function "
"\"{expected}\" instead.");
DECLARE_MESSAGE(
LintDeprecatedLicenseExpressionWithReplacement,
(msg::package_name, msg::actual, msg::new_value),
"{actual} is the currently used license and {new_value} is the license expression that should be used",
"The port \"{package_name}\" uses the deprecated license expression \"{actual}\". You shoud use the non "
"deprecated version \"{new_value}\".");
DECLARE_MESSAGE(LintDeprecatedLicenseExpressionWithoutReplacement,
(msg::package_name, msg::actual),
"{actual} is the currently used license",
"The port \"{package_name}\" uses the deprecated license expression \"{actual}\".");
DECLARE_MESSAGE(LintMissingLicenseExpression,
(msg::package_name),
"",
"There is no license expression in port \"{package_name}\". You could use "
"https://tools.spdx.org/app/check_license/ to determine the right license expression.");
DECLARE_MESSAGE(LintSuggestNewVersionScheme,
(msg::new_scheme, msg::old_scheme, msg::package_name),
"",
"Use the version scheme \"{new_scheme}\" instead of \"{old_scheme}\" in port "
"\"{package_name}\".\nUse --{option} to disable this check.");
"\"{package_name}\".");
DECLARE_MESSAGE(LintPortErrorsFixed,
(msg::package_name),
"",
"Problems in the port \"{package_name}\" have been fixed.");
DECLARE_MESSAGE(LintPortErrors,
(msg::package_name),
"",
"The port \"{package_name}\" should be fixed. See warning(s) above.");
DECLARE_MESSAGE(AddVersionUnableToParseVersionsFile, (msg::path), "", "unable to parse versions file {path}");
DECLARE_MESSAGE(AddVersionUncommittedChanges,
(msg::package_name),
Expand Down
13 changes: 13 additions & 0 deletions include/vcpkg/commands.lint-port.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <vcpkg/commands.interface.h>

namespace vcpkg::Commands::LintPort
{
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths);

struct LintPortCommand : PathsCommand
{
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) const override;
};
}
35 changes: 35 additions & 0 deletions include/vcpkg/portlint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <vcpkg/base/fwd/files.h>
#include <vcpkg/base/fwd/stringview.h>

#include <vcpkg/fwd/packagespec.h>
#include <vcpkg/fwd/triplet.h>
#include <vcpkg/fwd/vcpkgpaths.h>

#include <vcpkg/sourceparagraph.h>

namespace vcpkg::Lint
{
enum class Status : int
{
Ok = 0b0,
Problem = 0b01,
Fixed = 0b10,
PartiallyFixed = 0b11
};
Comment thread
autoantwort marked this conversation as resolved.

Status& operator|=(Status& self, Status s);

enum class Fix
{
NO = 0, // A warning message is printed for every found problem
YES // The problem is fixed in place (SourceControlFile) and no message is printed
};

Status check_used_version_scheme(SourceControlFile& scf, Fix fix);

Status check_license_expression(SourceControlFile& scf, Fix fix);

Status check_portfile_deprecated_functions(Filesystem& fs, SourceControlFileAndLocation& scf, Fix fix);
}
2 changes: 2 additions & 0 deletions include/vcpkg/sourceparagraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ namespace vcpkg
}
VersionSpec to_version_spec() const { return {core_paragraph->name, core_paragraph->to_version()}; }

std::unique_ptr<ParseControlErrorInfo> canonicalize();

friend bool operator==(const SourceControlFile& lhs, const SourceControlFile& rhs);
friend bool operator!=(const SourceControlFile& lhs, const SourceControlFile& rhs) { return !(lhs == rhs); }
};
Expand Down
Loading