@@ -171,10 +171,42 @@ function GetUniquePaths($pathCollections) {
171
171
172
172
$castStringSeq = [Linq.Enumerable ].GetMethod(" Cast" ).MakeGenericMethod([string ])
173
173
174
- function Get-GitStatus ($gitDir = (Get-GitDirectory )) {
174
+ <#
175
+ . SYNOPSIS
176
+ Gets a Git status object that is used by Write-GitStatus.
177
+ . DESCRIPTION
178
+ Gets a Git status object that is used by Write-GitStatus.
179
+ The status object provides the information to be displayed in the various
180
+ sections of the posh-git prompt.
181
+ . EXAMPLE
182
+ PS C:\> $s = Get-GitStatus; Write-GitStatus $s
183
+ Gets a Git status object. Then passes the object to Write-GitStatus which
184
+ writes out a posh-git prompt (or returns a string in ANSI mode) with the
185
+ information contained in the status object.
186
+ . INPUTS
187
+ None
188
+ . OUTPUTS
189
+ System.Management.Automation.PSObject
190
+ . LINK
191
+ Write-GitStatus
192
+ #>
193
+ function Get-GitStatus {
194
+ param (
195
+ # The path of a directory within a Git repository that you want to get
196
+ # the Git status.
197
+ [Parameter (Position = 0 )]
198
+ $GitDir = (Get-GitDirectory ),
199
+
200
+ # If specified, overrides $GitPromptSettings.EnablePromptStatus when it
201
+ # is set to $false.
202
+ [Parameter ()]
203
+ [switch ]
204
+ $Force
205
+ )
206
+
175
207
$settings = $Global :GitPromptSettings
176
- $enabled = ( -not $settings ) -or $settings.EnablePromptStatus
177
- if ($enabled -and $gitDir ) {
208
+ $enabled = $Force -or ! $settings -or $settings.EnablePromptStatus
209
+ if ($enabled -and $GitDir ) {
178
210
if ($settings.Debug ) {
179
211
$sw = [Diagnostics.Stopwatch ]::StartNew(); Write-Host ' '
180
212
}
@@ -196,7 +228,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
196
228
$filesUnmerged = New-Object System.Collections.Generic.List[string ]
197
229
$stashCount = 0
198
230
199
- if ($settings.EnableFileStatus -and ! $ (InDotGitOrBareRepoDir $gitDir ) -and ! $ (InDisabledRepository)) {
231
+ if ($settings.EnableFileStatus -and ! $ (InDotGitOrBareRepoDir $GitDir ) -and ! $ (InDisabledRepository)) {
200
232
if ($null -eq $settings.EnableFileStatusFromCache ) {
201
233
$settings.EnableFileStatusFromCache = $null -ne (Get-Module GitStatusCachePoshClient)
202
234
}
@@ -285,7 +317,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
285
317
}
286
318
}
287
319
288
- if (! $branch ) { $branch = Get-GitBranch $gitDir $sw }
320
+ if (! $branch ) { $branch = Get-GitBranch $GitDir $sw }
289
321
290
322
dbg ' Building status object' $sw
291
323
#
@@ -307,7 +339,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
307
339
Add-Member - Force - PassThru NoteProperty Unmerged $filesUnmerged.ToArray ()
308
340
309
341
$result = New-Object PSObject - Property @ {
310
- GitDir = $gitDir
342
+ GitDir = $GitDir
311
343
Branch = $branch
312
344
AheadBy = $aheadBy
313
345
BehindBy = $behindBy
0 commit comments