Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redid the Stash-Status from PR #181 from fritzh #215

Merged
merged 2 commits into from
Sep 2, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
16 changes: 16 additions & 0 deletions GitPrompt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ $global:GitPromptSettings = New-Object PSObject -Property @{
WorkingForegroundBrightColor = [ConsoleColor]::Red
WorkingBackgroundColor = $Host.UI.RawUI.BackgroundColor

EnableStashStatus = $false
BeforeStashText = ' ('
BeforeStashBackgroundColor = $Host.UI.RawUI.BackgroundColor
BeforeStashForegroundColor = [ConsoleColor]::Red
AfterStashText = ')'
AfterStashBackgroundColor = $Host.UI.RawUI.BackgroundColor
AfterStashForegroundColor = [ConsoleColor]::Red
StashBackgroundColor = $Host.UI.RawUI.BackgroundColor
StashForegroundColor = [ConsoleColor]::Red

ShowStatusWhenZero = $true

AutoRefreshIndex = $true
Expand Down Expand Up @@ -210,6 +220,12 @@ function Write-GitStatus($status) {
Write-Prompt (" {0}" -f $localStatusSymbol) -BackgroundColor $localStatusBackgroundColor -ForegroundColor $localStatusForegroundColor
}

if ($s.EnableStashStatus -and ($status.StashCount -gt 0)) {
Write-Prompt $s.BeforeStashText -BackgroundColor $s.BeforeStashBackgroundColor -ForegroundColor $s.BeforeStashForegroundColor
Write-Prompt $status.StashCount -BackgroundColor $s.StashBackgroundColor -ForegroundColor $s.StashForegroundColor
Write-Prompt $s.AfterStashText -BackgroundColor $s.AfterStashBackgroundColor -ForegroundColor $s.AfterStashForegroundColor
}

Write-Prompt $s.AfterText -BackgroundColor $s.AfterBackgroundColor -ForegroundColor $s.AfterForegroundColor

if ($WindowTitleSupported -and $s.EnableWindowTitle) {
Expand Down
3 changes: 3 additions & 0 deletions GitUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
$filesModified = @()
$filesDeleted = @()
$filesUnmerged = @()
$stashCount = 0

if($settings.EnableFileStatus -and !$(InDisabledRepository)) {
dbg 'Getting status' $sw
$status = git -c color.status=false status --short --branch 2>$null
$stashCount = $null | git stash list 2>$null | measure-object | select -expand Count
} else {
$status = @()
}
Expand Down Expand Up @@ -186,6 +188,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) {
HasWorking = [bool]$working
Working = $working
HasUntracked = [bool]$filesAdded
stashCount = $stashCount
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Can you flip the property to PascalCase?

}

dbg 'Finished' $sw
Expand Down