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

BREAKING CHANGE: Amend version identifier in ID #24

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Extensions can be removed from the marketplace by ID and version or `--all` to
remove all versions.

```console
./code-marketplace remove ms-python.python-2022.14.0 [flags]
./code-marketplace remove ms-python.python@2022.14.0 [flags]
./code-marketplace remove ms-python.python --all [flags]
```

Expand Down
4 changes: 2 additions & 2 deletions cli/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func remove() *cobra.Command {
Use: "remove <id>",
Short: "Remove an extension from the marketplace",
Example: strings.Join([]string{
" marketplace remove publisher.extension-1.0.0 --extensions-dir ./extensions",
" marketplace remove publisher.extension@1.0.0 --extensions-dir ./extensions",
" marketplace remove publisher.extension --all --artifactory http://artifactory.server/artifactory --repo extensions",
}, "\n"),
Args: cobra.ExactArgs(1),
Expand Down Expand Up @@ -78,7 +78,7 @@ func remove() *cobra.Command {
return xerrors.Errorf("%s.%s has no versions to delete", publisher, name)
} else if version == "" && !all {
return xerrors.Errorf(
"use %s-<version> to target a specific version or pass --all to delete %s of %s",
"use %s@<version> to target a specific version or pass --all to delete %s of %s",
id,
util.Plural(versionCount, "version", ""),
id,
Expand Down
2 changes: 1 addition & 1 deletion cli/remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestRemove(t *testing.T) {

id := fmt.Sprintf("%s.%s", test.extension.Publisher, test.extension.Name)
if test.version != "" {
id = fmt.Sprintf("%s-%s", id, test.version)
id = fmt.Sprintf("%s@%s", id, test.version)
}

cmd := cli.Root()
Expand Down
6 changes: 3 additions & 3 deletions fixtures/generate.bash
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ EOF
cat<<EOF > "$dest/extension/extension.js"
const vscode = require("vscode");
function activate(context) {
vscode.window.showInformationMessage("mock extension $publisher.$name-$version loaded");
vscode.window.showInformationMessage("mock extension $publisher.$name@$version loaded");
}
exports.activate = activate;
EOF
Expand All @@ -121,8 +121,8 @@ mock changelog
EOF
cp "$dir/icon.png" "$dest/extension/images/icon.png"
pushd "$dest" >/dev/null
rm "$publisher.$name-$version.vsix"
zip -r "$publisher.$name-$version.vsix" * -q
rm "$publisher.$name@$version.vsix"
zip -r "$publisher.$name@$version.vsix" * -q
popd >/dev/null
done < "$dir/versions"
done < "$dir/names"
Expand Down
6 changes: 3 additions & 3 deletions storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,16 @@ func ExtensionIDFromManifest(manifest *VSIXManifest) string {

// ExtensionID returns the full ID of an extension.
func ExtensionID(publisher, name, version string) string {
return fmt.Sprintf("%s.%s-%s", publisher, name, version)
return fmt.Sprintf("%s.%s@%s", publisher, name, version)
}

// ParseExtensionID parses an extension ID into its separate parts: publisher,
// name, and version (version may be blank).
func ParseExtensionID(id string) (string, string, string, error) {
re := regexp.MustCompile(`^([^.]+)\.([^-]+)-?(.*)$`)
re := regexp.MustCompile(`^([^.]+)\.([^@]+)@?(.*)$`)
match := re.FindAllStringSubmatch(id, -1)
if match == nil {
return "", "", "", xerrors.Errorf("\"%s\" does not match <publisher>.<name> or <publisher>.<name>-<version>", id)
return "", "", "", xerrors.Errorf("\"%s\" does not match <publisher>.<name> or <publisher>.<name>@<version>", id)
}
return match[0][1], match[0][2], match[0][3], nil
}
20 changes: 10 additions & 10 deletions storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func testManifest(t *testing.T, factory storageFactory) {
name: "MissingVersion",
error: fs.ErrNotExist,
extension: testutil.Extensions[0],
version: "some-nonexistent-version",
version: "some-nonexistent@version",
},
{
name: "MissingExtension",
Expand Down Expand Up @@ -275,7 +275,7 @@ func testManifest(t *testing.T, factory storageFactory) {
// manifest since it is not on the actual manifest on disk.
expected.Assets.Asset = append(expected.Assets.Asset, storage.VSIXAsset{
Type: storage.VSIXAssetType,
Path: fmt.Sprintf("%s.%s-%s.vsix", test.extension.Publisher, test.extension.Name, version),
Path: fmt.Sprintf("%s.%s@%s.vsix", test.extension.Publisher, test.extension.Name, version),
Addressable: "true",
})
require.NoError(t, err)
Expand Down Expand Up @@ -335,7 +335,7 @@ func testWalkExtensions(t *testing.T, factory storageFactory) {
// manifest since it is not on the actual manifest on disk.
manifest.Assets.Asset = append(manifest.Assets.Asset, storage.VSIXAsset{
Type: storage.VSIXAssetType,
Path: fmt.Sprintf("%s.%s-%s.vsix", ext.Publisher, ext.Name, ext.LatestVersion),
Path: fmt.Sprintf("%s.%s@%s.vsix", ext.Publisher, ext.Name, ext.LatestVersion),
Addressable: "true",
})
expected = append(expected, extension{
Expand Down Expand Up @@ -734,7 +734,7 @@ func testAddExtension(t *testing.T, factory storageFactory) {
// Put a directory in the way of the vsix.
f := factory(t)
ext := testutil.Extensions[3]
vsixName := fmt.Sprintf("%s.%s-%s.vsix", ext.Publisher, ext.Name, ext.LatestVersion)
vsixName := fmt.Sprintf("%s.%s@%s.vsix", ext.Publisher, ext.Name, ext.LatestVersion)
f.write([]byte("foo"), ext.Publisher, ext.Name, ext.LatestVersion, vsixName, "foo")

for _, test := range tests {
Expand Down Expand Up @@ -909,7 +909,7 @@ func TestExtensionID(t *testing.T) {
}{
{
name: "OK",
expected: "foo.bar-test",
expected: "foo.bar@test",
manifest: &storage.VSIXManifest{
Metadata: storage.VSIXMetadata{
Identity: storage.VSIXIdentity{
Expand Down Expand Up @@ -948,12 +948,12 @@ func TestParseExtensionID(t *testing.T) {
{
name: "OK",
expected: []string{"foo", "bar", "test"},
id: "foo.bar-test",
id: "foo.bar@test",
},
{
name: "VersionWithDots",
expected: []string{"foo", "bar", "test.test"},
id: "foo.bar-test.test",
id: "foo.bar@test.test",
},
{
name: "EmptyID",
Expand All @@ -963,12 +963,12 @@ func TestParseExtensionID(t *testing.T) {
{
name: "MissingPublisher",
error: true,
id: ".qux-bar",
id: ".qux@bar",
},
{
name: "MissingExtension",
error: true,
id: "foo.-baz",
id: "foo.@baz",
},
{
name: "MissingExtensionAndVersion",
Expand All @@ -983,7 +983,7 @@ func TestParseExtensionID(t *testing.T) {
{
name: "InvalidID",
error: true,
id: "publisher-version",
id: "publisher@version",
},
}

Expand Down
Loading