This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
Streams enhancements #109
Merged
Merged
Streams enhancements #109
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2e791e9
Add support for common properties shared between all streams
78ce40c
Minor refactoring on AUVersion
4cce4e9
Support alphabetical streams
ce04036
Add more information on streams for plugins (+ adapt GitReleases) & a…
25ad3a4
Merge Streams and StreamsDetails property in AUPackage + add tests on it
61bb507
Rename Include to IncludeStream
daf04b5
Fix IncludeStream argument when only one is passed
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -200,6 +200,8 @@ function Update-Package { | |
} | ||
|
||
function process_stream() { | ||
$package.Updated = $false | ||
|
||
if (!(is_version $package.NuspecVersion)) { | ||
Write-Warning "Invalid nuspec file Version '$($package.NuspecVersion)' - using 0.0" | ||
$global:Latest.NuspecVersion = $package.NuspecVersion = '0.0' | ||
|
@@ -284,7 +286,7 @@ function Update-Package { | |
|
||
$build = if ($v.Build -eq -1) {0} else {$v.Build} | ||
$v = [version] ('{0}.{1}.{2}.{3}' -f $v.Major, $v.Minor, $build, $d) | ||
$package.RemoteVersion = [AUVersion]::new($v, $nuspecVersion.Prerelease, $nuspecVersion.BuildMetadata).ToString() | ||
$package.RemoteVersion = $nuspecVersion.WithVersion($v).ToString() | ||
$Latest.Version = $package.RemoteVersion -as $Latest.Version.GetType() | ||
} | ||
|
||
|
@@ -401,30 +403,41 @@ function Update-Package { | |
|
||
if ($res.ContainsKey('Streams')) { | ||
if (!$res.Streams) { throw "au_GetLatest's streams returned nothing" } | ||
if ($res.Streams -isnot [HashTable]) { throw "au_GetLatest's streams don't return a HashTable result but $($res.Streams.GetType())" } | ||
if ($res.Streams -isnot [System.Collections.Specialized.OrderedDictionary] -and $res.Streams -isnot [HashTable]) { | ||
throw "au_GetLatest doesn't return an OrderedDictionary or HashTable result for streams but $($res.Streams.GetType())" | ||
} | ||
|
||
# Streams are expected to be sorted starting with the most recent one | ||
$streams = @($res.Streams.Keys) | ||
# In case of HashTable (i.e. not sorted), let's sort streams alphabetically descending | ||
if ($res.Streams -is [HashTable]) { $streams = $streams | sort -Descending } | ||
|
||
if ($Include) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
if ($Include -isnot [string] -and $Include -isnot [double] -and $Include -isnot [Array]) { | ||
throw "`$Include must be either a String, a Double or an Array but is $($Include.GetType())" | ||
} | ||
if ($Include -is [double]) { $Include = $Include -as [string] } | ||
if ($Include -is [string]) { [Array] $Include = $Include -split ',' | foreach { ,$_.Trim() } } | ||
if ($Include -is [string]) { | ||
# Forcing type in order to handle case when only one version is included | ||
[Array] $Include = $Include -split ',' | % { $_.Trim() } | ||
} | ||
} elseif ($Force) { | ||
$Include = @($res.Streams.Keys | sort { [AUVersion] $_ } -Descending | select -First 1) | ||
# When forcing update, a single stream is expected | ||
# By default, we take the first one (i.e. the most recent one) | ||
$Include = @($streams | select -First 1) | ||
} | ||
if ($Force -and (!$Include -or $Include.Length -ne 1)) { throw 'A single stream must be included when forcing package update' } | ||
|
||
if ($Include) { | ||
$streams = @{} | ||
$res.Streams.Keys | ? { $_ -in $Include } | % { | ||
$streams.Add($_, $res.Streams[$_]) | ||
} | ||
} else { | ||
$streams = $res.Streams | ||
} | ||
if ($Include) { $streams = $streams | ? { $_ -in $Include } } | ||
# Let's reverse the order in order to process streams starting with the oldest one | ||
[Array]::Reverse($streams) | ||
|
||
$streams.Keys | ? { !$Include -or $_ -in $Include } | sort { [AUVersion] $_ } | % { | ||
$stream = $streams[$_] | ||
$res.Keys | ? { $_ -ne 'Streams' } | % { $global:au_Latest.Remove($_) } | ||
$global:au_Latest += $res | ||
|
||
$package.StreamsDetails = @{} | ||
$streams | % { | ||
$stream = $res.Streams[$_] | ||
|
||
'' | result | ||
"*** Stream: $_ ***" | result | ||
|
@@ -440,7 +453,10 @@ function Update-Package { | |
|
||
set_latest $stream $package.Streams.$_ $_ | ||
process_stream | ||
|
||
$package.StreamsDetails.Add($_, $package.GetStreamDetails()) | ||
} | ||
$package.StreamsDetails.Values | ? { $_.updated } | % { $package.Updated = $true } | ||
} else { | ||
'' | result | ||
set_latest $res $package.NuspecVersion | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't it more intuitive that
$Streams
actually contains[AUPackage]
for each stream instead ofStreamsDetails
. I don't like you need to use 2 different mechanisms for streams vs non streams where the later should be just a special case having 1 package in stream.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just sayin', not that I can't live with it, given that streams are rare.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I've merged both properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, feel free to merge when you are done with this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I'm doing a final test and then I merge. Thanks!