Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Merge development into master #431

Merged
merged 22 commits into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ab60ff8
Secure the links
RDIL Jan 10, 2019
0d77cf1
Throw error when Test-ModuleManifest fails in Update-ModuleManifest
throwaway774 Jan 11, 2019
e454bd6
filter out hidden files from nupkg (#396)
edyoung Jan 14, 2019
e2c81de
Adding support for PowerShellGet switches (#347)
mrhockeymonkey Jan 14, 2019
c1f05eb
File renaming to PowerShellGet and Code cleanup, added some best prac…
Outek Jan 17, 2019
c3c8a45
Now removes the PSGet_ prepended to line 2 in the updated manifest. (…
ThePoShWolf Jan 19, 2019
5a51ee6
Added basic test case to demonstrate repository / problem
edyoung Jan 23, 2019
4cc6d80
Proposed fix for location issues
edyoung Jan 24, 2019
437b0ba
do-nothing update to tickle appveyor
edyoung Jan 24, 2019
24cdf82
Fix for not being able to register PSGallery repository behind web pr…
muzzar78 Jan 29, 2019
3f6f735
Allow Update-ModuleManifest to take an empty array of functions or co…
Feb 4, 2019
73e6f87
Updated CI pipeline for testing PSModule DSC resources (#413)
johlju Feb 6, 2019
8c6ed52
Fix Update-ModuleManifest clears FunctionsToExport, AliasesToExport, …
Feb 10, 2019
cfdc6c7
Fix bug #9, use utf8 for .nuspec
edyoung Feb 11, 2019
041cb48
Fix #36 Allow piping psrepositories (#420)
edyoung Feb 11, 2019
cb52f79
PSModule: Clean up code (#424)
johlju Feb 18, 2019
1c677b8
PSRepository: New DSC resource (#426)
johlju Feb 18, 2019
1ed4914
Add DSC Unit tests to BVT
mgreenegit Feb 21, 2019
6b13c51
Merge pull request #428 from mgreenegit/DSC-BVTtags-1
edyoung Feb 22, 2019
87783e9
Cleaned up Travis CI config (#429)
RDIL Feb 23, 2019
6926ad4
Fix #78 (#421)
edyoung Feb 25, 2019
b9fba01
Update version and changelog (#430)
alerickson Feb 26, 2019
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
Prev Previous commit
Next Next commit
Proposed fix for location issues
  • Loading branch information
edyoung authored and alerickson committed Feb 21, 2019
commit 4cc6d800319f96e5fb48c3ae9f582cad3568812c
38 changes: 33 additions & 5 deletions Tests/PSGetUpdateModule.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,31 +91,59 @@ Describe UpdateModuleFromAlternateRepo -Tags 'BVT' {
PSGetTestUtils\Uninstall-Module ContosoClient
}

It "Check situation" {
It "Check that removing a slash from a repo doesn't break update" {
$withSlash = "https://www.poshtestgallery.com/api/v2/"
$noSlash = "https://www.poshtestgallery.com/api/v2"
Write-Host (Get-PSRepository | Out-String)
#Write-Host (Get-PSRepository | Out-String)
(Get-PSRepository PSGallery).SourceLocation | Should Be $withSlash

Install-Module ContosoServer -RequiredVersion 1.0
(Get-InstalledModule ContosoServer).RepositorySourceLocation | Should Be $withSlash
Write-Host (Get-InstalledModule ContosoServer -AllVersions | Format-List | Out-String)
#Write-Host (Get-InstalledModule ContosoServer -AllVersions | Format-List | Out-String)

# now update where PSGallery Source Location is
Set-PSGallerySourceLocation -Location $noSlash
Write-Host (Get-PSRepository | Out-String)
#Write-Host (Get-PSRepository | Out-String)
(Get-PSRepository PSGallery).SourceLocation | Should Be $noSlash

# reload powershellget to force-update cached repository info
Import-Module PowerShellGet -Force

# now try and update module isntalled using other SourceLocation
Update-Module ContosoServer -RequiredVersion 2.0 -ErrorAction Stop
Write-Host (Get-InstalledModule ContosoServer -AllVersions | Format-List | Out-String)
#Write-Host (Get-InstalledModule ContosoServer -AllVersions | Format-List | Out-String)
(Get-InstalledModule ContosoServer).RepositorySourceLocation | Should Be $noSlash

(Get-InstalledModule ContosoServer).Version | Should Be 2.0
}

It "Check that adding a slash to a repo doesn't break update" {
$withSlash = "https://www.poshtestgallery.com/api/v2/"
$noSlash = "https://www.poshtestgallery.com/api/v2"
#Write-Host (Get-PSRepository | Out-String)

Set-PSGallerySourceLocation -Location $noSlash

(Get-PSRepository PSGallery).SourceLocation | Should Be $noSlash

Install-Module ContosoServer -RequiredVersion 1.0
(Get-InstalledModule ContosoServer).RepositorySourceLocation | Should Be $noSlash
#Write-Host (Get-InstalledModule ContosoServer -AllVersions | Format-List | Out-String)

# now update where PSGallery Source Location is
Set-PSGallerySourceLocation -Location $withSlash
#Write-Host (Get-PSRepository | Out-String)
(Get-PSRepository PSGallery).SourceLocation | Should Be $withSlash

# reload powershellget to force-update cached repository info
Import-Module PowerShellGet -Force

# now try and update module isntalled using other SourceLocation
Update-Module ContosoServer -RequiredVersion 2.0 -ErrorAction Stop
#Write-Host (Get-InstalledModule ContosoServer -AllVersions | Format-List | Out-String)
(Get-InstalledModule ContosoServer).RepositorySourceLocation | Should Be $withSlash

(Get-InstalledModule ContosoServer).Version | Should Be 2.0
}
}

Expand Down
19 changes: 8 additions & 11 deletions src/PowerShellGet/private/functions/Get-SourceName.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
function Get-SourceName
{
function Get-SourceName {
[CmdletBinding()]
[OutputType("string")]
Param
(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]
$Location
)

Set-ModuleSourcesVariable

foreach($psModuleSource in $script:PSGetModuleSources.Values)
{
if(($psModuleSource.Name -eq $Location) -or
($psModuleSource.SourceLocation -eq $Location) -or
((Get-Member -InputObject $psModuleSource -Name $script:ScriptSourceLocation) -and
($psModuleSource.ScriptSourceLocation -eq $Location)))
{
foreach ($psModuleSource in $script:PSGetModuleSources.Values) {
if (($psModuleSource.Name -eq $Location) -or
(Test-EquivalentLocation -LocationA $psModuleSource.SourceLocation -LocationB $Location) -or
((Get-Member -InputObject $psModuleSource -Name $script:ScriptSourceLocation) -and
(Test-EquivalentLocation -LocationA $psModuleSource.ScriptSourceLocation -LocationB $Location))) {
return $psModuleSource.Name
}
}
}
}
18 changes: 18 additions & 0 deletions src/PowerShellGet/private/functions/Test-EquivalentLocation.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Compare 2 strings, ignoring any trailing slashes or backslashes.
# This is not exactly the same as URL or path equivalence but it should work in practice
function Test-EquivalentLocation {
[CmdletBinding()]
[OutputType("bool")]
param(
[Parameter(Mandatory = $false)]
[string]$LocationA,

[Parameter(Mandatory = $false)]
[string]$LocationB
)

$LocationA = $LocationA.TrimEnd("\/")
$LocationB = $LocationB.TrimEnd("\/")
return $LocationA -eq $LocationB
}