Skip to content

Commit b38768e

Browse files
authored
Make x-add-version not require changes be committed first. (#1616)
1 parent 418bd01 commit b38768e

23 files changed

+392
-309
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
echo 'Hello World!'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "executable-bit",
3+
"version": "1.0"
4+
}

azure-pipelines/e2e-assets/ci-verify-versions-registry/versions/baseline.json

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
"baseline": "1.0",
3333
"port-version": 0
3434
},
35+
"executable-bit": {
36+
"baseline": "1.0",
37+
"port-version": 0
38+
},
3539
"good": {
3640
"baseline": "1.0",
3741
"port-version": 0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"versions": [
3+
{
4+
"git-tree": "6fb9e388021421a5bf6e2cb1f57c67e9ceb6ee43",
5+
"version": "1.0",
6+
"port-version": 0
7+
}
8+
]
9+
}

azure-pipelines/end-to-end-tests-dir/ci-verify-versions.ps1

+16-17
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
Copy-Item -Recurse "$PSScriptRoot/../e2e-assets/ci-verify-versions-registry" "$TestingRoot/ci-verify-versions-registry"
44
git -C "$TestingRoot/ci-verify-versions-registry" @gitConfigOptions init
5+
git -C "$TestingRoot/ci-verify-versions-registry" @gitConfigOptions add --chmod=+x 'ports/executable-bit/some-script.sh'
56
git -C "$TestingRoot/ci-verify-versions-registry" @gitConfigOptions add -A
67
git -C "$TestingRoot/ci-verify-versions-registry" @gitConfigOptions commit -m testing
78
Move-Item "$TestingRoot/ci-verify-versions-registry/old-port-versions/has-local-edits" "$TestingRoot/ci-verify-versions-registry/ports"
89

910
$expected = @"
10-
$TestingRoot/ci-verify-versions-registry/ports/malformed/vcpkg.json:4:3: error: Unexpected character; expected property name
11-
on expression: ~broken
12-
^
1311
$TestingRoot/ci-verify-versions-registry/versions/b-/bad-git-tree.json: error: [email protected] git tree 000000070c5f496fcf1a97cf654d5e81f0d2685a does not match the port directory
1412
$TestingRoot/ci-verify-versions-registry/ports/bad-git-tree: note: the port directory has git tree 6528b2c70c5f496fcf1a97cf654d5e81f0d2685a
1513
$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:
@@ -41,34 +39,34 @@ note: you can run the following commands to add the current version of baseline-
4139
git add versions
4240
git commit -m `"Update version database`"
4341
$TestingRoot/ci-verify-versions-registry/ports/baseline-version-missing/vcpkg.json: message: all version constraints are consistent with the version database
44-
$TestingRoot/ci-verify-versions-registry/ports/dependency-not-in-versions-database: message: [email protected] is correctly in the version database (321c8b400526dc412a987285ef469eec6221a4b4)
45-
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
46-
$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?
4742
$TestingRoot/ci-verify-versions-registry/ports/dependency-not-in-versions-database-feature: message: [email protected] is correctly in the version database (2298ee25ea54ed92595250a2be07d01bdd76f47c)
4843
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
4944
$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?
5045
note: the dependency is in the feature named add-things
51-
$TestingRoot/ci-verify-versions-registry/ports/dependency-version-not-in-versions-database: message: [email protected] is correctly in the version database (f0d44555fe7714929e432ab9e12a436e28ffef9e)
52-
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
53-
$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.
54-
$TestingRoot/ci-verify-versions-registry/versions/g-/good.json: note: consider removing the version constraint or choosing a value declared here
46+
$TestingRoot/ci-verify-versions-registry/ports/dependency-not-in-versions-database: message: [email protected] is correctly in the version database (321c8b400526dc412a987285ef469eec6221a4b4)
47+
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
48+
$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?
5549
$TestingRoot/ci-verify-versions-registry/ports/dependency-version-not-in-versions-database-feature: message: [email protected] is correctly in the version database (ba3008bb2d42c61f172b7d9592de0212edf20fc6)
5650
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
5751
$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.
5852
$TestingRoot/ci-verify-versions-registry/versions/g-/good.json: note: consider removing the version constraint or choosing a value declared here
5953
note: the dependency is in the feature named add-things
54+
$TestingRoot/ci-verify-versions-registry/ports/dependency-version-not-in-versions-database: message: [email protected] is correctly in the version database (f0d44555fe7714929e432ab9e12a436e28ffef9e)
55+
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
56+
$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.
57+
$TestingRoot/ci-verify-versions-registry/versions/g-/good.json: note: consider removing the version constraint or choosing a value declared here
58+
$TestingRoot/ci-verify-versions-registry/ports/executable-bit: message: [email protected] is correctly in the version database (6fb9e388021421a5bf6e2cb1f57c67e9ceb6ee43)
59+
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
60+
$TestingRoot/ci-verify-versions-registry/ports/executable-bit/vcpkg.json: message: all version constraints are consistent with the version database
6061
$TestingRoot/ci-verify-versions-registry/ports/good: message: [email protected] is correctly in the version database (0f3d67db0dbb6aa5499bc09367a606b495e16d35)
6162
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
6263
$TestingRoot/ci-verify-versions-registry/ports/good/vcpkg.json: message: all version constraints are consistent with the version database
63-
$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.
64-
note: you can commit your changes and add them to the version database by running:
65-
git add "$TestingRoot/ci-verify-versions-registry/ports/has-local-edits"
66-
git commit -m wip
67-
vcpkg x-add-version has-local-edits
68-
git add versions
69-
git commit --amend -m "[has-local-edits] Add new port"
64+
$TestingRoot/ci-verify-versions-registry/ports/has-local-edits: message: [email protected] is correctly in the version database (b1d7f6030942b329a200f16c931c01e2ec9e1e79)
7065
$TestingRoot/ci-verify-versions-registry/versions/baseline.json: message: [email protected] matches the current baseline
7166
$TestingRoot/ci-verify-versions-registry/ports/has-local-edits/vcpkg.json: message: all version constraints are consistent with the version database
67+
$TestingRoot/ci-verify-versions-registry/ports/malformed/vcpkg.json:4:3: error: Unexpected character; expected property name
68+
on expression: ~broken
69+
^
7270
$TestingRoot/ci-verify-versions-registry/versions/m-/mismatch-git-tree.json: error: [email protected] git tree 41d20d2a02d75343b0933b624faf9f061b112dad does not match the port directory
7371
$TestingRoot/ci-verify-versions-registry/ports/mismatch-git-tree: note: the port directory has git tree 34b3289caaa7a97950828905d354dc971c3c15a7
7472
$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:
@@ -129,6 +127,7 @@ $TestingRoot/ci-verify-versions-registry/versions/d-/dependency-not-in-versions-
129127
$TestingRoot/ci-verify-versions-registry/versions/d-/dependency-not-in-versions-database-feature.json: message: [email protected] is correctly in the version database (2298ee25ea54ed92595250a2be07d01bdd76f47c)
130128
$TestingRoot/ci-verify-versions-registry/versions/d-/dependency-version-not-in-versions-database.json: message: [email protected] is correctly in the version database (f0d44555fe7714929e432ab9e12a436e28ffef9e)
131129
$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)
130+
$TestingRoot/ci-verify-versions-registry/versions/e-/executable-bit.json: message: [email protected] is correctly in the version database (6fb9e388021421a5bf6e2cb1f57c67e9ceb6ee43)
132131
$TestingRoot/ci-verify-versions-registry/versions/g-/good.json: message: [email protected] is correctly in the version database (0f3d67db0dbb6aa5499bc09367a606b495e16d35)
133132
$TestingRoot/ci-verify-versions-registry/versions/h-/has-local-edits.json: message: [email protected] is correctly in the version database (b1d7f6030942b329a200f16c931c01e2ec9e1e79)
134133
$TestingRoot/ci-verify-versions-registry/versions/m-/malformed.json: $buildtreesRoot/versioning_/versions/malformed/a1f22424b0fb1460200c12e1b7933f309f9c8373/vcpkg.json:4:3: error: Unexpected character; expected property name

azure-pipelines/end-to-end-tests-dir/versions.ps1

+11-21
Original file line numberDiff line numberDiff line change
@@ -82,52 +82,46 @@ Throw-IfFailed
8282
# Validate port-version
8383
$CurrentTest = "x-add-version octopus"
8484
Set-EmptyTestPort -Name octopus -Version 1.0 -PortVersion "1" -PortsRoot "$versionFilesPath/ports"
85-
git -C $versionFilesPath @gitConfigOptions add -A
86-
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 1.0#1"
8785
$output = Run-VcpkgAndCaptureOutput @portsRedirectArgsOK x-add-version octopus
8886
Throw-IfNotFailed
8987
if ($output -notmatch @"
90-
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 .
88+
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 .
9189
"@) {
92-
throw "Expected detecting present port-version when a new version is added as bad"
90+
throw "Expected detecting present port-version when a new version is added as bad"
9391
}
9492

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

10098
Set-EmptyTestPort -Name octopus -Version 2.0 -PortVersion "1" -PortsRoot "$versionFilesPath/ports"
101-
git -C $versionFilesPath @gitConfigOptions add -A
102-
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#1"
10399
$output = Run-VcpkgAndCaptureOutput @portsRedirectArgsOK x-add-version octopus
104100
Throw-IfNotFailed
105101
if ($output -notmatch @"
106-
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 .
102+
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 .
107103
"@) {
108-
throw "Expected detecting present port-version when a new version is added as bad"
104+
throw "Expected detecting present port-version when a new version is added as bad"
109105
}
110106

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

116112
Set-EmptyTestPort -Name octopus -Version 2.0 -PortVersion "3" -PortsRoot "$versionFilesPath/ports"
117-
git -C $versionFilesPath @gitConfigOptions add -A
118-
git -C $versionFilesPath @gitConfigOptions commit -m "add octopus 2.0#3"
119113
$output = Run-VcpkgAndCaptureOutput @portsRedirectArgsOK x-add-version octopus
120114
Throw-IfNotFailed
121115
if ($output -notmatch @"
122-
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 .
116+
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 .
123117
"@) {
124-
throw "Expected detecting present port-version when a new version is added as bad"
118+
throw "Expected detecting present port-version when a new version is added as bad"
125119
}
126120

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

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

150144
Write-Trace "testing baselines"
151145
Copy-Item -Recurse "$versionFilesPath/old-ports/zlib-1.2.11-8" "$versionFilesPath/ports/zlib"
152-
git -C $versionFilesPath @gitConfigOptions add -A
153-
git -C $versionFilesPath @gitConfigOptions commit -m "set zlib-1.2.11-8"
154146
Run-Vcpkg @portsRedirectArgsOK x-add-version zlib
155147
Throw-IfFailed
156148
git -C $versionFilesPath @gitConfigOptions add -A
157-
git -C $versionFilesPath @gitConfigOptions commit -m "add zlib-1.2.11-8 to version database"
149+
git -C $versionFilesPath @gitConfigOptions commit -m "set zlib-1.2.11-8"
158150
$baselineSha = git -C $versionFilesPath @gitConfigOptions rev-parse HEAD
159151
Remove-Item -Recurse -Force -LiteralPath "$versionFilesPath/ports/zlib"
160152
Copy-Item -Recurse "$versionFilesPath/old-ports/zlib-1.2.11-9" "$versionFilesPath/ports/zlib"
161-
git -C $versionFilesPath @gitConfigOptions add -A
162-
git -C $versionFilesPath @gitConfigOptions commit -m "set zlib-1.2.11-9"
163153
Run-Vcpkg @portsRedirectArgsOK x-add-version zlib
164154
Throw-IfFailed
165155
git -C $versionFilesPath @gitConfigOptions add -A
166-
git -C $versionFilesPath @gitConfigOptions commit -m "add zlib-1.2.11-9 to version database"
156+
git -C $versionFilesPath @gitConfigOptions commit -m "set zlib-1.2.11-9"
167157

168158
$CurrentTest = "without default baseline 2 -- enabling versions should not change behavior"
169159
Remove-Item -Recurse $buildtreesRoot/versioning_ -ErrorAction SilentlyContinue

include/vcpkg/base/diagnostics.h

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <vcpkg/base/fwd/diagnostics.h>
4+
35
#include <vcpkg/base/expected.h>
46
#include <vcpkg/base/message_sinks.h>
57
#include <vcpkg/base/messages.h>
@@ -12,16 +14,6 @@
1214

1315
namespace vcpkg
1416
{
15-
enum class DiagKind
16-
{
17-
None, // foo.h: localized
18-
Message, // foo.h: message: localized
19-
Error, // foo.h: error: localized
20-
Warning, // foo.h: warning: localized
21-
Note, // foo.h: note: localized
22-
COUNT
23-
};
24-
2517
struct TextRowCol
2618
{
2719
// '0' indicates that line and column information is unknown; '1' is the first row/column
@@ -242,10 +234,6 @@ namespace vcpkg
242234
DiagnosticContext& inner_context;
243235
};
244236

245-
extern DiagnosticContext& console_diagnostic_context;
246-
extern DiagnosticContext& status_only_diagnostic_context;
247-
extern DiagnosticContext& null_diagnostic_context;
248-
249237
// The following overloads are implementing
250238
// adapt_context_to_expected(Fn functor, Args&&... args)
251239
//

include/vcpkg/base/files.h

+21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#pragma once
22

3+
#include <vcpkg/base/fwd/diagnostics.h>
34
#include <vcpkg/base/fwd/files.h>
45
#include <vcpkg/base/fwd/fmt.h>
56
#include <vcpkg/base/fwd/message_sinks.h>
7+
#include <vcpkg/base/fwd/optional.h>
68
#include <vcpkg/base/fwd/span.h>
79

810
#include <vcpkg/base/checks.h>
@@ -300,6 +302,10 @@ namespace vcpkg
300302
CopyOptions options,
301303
std::error_code& ec) const = 0;
302304
bool copy_file(const Path& source, const Path& destination, CopyOptions options, LineInfo li) const;
305+
Optional<bool> copy_file(DiagnosticContext& context,
306+
const Path& source,
307+
const Path& destination,
308+
CopyOptions options) const;
303309

304310
virtual void copy_symlink(const Path& source, const Path& destination, std::error_code& ec) const = 0;
305311
void copy_symlink(const Path& source, const Path& destination, LineInfo li) const;
@@ -369,6 +375,21 @@ namespace vcpkg
369375
#if !defined(_WIN32)
370376
void close_mark_invalid(int& fd) noexcept;
371377
#endif // ^^^ !_WIN32
378+
379+
struct TempFileDeleter
380+
{
381+
explicit TempFileDeleter(const Filesystem& fs, const Path& path);
382+
383+
TempFileDeleter(TempFileDeleter&&) = delete;
384+
TempFileDeleter(const TempFileDeleter&) = delete;
385+
386+
~TempFileDeleter();
387+
388+
const Path path;
389+
390+
private:
391+
const Filesystem& m_fs;
392+
};
372393
}
373394

374395
VCPKG_FORMAT_AS(vcpkg::Path, vcpkg::StringView);

include/vcpkg/base/fwd/diagnostics.h

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#pragma once
2+
3+
namespace vcpkg
4+
{
5+
enum class DiagKind
6+
{
7+
None, // foo.h: localized
8+
Message, // foo.h: message: localized
9+
Error, // foo.h: error: localized
10+
Warning, // foo.h: warning: localized
11+
Note, // foo.h: note: localized
12+
COUNT
13+
};
14+
15+
struct TextRowCol;
16+
struct DiagnosticLine;
17+
struct DiagnosticContext;
18+
struct PrintingDiagnosticContext;
19+
struct BufferedDiagnosticContext;
20+
struct FullyBufferedDiagnosticContext;
21+
struct AttemptDiagnosticContext;
22+
struct WarningDiagnosticContext;
23+
24+
extern DiagnosticContext& console_diagnostic_context;
25+
extern DiagnosticContext& status_only_diagnostic_context;
26+
extern DiagnosticContext& null_diagnostic_context;
27+
}

include/vcpkg/base/fwd/git.h

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
namespace vcpkg
44
{
55
struct GitConfig;
6+
struct GitLSTreeEntry;
67
}

0 commit comments

Comments
 (0)