From 0524fa71455e33b0261c70d68b4c43f50d594829 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Thu, 29 Dec 2016 09:56:41 -0600 Subject: [PATCH 1/3] Add status characters to comment --- GitPrompt.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/GitPrompt.ps1 b/GitPrompt.ps1 index 97b2843a0..33511b5d7 100644 --- a/GitPrompt.ps1 +++ b/GitPrompt.ps1 @@ -1,4 +1,4 @@ -# Inspired by Mark Embling +# Inspired by Mark Embling # http://www.markembling.info/view/my-ideal-powershell-prompt-with-git-integration $global:GitPromptSettings = New-Object PSObject -Property @{ @@ -39,19 +39,19 @@ $global:GitPromptSettings = New-Object PSObject -Property @{ BranchForegroundColor = [ConsoleColor]::Cyan BranchBackgroundColor = $Host.UI.RawUI.BackgroundColor - BranchIdenticalStatusToSymbol = [char]0x2261 # Three horizontal lines + BranchIdenticalStatusToSymbol = [char]0x2261 # ≡ Three horizontal lines BranchIdenticalStatusToForegroundColor = [ConsoleColor]::Cyan BranchIdenticalStatusToBackgroundColor = $Host.UI.RawUI.BackgroundColor - BranchAheadStatusSymbol = [char]0x2191 # Up arrow + BranchAheadStatusSymbol = [char]0x2191 # ↑ Up arrow BranchAheadStatusForegroundColor = [ConsoleColor]::Green BranchAheadStatusBackgroundColor = $Host.UI.RawUI.BackgroundColor - BranchBehindStatusSymbol = [char]0x2193 # Down arrow + BranchBehindStatusSymbol = [char]0x2193 # ↓ Down arrow BranchBehindStatusForegroundColor = [ConsoleColor]::Red BranchBehindStatusBackgroundColor = $Host.UI.RawUI.BackgroundColor - BranchBehindAndAheadStatusSymbol = [char]0x2195 # Up & Down arrow + BranchBehindAndAheadStatusSymbol = [char]0x2195 # ↕ Up & Down arrow BranchBehindAndAheadStatusForegroundColor = [ConsoleColor]::Yellow BranchBehindAndAheadStatusBackgroundColor = $Host.UI.RawUI.BackgroundColor From 084b18200bcd6f8472afe5399d9b703a36e14643 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Thu, 29 Dec 2016 10:11:27 -0600 Subject: [PATCH 2/3] Parse and show upstream gone branch status --- GitPrompt.ps1 | 9 +++++++++ GitUtils.ps1 | 5 ++++- README.md | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/GitPrompt.ps1 b/GitPrompt.ps1 index 33511b5d7..fbd440fe2 100644 --- a/GitPrompt.ps1 +++ b/GitPrompt.ps1 @@ -39,6 +39,10 @@ $global:GitPromptSettings = New-Object PSObject -Property @{ BranchForegroundColor = [ConsoleColor]::Cyan BranchBackgroundColor = $Host.UI.RawUI.BackgroundColor + BranchGoneStatusSymbol = [char]0x00D7 # × Multiplication sign + BranchGoneStatusForegroundColor = [ConsoleColor]::DarkCyan + BranchGoneStatusBackgroundColor = $Host.UI.RawUI.BackgroundColor + BranchIdenticalStatusToSymbol = [char]0x2261 # ≡ Three horizontal lines BranchIdenticalStatusToForegroundColor = [ConsoleColor]::Cyan BranchIdenticalStatusToBackgroundColor = $Host.UI.RawUI.BackgroundColor @@ -143,6 +147,11 @@ function Write-GitStatus($status) { if (!$status.Upstream) { $branchStatusSymbol = $s.BranchUntrackedSymbol + } elseif ($status.UpstreamGone -eq $true) { + # Upstream branch is gone + $branchStatusSymbol = $s.BranchGoneStatusSymbol + $branchStatusBackgroundColor = $s.BranchGoneStatusBackgroundColor + $branchStatusForegroundColor = $s.BranchGoneStatusForegroundColor } elseif ($status.BehindBy -eq 0 -and $status.AheadBy -eq 0) { # We are aligned with remote $branchStatusSymbol = $s.BranchIdenticalStatusToSymbol diff --git a/GitUtils.ps1 b/GitUtils.ps1 index 36f6e3b67..a600def9b 100644 --- a/GitUtils.ps1 +++ b/GitUtils.ps1 @@ -132,6 +132,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) { $branch = $null $aheadBy = 0 $behindBy = 0 + $gone = $false $indexAdded = New-Object System.Collections.Generic.List[string] $indexModified = New-Object System.Collections.Generic.List[string] $indexDeleted = New-Object System.Collections.Generic.List[string] @@ -177,13 +178,14 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) { continue } - '^## (?\S+?)(?:\.\.\.(?\S+))?(?: \[(?:ahead (?\d+))?(?:, )?(?:behind (?\d+))?\])?$' { + '^## (?\S+?)(?:\.\.\.(?\S+))?(?: \[(?:ahead (?\d+))?(?:, )?(?:behind (?\d+))?(?gone)?\])?$' { if ($sw) { dbg "Status: $_" $sw } $branch = $matches['branch'] $upstream = $matches['upstream'] $aheadBy = [int]$matches['ahead'] $behindBy = [int]$matches['behind'] + $gone = [string]$matches['gone'] -eq 'gone' continue } @@ -224,6 +226,7 @@ function Get-GitStatus($gitDir = (Get-GitDirectory)) { Branch = $branch AheadBy = $aheadBy BehindBy = $behindBy + UpstreamGone = $gone Upstream = $upstream HasIndex = [bool]$index Index = $index diff --git a/README.md b/README.md index 1a7bbd581..e5efc1b5b 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,7 @@ By default, the status summary has the following format: * ↑ = The local branch is ahead of the remote branch, a 'git push' is required to update the remote branch (`BranchAheadStatus`) * ↓ = The local branch is behind the remote branch, a 'git pull' is required to update the local branch (`BranchBehindStatus`) * ↕ = The local branch is both ahead and behind the remote branch, a rebase of the local branch is required before pushing local changes to the remote branch (`BranchBehindAndAheadStatus`) + * × = The local branch is tracking a branch that is gone from the remote (`BranchGoneStatus') * ABCD represent the index; ` | ` (`DelimText`); EFGH represent the working directory * `+` = Added files * `~` = Modified files From a32d1a5e6392583c9527c8f1fd749e9dab8fe40e Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Thu, 29 Dec 2016 10:13:26 -0600 Subject: [PATCH 3/3] Adjust readme punctuation --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e5efc1b5b..91a950daa 100644 --- a/README.md +++ b/README.md @@ -229,9 +229,9 @@ By default, the status summary has the following format: * Yellow means the branch is both ahead of and behind its remote * S represents the branch status in relation to remote (tracked origin) branch. Note: This information reflects the state of the remote tracked branch after the last `git fetch/pull` of the remote. * ≡ = The local branch in at the same commit level as the remote branch (`BranchIdenticalStatus`) - * ↑ = The local branch is ahead of the remote branch, a 'git push' is required to update the remote branch (`BranchAheadStatus`) - * ↓ = The local branch is behind the remote branch, a 'git pull' is required to update the local branch (`BranchBehindStatus`) - * ↕ = The local branch is both ahead and behind the remote branch, a rebase of the local branch is required before pushing local changes to the remote branch (`BranchBehindAndAheadStatus`) + * ↑ = The local branch is ahead of the remote branch; a 'git push' is required to update the remote branch (`BranchAheadStatus`) + * ↓ = The local branch is behind the remote branch; a 'git pull' is required to update the local branch (`BranchBehindStatus`) + * ↕ = The local branch is both ahead and behind the remote branch; a rebase of the local branch is required before pushing local changes to the remote branch (`BranchBehindAndAheadStatus`) * × = The local branch is tracking a branch that is gone from the remote (`BranchGoneStatus') * ABCD represent the index; ` | ` (`DelimText`); EFGH represent the working directory * `+` = Added files