-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added @>= to existing >= for version selection --------- Co-authored-by: Sourabh Mehta <[email protected]>
- Loading branch information
Showing
6 changed files
with
53 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,11 @@ Add a pack using the following "<pack>" specification or using packs provided by | |
been released yet. This will install it as a local pack and | ||
keep a reference in ".Local/local_repository.pidx". | ||
The file can be a local file or a file hosted somewhere else on the Internet. | ||
To select a specific version use: Vendor::[email protected] | ||
To select the newest version of a major version use: Vendor::Pack@^x.y.z | ||
To select any newer version use: Vendor::Pack@>=x.y.z | ||
The file can be a local file or a file hosted somewhere else on the Internet. | ||
If it's hosted somewhere, cpackget will first download it then extract all pack files into "CMSIS_PACK_ROOT/<vendor>/<packName>/<x.y.z>/" | ||
If "-f" is used, cpackget will call "cpackget pack add" on each URL specified in the <packs list> file.`, | ||
Args: cobra.MinimumNArgs(0), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ var ( | |
ListCached = true | ||
ListFilter = "" | ||
ListPublic = true | ||
ListUpdates = true | ||
ListRequirements = true | ||
) | ||
|
||
|
@@ -35,7 +36,7 @@ func ExampleListInstalledPacks() { | |
log.SetOutput(os.Stdout) | ||
defer log.SetOutput(io.Discard) | ||
|
||
_ = installer.ListInstalledPacks(!ListCached, !ListPublic, !ListRequirements, ListFilter) | ||
_ = installer.ListInstalledPacks(!ListCached, !ListPublic, !ListUpdates, !ListRequirements, ListFilter) | ||
// Output: | ||
// I: Listing installed packs | ||
// I: (no packs installed) | ||
|
@@ -49,7 +50,7 @@ func ExampleListInstalledPacks_emptyCache() { | |
log.SetOutput(os.Stdout) | ||
defer log.SetOutput(io.Discard) | ||
|
||
_ = installer.ListInstalledPacks(ListCached, !ListPublic, !ListRequirements, ListFilter) | ||
_ = installer.ListInstalledPacks(ListCached, !ListPublic, !ListUpdates, !ListRequirements, ListFilter) | ||
// Output: | ||
// I: Listing cached packs | ||
// I: (no packs cached) | ||
|
@@ -63,7 +64,7 @@ func ExampleListInstalledPacks_emptyPublicIndex() { | |
log.SetOutput(os.Stdout) | ||
defer log.SetOutput(io.Discard) | ||
|
||
_ = installer.ListInstalledPacks(ListCached, ListPublic, !ListRequirements, ListFilter) | ||
_ = installer.ListInstalledPacks(ListCached, ListPublic, !ListUpdates, !ListRequirements, ListFilter) | ||
// Output: | ||
// I: Listing packs from the public index | ||
// I: (no packs in public index) | ||
|
@@ -102,7 +103,7 @@ func ExampleListInstalledPacks_list() { | |
|
||
log.SetOutput(os.Stdout) | ||
defer log.SetOutput(io.Discard) | ||
_ = installer.ListInstalledPacks(ListCached, ListPublic, !ListRequirements, ListFilter) | ||
_ = installer.ListInstalledPacks(ListCached, ListPublic, !ListUpdates, !ListRequirements, ListFilter) | ||
// Output: | ||
// I: Listing packs from the public index | ||
// I: TheVendor::[email protected] (cached) | ||
|
@@ -139,7 +140,7 @@ func ExampleListInstalledPacks_listCached() { | |
|
||
log.SetOutput(os.Stdout) | ||
defer log.SetOutput(io.Discard) | ||
_ = installer.ListInstalledPacks(ListCached, !ListPublic, !ListRequirements, ListFilter) | ||
_ = installer.ListInstalledPacks(ListCached, !ListPublic, !ListUpdates, !ListRequirements, ListFilter) | ||
// Output: | ||
// I: Listing cached packs | ||
// I: TheVendor::[email protected] | ||
|
@@ -186,7 +187,7 @@ func TestListInstalledPacks(t *testing.T) { | |
var buf bytes.Buffer | ||
log.SetOutput(&buf) | ||
defer log.SetOutput(io.Discard) | ||
assert.Nil(installer.ListInstalledPacks(!ListCached, !ListPublic, !ListRequirements, ListFilter)) | ||
assert.Nil(installer.ListInstalledPacks(!ListCached, !ListPublic, !ListUpdates, !ListRequirements, ListFilter)) | ||
stdout := buf.String() | ||
assert.Contains(stdout, "I: Listing installed packs") | ||
assert.Contains(stdout, fmt.Sprintf("I: TheVendor::[email protected] (installed via %s)", expectedPdscAbsPath)) | ||
|
@@ -216,7 +217,7 @@ func TestListInstalledPacks(t *testing.T) { | |
var buf bytes.Buffer | ||
log.SetOutput(&buf) | ||
defer log.SetOutput(io.Discard) | ||
assert.Nil(installer.ListInstalledPacks(!ListCached, !ListPublic, !ListRequirements, ListFilter)) | ||
assert.Nil(installer.ListInstalledPacks(!ListCached, !ListPublic, !ListUpdates, !ListRequirements, ListFilter)) | ||
stdout := buf.String() | ||
assert.Contains(stdout, "I: Listing installed packs") | ||
assert.Contains(stdout, fmt.Sprintf("I: TheVendor::[email protected] (installed via %s)", expectedPdscAbsPath)) | ||
|
@@ -226,7 +227,7 @@ func TestListInstalledPacks(t *testing.T) { | |
assert.Nil(pdscXML.Read()) | ||
pdscXML.ReleasesTag.Releases[0].Version = "1.2.4" | ||
assert.Nil(utils.WriteXML(pdscPath, pdscXML)) | ||
assert.Nil(installer.ListInstalledPacks(!ListCached, !ListPublic, !ListRequirements, ListFilter)) | ||
assert.Nil(installer.ListInstalledPacks(!ListCached, !ListPublic, !ListUpdates, !ListRequirements, ListFilter)) | ||
stdout = buf.String() | ||
assert.Contains(stdout, "I: Listing installed packs") | ||
assert.Contains(stdout, fmt.Sprintf("I: TheVendor::[email protected] (installed via %s)", expectedPdscAbsPath)) | ||
|
@@ -264,7 +265,7 @@ func ExampleListInstalledPacks_listMalformedInstalledPacks() { | |
|
||
log.SetOutput(os.Stdout) | ||
defer log.SetOutput(io.Discard) | ||
_ = installer.ListInstalledPacks(!ListCached, !ListPublic, !ListRequirements, ListFilter) | ||
_ = installer.ListInstalledPacks(!ListCached, !ListPublic, !ListUpdates, !ListRequirements, ListFilter) | ||
// Output: | ||
// I: Listing installed packs | ||
// E: _TheVendor::[email protected] - error: pack version incorrect format | ||
|
@@ -300,7 +301,7 @@ func ExampleListInstalledPacks_filter() { | |
|
||
log.SetOutput(os.Stdout) | ||
defer log.SetOutput(io.Discard) | ||
_ = installer.ListInstalledPacks(ListCached, ListPublic, !ListRequirements, "1.2.4") | ||
_ = installer.ListInstalledPacks(ListCached, ListPublic, !ListUpdates, !ListRequirements, "1.2.4") | ||
// Output: | ||
// I: Listing packs from the public index, filtering by "1.2.4" | ||
// I: TheVendor::[email protected] (installed) | ||
|
@@ -337,7 +338,7 @@ func ExampleListInstalledPacks_filterErrorPackages() { | |
|
||
log.SetOutput(os.Stdout) | ||
defer log.SetOutput(io.Discard) | ||
_ = installer.ListInstalledPacks(!ListCached, !ListPublic, !ListRequirements, "TheVendor") | ||
_ = installer.ListInstalledPacks(!ListCached, !ListPublic, !ListUpdates, !ListRequirements, "TheVendor") | ||
// Output: | ||
// I: Listing installed packs, filtering by "TheVendor" | ||
// E: _TheVendor::[email protected] - error: pack version incorrect format | ||
|
@@ -372,7 +373,7 @@ func ExampleListInstalledPacks_filterInvalidChars() { | |
|
||
log.SetOutput(os.Stdout) | ||
defer log.SetOutput(io.Discard) | ||
_ = installer.ListInstalledPacks(ListCached, ListPublic, !ListRequirements, "@ :") | ||
_ = installer.ListInstalledPacks(ListCached, ListPublic, !ListUpdates, !ListRequirements, "@ :") | ||
// Output: | ||
// I: Listing packs from the public index, filtering by "@ :" | ||
} | ||
|
@@ -406,7 +407,7 @@ func ExampleListInstalledPacks_filteradditionalMessages() { | |
|
||
log.SetOutput(os.Stdout) | ||
defer log.SetOutput(io.Discard) | ||
_ = installer.ListInstalledPacks(ListCached, !ListPublic, !ListRequirements, "(installed)") | ||
_ = installer.ListInstalledPacks(ListCached, !ListPublic, !ListUpdates, !ListRequirements, "(installed)") | ||
// Output: | ||
// I: Listing cached packs, filtering by "(installed)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,10 @@ var packFileNameRegex = regexp.MustCompile(packFileNamePattern) | |
// - Vendor::Pack | ||
// - Vendor::[email protected] | ||
// - Vendor::Pack@^x.y.z | ||
// - Vendor::Pack@>=x.y.z | ||
// - Vendor::Pack>=x.y.z | ||
var dottedPackIDPattern = fmt.Sprintf(`^(?P<vendor>%s)\.(?P<pack>%s)(?:\.(?P<version>%s))?$`, namePattern, namePattern, versionPattern) | ||
var legacyPackIDPattern = fmt.Sprintf(`^(?P<vendor>%s)::(?P<pack>%s)(?:(@|@\^|>=)(?P<version>%s|latest))?$`, namePattern, namePattern, versionPattern) | ||
var legacyPackIDPattern = fmt.Sprintf(`^(?P<vendor>%s)::(?P<pack>%s)(?:(@|@\^|@>=|>=)(?P<version>%s|latest))?$`, namePattern, namePattern, versionPattern) | ||
var packIDPattern = fmt.Sprintf(`(?:%s|%s)`, dottedPackIDPattern, legacyPackIDPattern) | ||
|
||
// packIDRegex pre-compiles packIdPattern | ||
|
@@ -126,7 +127,7 @@ const ( | |
// Examples: Vendor::PackName, Vendor.PackName | ||
AnyVersion = 2 | ||
|
||
// Example: Vendor::PackName>=x.y.z | ||
// Example: Vendor::PackName@>=x.y.z | ||
GreaterVersion = 3 | ||
|
||
// Example: Vendor::PackName@^x.y.z (the greatest version of the pack keeping the same major number) | ||
|
@@ -137,9 +138,10 @@ const ( | |
) | ||
|
||
var versionModMap = map[string]int{ | ||
"@": ExactVersion, | ||
"@^": GreatestCompatibleVersion, | ||
">=": GreaterVersion, | ||
"@": ExactVersion, | ||
"@^": GreatestCompatibleVersion, | ||
"@>=": GreaterVersion, | ||
">=": GreaterVersion, | ||
} | ||
|
||
// PackInfo defines a basic pack information set | ||
|
@@ -241,7 +243,7 @@ func ExtractPackInfo(packPath string) (PackInfo, error) { | |
info.VersionModifier = ExactVersion | ||
} | ||
} else if len(matches) == 5 { | ||
// 5 matches: [Vendor::Pack(@|@^|>=)x.y.z, Vendor, Pack, (@|@^|>=), x.y.z] (legacy version) | ||
// 5 matches: [Vendor::Pack(@|@^|@>=|>=)x.y.z, Vendor, Pack, (@|@^|@>=|>=), x.y.z] (legacy version) | ||
versionModifier := matches[3] | ||
version := matches[4] | ||
|
||
|