Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 39 lines (34 sloc) 1.006 kb
0cf809e Improved Get-GitBranch
unknown authored
1 # General Utility Functions
2
c3147d0 @dahlbyk Rename Coalesce-Args to Invoke-NullCoalescing
authored
3 function Invoke-NullCoalescing {
0cf809e Improved Get-GitBranch
unknown authored
4 $result = $null
5 foreach($arg in $args) {
6 if ($arg -is [ScriptBlock]) {
7 $result = & $arg
8 } else {
9 $result = $arg
10 }
11 if ($result) { break }
12 }
13 $result
14 }
0dc174d @drmohundro Converted to be a PS module.
drmohundro authored
15
c3147d0 @dahlbyk Rename Coalesce-Args to Invoke-NullCoalescing
authored
16 Set-Alias ?? Invoke-NullCoalescing -Force
0dc174d @drmohundro Converted to be a PS module.
drmohundro authored
17
2a209ff @dahlbyk Change Test-LocalOrParentPath to Get-LocalOrParentPath, which fixes bran...
authored
18 function Get-LocalOrParentPath($path) {
78441c9 @dahlbyk Fix prompt in hidden (.git) directories
authored
19 $checkIn = Get-Item -Force .
3df2a57 @ShadowWolf LocalOrParentPath checks provider name
ShadowWolf authored
20 if ($checkIn.PSProvider.Name -ne 'FileSystem') {
21 return $null
22 }
69b78c9 @JeremySkinner Fixed Test-LocalOrParentPath. It didn't work if you were in a subdirecto...
JeremySkinner authored
23 while ($checkIn -ne $NULL) {
9d624ca @dahlbyk maybe fix?
authored
24 $pathToTest = [System.IO.Path]::Combine($checkIn.fullname, $path)
72fde6f @dahlbyk Use -LiteralPath to handle paths with []
authored
25 if (Test-Path -LiteralPath $pathToTest) {
2a209ff @dahlbyk Change Test-LocalOrParentPath to Get-LocalOrParentPath, which fixes bran...
authored
26 return $pathToTest
69b78c9 @JeremySkinner Fixed Test-LocalOrParentPath. It didn't work if you were in a subdirecto...
JeremySkinner authored
27 } else {
28 $checkIn = $checkIn.parent
29 }
30 }
2a209ff @dahlbyk Change Test-LocalOrParentPath to Get-LocalOrParentPath, which fixes bran...
authored
31 return $null
0dc174d @drmohundro Converted to be a PS module.
drmohundro authored
32 }
c00a37a @dahlbyk Add timing to debug statements
authored
33
34 function dbg ($Message, [Diagnostics.Stopwatch]$Stopwatch) {
f544c4c @dahlbyk Add $GitPromptSettings.Debug instead of relying on $DebugPreference
authored
35 if($Stopwatch) {
36 Write-Verbose ('{0:00000}:{1}' -f $Stopwatch.ElapsedMilliseconds,$Message) -Verbose # -ForegroundColor Yellow
37 }
c00a37a @dahlbyk Add timing to debug statements
authored
38 }
Something went wrong with that request. Please try again.