Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make x-add-version not require changes be committed first. #1616

Merged
merged 8 commits into from
Mar 20, 2025
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
echo 'Hello World!'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "executable-bit",
"version": "1.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"baseline": "1.0",
"port-version": 0
},
"executable-bit": {
"baseline": "1.0",
"port-version": 0
},
"good": {
"baseline": "1.0",
"port-version": 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "6fb9e388021421a5bf6e2cb1f57c67e9ceb6ee43",
"version": "1.0",
"port-version": 0
}
]
}
33 changes: 16 additions & 17 deletions azure-pipelines/end-to-end-tests-dir/ci-verify-versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/ci-verify-versions-registry" "$TestingRoot/ci-verify-versions-registry"
git -C "$TestingRoot/ci-verify-versions-registry" @gitConfigOptions init
git -C "$TestingRoot/ci-verify-versions-registry" @gitConfigOptions add --chmod=+x 'ports/executable-bit/some-script.sh'
Copy link
Member Author

@BillyONeal BillyONeal Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This additional test was added with the change to reuse the existing index done in response to x-ci-verify-versions failing on the real github.com/microsoft/vcpkg. Because I was always making new trees that don't have the git-only-on-Windows-anyway +x bit, the new trees had different SHAs than our version database says, resulting in failures.

In the following message to the team I sent when I just discovered this problem I'm using git diff-tree on some of the openssl trees and ports\openssl\unix\configure shows up because it's got a +x.

(Sorry it's just a screenshot; now that I fixed the problem it'd be annoying to try to recreate the broken behavior and it isn't super important now that it is fixed and has a regression test anyway)

image

git -C "$TestingRoot/ci-verify-versions-registry" @gitConfigOptions add -A
git -C "$TestingRoot/ci-verify-versions-registry" @gitConfigOptions commit -m testing
Move-Item "$TestingRoot/ci-verify-versions-registry/old-port-versions/has-local-edits" "$TestingRoot/ci-verify-versions-registry/ports"

$expected = @"
$TestingRoot/ci-verify-versions-registry/ports/malformed/vcpkg.json:4:3: error: Unexpected character; expected property name
on expression: ~broken
^
$TestingRoot/ci-verify-versions-registry/versions/b-/bad-git-tree.json: error: [email protected] git tree 000000070c5f496fcf1a97cf654d5e81f0d2685a does not match the port directory
$TestingRoot/ci-verify-versions-registry/ports/bad-git-tree: note: the port directory has git tree 6528b2c70c5f496fcf1a97cf654d5e81f0d2685a
$TestingRoot/ci-verify-versions-registry/ports/bad-git-tree/vcpkg.json: note: if [email protected] is already published, update this file with a new version or port-version, commit it, then add the new version by running:
Expand Down Expand Up @@ -41,34 +39,34 @@ note: you can run the following commands to add the current version of baseline-
git add versions
git commit -m `"Update version database`"
$TestingRoot/ci-verify-versions-registry/ports/baseline-version-missing/vcpkg.json: message: all version constraints are consistent with the version database
$TestingRoot/ci-verify-versions-registry/ports/dependency-not-in-versions-database: message: [email protected] is correctly in the version database (321c8b400526dc412a987285ef469eec6221a4b4)
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
$TestingRoot/ci-verify-versions-registry/ports/dependency-not-in-versions-database/vcpkg.json: error: the dependency no-versions does not exist in the version database; does that port exist?
$TestingRoot/ci-verify-versions-registry/ports/dependency-not-in-versions-database-feature: message: [email protected] is correctly in the version database (2298ee25ea54ed92595250a2be07d01bdd76f47c)
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
$TestingRoot/ci-verify-versions-registry/ports/dependency-not-in-versions-database-feature/vcpkg.json: error: the dependency no-versions does not exist in the version database; does that port exist?
note: the dependency is in the feature named add-things
$TestingRoot/ci-verify-versions-registry/ports/dependency-version-not-in-versions-database: message: [email protected] is correctly in the version database (f0d44555fe7714929e432ab9e12a436e28ffef9e)
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
$TestingRoot/ci-verify-versions-registry/ports/dependency-version-not-in-versions-database/vcpkg.json: error: the "version>=" constraint to good names version 0.9 which does not exist in the version database. All versions must exist in the version database to be interpreted by vcpkg.
$TestingRoot/ci-verify-versions-registry/versions/g-/good.json: note: consider removing the version constraint or choosing a value declared here
$TestingRoot/ci-verify-versions-registry/ports/dependency-not-in-versions-database: message: [email protected] is correctly in the version database (321c8b400526dc412a987285ef469eec6221a4b4)
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
$TestingRoot/ci-verify-versions-registry/ports/dependency-not-in-versions-database/vcpkg.json: error: the dependency no-versions does not exist in the version database; does that port exist?
$TestingRoot/ci-verify-versions-registry/ports/dependency-version-not-in-versions-database-feature: message: [email protected] is correctly in the version database (ba3008bb2d42c61f172b7d9592de0212edf20fc6)
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
$TestingRoot/ci-verify-versions-registry/ports/dependency-version-not-in-versions-database-feature/vcpkg.json: error: the "version>=" constraint to good names version 0.9 which does not exist in the version database. All versions must exist in the version database to be interpreted by vcpkg.
$TestingRoot/ci-verify-versions-registry/versions/g-/good.json: note: consider removing the version constraint or choosing a value declared here
note: the dependency is in the feature named add-things
$TestingRoot/ci-verify-versions-registry/ports/dependency-version-not-in-versions-database: message: [email protected] is correctly in the version database (f0d44555fe7714929e432ab9e12a436e28ffef9e)
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
$TestingRoot/ci-verify-versions-registry/ports/dependency-version-not-in-versions-database/vcpkg.json: error: the "version>=" constraint to good names version 0.9 which does not exist in the version database. All versions must exist in the version database to be interpreted by vcpkg.
$TestingRoot/ci-verify-versions-registry/versions/g-/good.json: note: consider removing the version constraint or choosing a value declared here
$TestingRoot/ci-verify-versions-registry/ports/executable-bit: message: [email protected] is correctly in the version database (6fb9e388021421a5bf6e2cb1f57c67e9ceb6ee43)
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
$TestingRoot/ci-verify-versions-registry/ports/executable-bit/vcpkg.json: message: all version constraints are consistent with the version database
$TestingRoot/ci-verify-versions-registry/ports/good: message: [email protected] is correctly in the version database (0f3d67db0dbb6aa5499bc09367a606b495e16d35)
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
$TestingRoot/ci-verify-versions-registry/ports/good/vcpkg.json: message: all version constraints are consistent with the version database
$TestingRoot/ci-verify-versions-registry/ports/has-local-edits/vcpkg.json: error: the git tree of the port directory could not be determined. This is usually caused by uncommitted changes.
note: you can commit your changes and add them to the version database by running:
git add "$TestingRoot/ci-verify-versions-registry/ports/has-local-edits"
git commit -m wip
vcpkg x-add-version has-local-edits
git add versions
git commit --amend -m "[has-local-edits] Add new port"
$TestingRoot/ci-verify-versions-registry/ports/has-local-edits: message: [email protected] is correctly in the version database (b1d7f6030942b329a200f16c931c01e2ec9e1e79)
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
$TestingRoot/ci-verify-versions-registry/ports/has-local-edits/vcpkg.json: message: all version constraints are consistent with the version database
$TestingRoot/ci-verify-versions-registry/ports/malformed/vcpkg.json:4:3: error: Unexpected character; expected property name
on expression: ~broken
^
$TestingRoot/ci-verify-versions-registry/versions/m-/mismatch-git-tree.json: error: [email protected] git tree 41d20d2a02d75343b0933b624faf9f061b112dad does not match the port directory
$TestingRoot/ci-verify-versions-registry/ports/mismatch-git-tree: note: the port directory has git tree 34b3289caaa7a97950828905d354dc971c3c15a7
$TestingRoot/ci-verify-versions-registry/ports/mismatch-git-tree/vcpkg.json: note: if [email protected] is already published, update this file with a new version or port-version, commit it, then add the new version by running:
Expand Down Expand Up @@ -129,6 +127,7 @@ $TestingRoot/ci-verify-versions-registry/versions/d-/dependency-not-in-versions-
$TestingRoot/ci-verify-versions-registry/versions/d-/dependency-not-in-versions-database-feature.json: message: [email protected] is correctly in the version database (2298ee25ea54ed92595250a2be07d01bdd76f47c)
$TestingRoot/ci-verify-versions-registry/versions/d-/dependency-version-not-in-versions-database.json: message: [email protected] is correctly in the version database (f0d44555fe7714929e432ab9e12a436e28ffef9e)
$TestingRoot/ci-verify-versions-registry/versions/d-/dependency-version-not-in-versions-database-feature.json: message: [email protected] is correctly in the version database (ba3008bb2d42c61f172b7d9592de0212edf20fc6)
$TestingRoot/ci-verify-versions-registry/versions/e-/executable-bit.json: message: [email protected] is correctly in the version database (6fb9e388021421a5bf6e2cb1f57c67e9ceb6ee43)
$TestingRoot/ci-verify-versions-registry/versions/g-/good.json: message: [email protected] is correctly in the version database (0f3d67db0dbb6aa5499bc09367a606b495e16d35)
$TestingRoot/ci-verify-versions-registry/versions/h-/has-local-edits.json: message: [email protected] is correctly in the version database (b1d7f6030942b329a200f16c931c01e2ec9e1e79)
$TestingRoot/ci-verify-versions-registry/versions/m-/malformed.json: $buildtreesRoot/versioning_/versions/malformed/a1f22424b0fb1460200c12e1b7933f309f9c8373/vcpkg.json:4:3: error: Unexpected character; expected property name
Expand Down
32 changes: 11 additions & 21 deletions azure-pipelines/end-to-end-tests-dir/versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,52 +82,46 @@ Throw-IfFailed
# Validate port-version
$CurrentTest = "x-add-version octopus"
Set-EmptyTestPort -Name octopus -Version 1.0 -PortVersion "1" -PortsRoot "$versionFilesPath/ports"
git -C $versionFilesPath @gitConfigOptions add -A
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 1.0#1"
$output = Run-VcpkgAndCaptureOutput @portsRedirectArgsOK x-add-version octopus
Throw-IfNotFailed
if ($output -notmatch @"
warning: In octopus, 1.0 is completely new version, so the "port-version" field should be removed. Remove "port-version", commit that change, and try again. To skip this check, rerun with --skip-version-format-check .
warning: In octopus, 1.0 is a completely new version, so there should be no "port-version". Remove "port-version" and try again. To skip this check, rerun with --skip-version-format-check .
"@) {
throw "Expected detecting present port-version when a new version is added as bad"
throw "Expected detecting present port-version when a new version is added as bad"
}

Run-Vcpkg @portsRedirectArgsOK x-add-version octopus --skip-version-format-check
Throw-IfFailed
git -C $versionFilesPath @gitConfigOptions add -A
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 1.0#1 to version database"
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 1.0#1"

Set-EmptyTestPort -Name octopus -Version 2.0 -PortVersion "1" -PortsRoot "$versionFilesPath/ports"
git -C $versionFilesPath @gitConfigOptions add -A
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#1"
$output = Run-VcpkgAndCaptureOutput @portsRedirectArgsOK x-add-version octopus
Throw-IfNotFailed
if ($output -notmatch @"
warning: In octopus, 2.0 is completely new version, so the "port-version" field should be removed. Remove "port-version", commit that change, and try again. To skip this check, rerun with --skip-version-format-check .
warning: In octopus, 2.0 is a completely new version, so there should be no "port-version". Remove "port-version" and try again. To skip this check, rerun with --skip-version-format-check .
"@) {
throw "Expected detecting present port-version when a new version is added as bad"
throw "Expected detecting present port-version when a new version is added as bad"
}

Run-Vcpkg @portsRedirectArgsOK x-add-version octopus --skip-version-format-check
Throw-IfFailed
git -C $versionFilesPath @gitConfigOptions add -A
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#1 to version database"
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#1"

Set-EmptyTestPort -Name octopus -Version 2.0 -PortVersion "3" -PortsRoot "$versionFilesPath/ports"
git -C $versionFilesPath @gitConfigOptions add -A
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#3"
$output = Run-VcpkgAndCaptureOutput @portsRedirectArgsOK x-add-version octopus
Throw-IfNotFailed
if ($output -notmatch @"
warning: In octopus, the current "port-version" for 2.0 is 1, so the next added "port-version" should be 2, but the port declares "port-version" 3. Change "port-version" to 2, commit that change, and try again. To skip this check, rerun with --skip-version-format-check .
warning: In octopus, the current "port-version" for 2.0 is 1, so the expected new "port-version" is 2, but the port declares "port-version" 3. Change "port-version" to 2 and try again. To skip this check, rerun with --skip-version-format-check .
"@) {
throw "Expected detecting present port-version when a new version is added as bad"
throw "Expected detecting present port-version when a new version is added as bad"
}

Run-Vcpkg @portsRedirectArgsOK x-add-version octopus --skip-version-format-check
Throw-IfFailed
git -C $versionFilesPath @gitConfigOptions add -A
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#3 to version database"
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#3"

$CurrentTest = "default baseline"
$out = Run-VcpkgAndCaptureOutput @commonArgs "--feature-flags=versions" install --x-manifest-root=$versionFilesPath/default-baseline-1
Expand All @@ -149,21 +143,17 @@ if (($out -notmatch ".*error: Failed to load port because versions are inconsist

Write-Trace "testing baselines"
Copy-Item -Recurse "$versionFilesPath/old-ports/zlib-1.2.11-8" "$versionFilesPath/ports/zlib"
git -C $versionFilesPath @gitConfigOptions add -A
git -C $versionFilesPath @gitConfigOptions commit -m "set zlib-1.2.11-8"
Run-Vcpkg @portsRedirectArgsOK x-add-version zlib
Throw-IfFailed
git -C $versionFilesPath @gitConfigOptions add -A
git -C $versionFilesPath @gitConfigOptions commit -m "add zlib-1.2.11-8 to version database"
git -C $versionFilesPath @gitConfigOptions commit -m "set zlib-1.2.11-8"
$baselineSha = git -C $versionFilesPath @gitConfigOptions rev-parse HEAD
Remove-Item -Recurse -Force -LiteralPath "$versionFilesPath/ports/zlib"
Copy-Item -Recurse "$versionFilesPath/old-ports/zlib-1.2.11-9" "$versionFilesPath/ports/zlib"
git -C $versionFilesPath @gitConfigOptions add -A
git -C $versionFilesPath @gitConfigOptions commit -m "set zlib-1.2.11-9"
Run-Vcpkg @portsRedirectArgsOK x-add-version zlib
Throw-IfFailed
git -C $versionFilesPath @gitConfigOptions add -A
git -C $versionFilesPath @gitConfigOptions commit -m "add zlib-1.2.11-9 to version database"
git -C $versionFilesPath @gitConfigOptions commit -m "set zlib-1.2.11-9"

$CurrentTest = "without default baseline 2 -- enabling versions should not change behavior"
Remove-Item -Recurse $buildtreesRoot/versioning_ -ErrorAction SilentlyContinue
Expand Down
16 changes: 2 additions & 14 deletions include/vcpkg/base/diagnostics.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <vcpkg/base/fwd/diagnostics.h>

#include <vcpkg/base/expected.h>
#include <vcpkg/base/message_sinks.h>
#include <vcpkg/base/messages.h>
Expand All @@ -12,16 +14,6 @@

namespace vcpkg
{
enum class DiagKind
{
None, // foo.h: localized
Message, // foo.h: message: localized
Error, // foo.h: error: localized
Warning, // foo.h: warning: localized
Note, // foo.h: note: localized
COUNT
};

struct TextRowCol
{
// '0' indicates that line and column information is unknown; '1' is the first row/column
Expand Down Expand Up @@ -242,10 +234,6 @@ namespace vcpkg
DiagnosticContext& inner_context;
};

extern DiagnosticContext& console_diagnostic_context;
extern DiagnosticContext& status_only_diagnostic_context;
extern DiagnosticContext& null_diagnostic_context;

// The following overloads are implementing
// adapt_context_to_expected(Fn functor, Args&&... args)
//
Expand Down
21 changes: 21 additions & 0 deletions include/vcpkg/base/files.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#pragma once

#include <vcpkg/base/fwd/diagnostics.h>
#include <vcpkg/base/fwd/files.h>
#include <vcpkg/base/fwd/fmt.h>
#include <vcpkg/base/fwd/message_sinks.h>
#include <vcpkg/base/fwd/optional.h>
#include <vcpkg/base/fwd/span.h>

#include <vcpkg/base/checks.h>
Expand Down Expand Up @@ -300,6 +302,10 @@ namespace vcpkg
CopyOptions options,
std::error_code& ec) const = 0;
bool copy_file(const Path& source, const Path& destination, CopyOptions options, LineInfo li) const;
Optional<bool> copy_file(DiagnosticContext& context,
const Path& source,
const Path& destination,
CopyOptions options) const;

virtual void copy_symlink(const Path& source, const Path& destination, std::error_code& ec) const = 0;
void copy_symlink(const Path& source, const Path& destination, LineInfo li) const;
Expand Down Expand Up @@ -369,6 +375,21 @@ namespace vcpkg
#if !defined(_WIN32)
void close_mark_invalid(int& fd) noexcept;
#endif // ^^^ !_WIN32

struct TempFileDeleter
{
explicit TempFileDeleter(const Filesystem& fs, const Path& path);

TempFileDeleter(TempFileDeleter&&) = delete;
TempFileDeleter(const TempFileDeleter&) = delete;

~TempFileDeleter();

const Path path;

private:
const Filesystem& m_fs;
};
}

VCPKG_FORMAT_AS(vcpkg::Path, vcpkg::StringView);
27 changes: 27 additions & 0 deletions include/vcpkg/base/fwd/diagnostics.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

namespace vcpkg
{
enum class DiagKind
{
None, // foo.h: localized
Message, // foo.h: message: localized
Error, // foo.h: error: localized
Warning, // foo.h: warning: localized
Note, // foo.h: note: localized
COUNT
};

struct TextRowCol;
struct DiagnosticLine;
struct DiagnosticContext;
struct PrintingDiagnosticContext;
struct BufferedDiagnosticContext;
struct FullyBufferedDiagnosticContext;
struct AttemptDiagnosticContext;
struct WarningDiagnosticContext;

extern DiagnosticContext& console_diagnostic_context;
extern DiagnosticContext& status_only_diagnostic_context;
extern DiagnosticContext& null_diagnostic_context;
}
1 change: 1 addition & 0 deletions include/vcpkg/base/fwd/git.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
namespace vcpkg
{
struct GitConfig;
struct GitLSTreeEntry;
}
Loading