1- <#
1+ # cspell:ignore jdoe TrimEnd
2+ <#
23 . SYNOPSIS
34 Clone a git repository
45
5354
5455 # Simple syntax
5556 # First example shows cloning PSDeploy from ramblingcookiemonster's GitHub repo
56- # Second example shows clonging BuildHelpers from jdoe's internal GitLab account and checking out a specific commit
57+ # Second example shows cloning BuildHelpers from jdoe's internal GitLab account and checking out a specific commit
5758 # Both are cloned to the current path (e.g. .\<repo name>)
5859 # This syntax assumes git as a source. The right hand side is the version (branch, commit, tags/<tag name>, etc.)
5960#>
60- [cmdletbinding ()]
61+ [CmdletBinding ()]
6162param (
6263 [PSTypeName (' PSDepend.Dependency' )]
63- [psobject []]$Dependency ,
64+ [PSObject []]$Dependency ,
6465
6566 [switch ]$Force ,
6667
@@ -84,16 +85,14 @@ if (-not $Name) {
8485if ($Name -match " ^[a-zA-Z0-9]+/[a-zA-Z0-9_-]+$" ) {
8586 $Name = " https://github.com/$Name .git"
8687}
87- $GitName = $Name.trimend (' /' ).split(' /' )[-1 ] -replace " \.git$" , ' '
88+ $GitName = $Name.TrimEnd (' /' ).split(' /' )[-1 ] -replace " \.git$" , ' '
8889if ($Dependency.Target -and ($Target = (Get-Item $Dependency.Target - ErrorAction SilentlyContinue).FullName)) {
8990 Write-Debug " Target resolved to $Target "
90- }
91- else {
91+ } else {
9292 if ($Dependency.Target ) {
9393 $Target = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath ($Dependency.Target )
9494 Write-Debug " Target $ ( $Dependency.Target ) does not exist yet, will be created"
95- }
96- else {
95+ } else {
9796 $Target = $PWD.Path
9897 Write-Debug " Target defaulted to current dir: $Target "
9998 }
@@ -111,8 +110,8 @@ if (-not (Test-Path $RepoPath)) {
111110 if ( $PSDependAction -contains ' Test' -and $PSDependAction.count -eq 1 ) {
112111 return $False
113112 }
114- }
115- else { # Target exists
113+ } else {
114+ # Target exists
116115 $GottaTest = $True
117116}
118117
@@ -129,28 +128,25 @@ if (-not $Version) {
129128if ($GottaTest ) {
130129 Push-Location
131130 Set-Location $RepoPath
132- $Branch = Invoke-ExternalCommand git - Arguments (Write-Output rev- parse -- abbrev- ref HEAD) - Passthru
133- $Commit = Invoke-ExternalCommand git - Arguments (Write-Output rev- parse HEAD) - Passthru
131+ $Branch = Invoke-ExternalCommand git - Arguments (Write-Output rev- parse -- abbrev- ref HEAD) - PassThru
132+ $Commit = Invoke-ExternalCommand git - Arguments (Write-Output rev- parse HEAD) - PassThru
134133 Pop-Location
135134 if (-not $Branch ) {
136135 Write-Warning " [$RepoPath ] exists but does not appear to be a valid git repository. Skipping [$DependencyName ]."
137136 if ($PSDependAction -contains ' Test' -and $PSDependAction.count -eq 1 ) {
138137 return $false
139138 }
140139 $GottaInstall = $False
141- }
142- elseif ($Version -eq $Branch -or $Version -eq $Commit ) {
140+ } elseif ($Version -eq $Branch -or $Version -eq $Commit ) {
143141 Write-Verbose " [$RepoPath ] exists and is already at version [$Version ]"
144142 if ($PSDependAction -contains ' Test' -and $PSDependAction.count -eq 1 ) {
145143 return $true
146144 }
147145 $GottaInstall = $False
148- }
149- elseif ($PSDependAction -contains ' Test' -and $PSDependAction.count -eq 1 ) {
146+ } elseif ($PSDependAction -contains ' Test' -and $PSDependAction.count -eq 1 ) {
150147 Write-Verbose " [$RepoPath ] exists and is at branch [$Branch ], commit [$Commit ].`n We don't currently support moving to the requested version [$Version ]"
151148 return $false
152- }
153- else {
149+ } else {
154150 Write-Verbose " [$RepoPath ] exists and is at branch [$Branch ], commit [$Commit ].`n We don't currently support moving to the requested version [$Version ]"
155151 $GottaInstall = $False
156152 }
@@ -171,8 +167,7 @@ if ($GottaInstall -and !$ExtractProject) {
171167 Write-Verbose - Message " Checking out [$Version ] of [$Name ] from [$RepoPath ]"
172168 Invoke-ExternalCommand git ' checkout' , $Version
173169 Pop-Location
174- }
175- elseif ($GottaInstall -and $ExtractProject ) {
170+ } elseif ($GottaInstall -and $ExtractProject ) {
176171 $OutPath = Join-Path ([System.IO.Path ]::GetTempPath()) ([guid ]::NewGuid().guid)
177172 $RepoFolder = Join-Path - Path $OutPath - ChildPath $GitName
178173
0 commit comments