From 1938a20f83e529813c2c47a9cf55cc50105959f6 Mon Sep 17 00:00:00 2001 From: Derek Lomax Date: Thu, 15 May 2025 10:01:01 -0600 Subject: [PATCH 1/5] style(git.status): change On Branch to On branch --- Types/git.status/Git.Status.format.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Types/git.status/Git.Status.format.ps1 b/Types/git.status/Git.Status.format.ps1 index 12706f7d..f0dedbdb 100644 --- a/Types/git.status/Git.Status.format.ps1 +++ b/Types/git.status/Git.Status.format.ps1 @@ -1,5 +1,5 @@ Write-FormatView -TypeName Git.Status -Action { - Write-FormatViewExpression -Text "On Branch: " + Write-FormatViewExpression -Text "On branch: " Write-FormatViewExpression -ScriptBlock { $_.BranchName } -if { $_.BranchName -notin 'main', 'master' } -ForegroundColor Verbose Write-FormatViewExpression -ScriptBlock { $_.BranchName } -if { $_.BranchName -in 'main', 'master' } -ForegroundColor Warning Write-FormatViewExpression -Newline From 8caecb1b30895b28272a0d739d365f97b555ddde Mon Sep 17 00:00:00 2001 From: Derek Lomax Date: Thu, 15 May 2025 10:03:50 -0600 Subject: [PATCH 2/5] style(git.status): remove git.status format group by GitRoot This will remove the GitRoot at the top of the git status formatting In my opinion this is unsightly and offers no visual benefit --- Types/git.status/Git.Status.format.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Types/git.status/Git.Status.format.ps1 b/Types/git.status/Git.Status.format.ps1 index f0dedbdb..39f67bb5 100644 --- a/Types/git.status/Git.Status.format.ps1 +++ b/Types/git.status/Git.Status.format.ps1 @@ -41,4 +41,4 @@ Write-FormatView -TypeName Git.Status -Action { (-not $gitStatus.Untracked) -and (-not $gitStatus.Unstaged) -and (-not $gitStatus.Staged) } -Text "Nothing to commit, working tree clean" -} -GroupByProperty GitRoot +} From 19ed63d31572a919f3e3a4f259cdf094e2e2171e Mon Sep 17 00:00:00 2001 From: Derek Lomax Date: Thu, 15 May 2025 10:05:32 -0600 Subject: [PATCH 3/5] fix(git.status): attempt to fix the conditional display of 'Nothing to commit' However, simply adding the .Count does not make any difference --- Types/git.status/Git.Status.format.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Types/git.status/Git.Status.format.ps1 b/Types/git.status/Git.Status.format.ps1 index 39f67bb5..1085e484 100644 --- a/Types/git.status/Git.Status.format.ps1 +++ b/Types/git.status/Git.Status.format.ps1 @@ -38,7 +38,7 @@ Write-FormatView -TypeName Git.Status -Action { Write-FormatViewExpression -if { $gitStatus = $_ - (-not $gitStatus.Untracked) -and (-not $gitStatus.Unstaged) -and (-not $gitStatus.Staged) + (-not $gitStatus.Untracked.Count) -and (-not $gitStatus.Unstaged.Count) -and (-not $gitStatus.Staged.Count) } -Text "Nothing to commit, working tree clean" } From c0cf70b4be20d05969ec53ec07b8570b8b67845e Mon Sep 17 00:00:00 2001 From: Derek Lomax Date: Thu, 15 May 2025 11:10:58 -0600 Subject: [PATCH 4/5] style(git.status): add color to git.status staged, unstaged, untracted files This makes a huge visual improvement! --- Types/git.status/Git.Status.format.ps1 | 22 +++++------ ugit.format.ps1xml | 53 ++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/Types/git.status/Git.Status.format.ps1 b/Types/git.status/Git.Status.format.ps1 index 1085e484..b6e2f35d 100644 --- a/Types/git.status/Git.Status.format.ps1 +++ b/Types/git.status/Git.Status.format.ps1 @@ -2,9 +2,8 @@ Write-FormatView -TypeName Git.Status -Action { Write-FormatViewExpression -Text "On branch: " Write-FormatViewExpression -ScriptBlock { $_.BranchName } -if { $_.BranchName -notin 'main', 'master' } -ForegroundColor Verbose Write-FormatViewExpression -ScriptBlock { $_.BranchName } -if { $_.BranchName -in 'main', 'master' } -ForegroundColor Warning - Write-FormatViewExpression -Newline Write-FormatViewExpression -If { $_.Status -notlike 'Nothing*' } -ScriptBlock { $_.Status + [Environment]::NewLine } - Write-formatviewExpression -If { $_.Staged } -ScriptBlock { + Write-formatviewExpression -If { $_.Staged } -ScriptBlock { "Changes Staged For Commit: (use git commit -m to commit)" + [Environment]::NewLine } @@ -12,9 +11,9 @@ Write-FormatView -TypeName Git.Status -Action { (@(foreach ($line in $($_.Staged | Select-Object ChangeType, Path | Out-String -Width ($host.UI.RawUI.BufferSize.Width - 8)) -split '(?>\r\n|\n)') { (" " * 4) + $line }) -join [Environment]::NewLine) + [Environment]::NewLine - } + } -ForegroundColor Green - Write-FormatViewExpression -If { $_.Unstaged } -ScriptBlock { + Write-FormatViewExpression -If { $_.Unstaged } -ScriptBlock { "Changes Not Staged For Commit: (use git add to add, git restore to discard changes)" + [Environment]::NewLine } @@ -23,7 +22,7 @@ Write-FormatView -TypeName Git.Status -Action { (@(foreach ($line in $($_.Unstaged | Select-Object ChangeType, Path | Out-String -Width ($host.UI.RawUI.BufferSize.Width - 8)) -split '(?>\r\n|\n)') { (" " * 4) + $line }) -join [Environment]::NewLine) + [Environment]::NewLine - } + } -ForegroundColor Red Write-FormatViewExpression -If { $_.Untracked } -ScriptBlock { "Untracked Files: @@ -34,11 +33,12 @@ Write-FormatView -TypeName Git.Status -Action { @(foreach ($line in $($_.Untracked | Out-String -Width ($host.UI.RawUI.BufferSize.Width - 8)) -split '(?>\r\n|\n)') { (" " * 4) + $line }) -join [Environment]::NewLine - } - - Write-FormatViewExpression -if { - $gitStatus = $_ - (-not $gitStatus.Untracked.Count) -and (-not $gitStatus.Unstaged.Count) -and (-not $gitStatus.Staged.Count) - } -Text "Nothing to commit, working tree clean" + } -ForegroundColor Red + Write-FormatViewExpression -ScriptBlock { + if(($_.Untracked.Count + $_.Unstaged.Count + $_.Staged.Count) -eq 0) + { + "Nothing to commit, working tree clean" + } + } } diff --git a/ugit.format.ps1xml b/ugit.format.ps1xml index e0043e5a..7587686c 100644 --- a/ugit.format.ps1xml +++ b/ugit.format.ps1xml @@ -2826,14 +2826,11 @@ $BackgroundColor Git.Status - - GitRoot - - On Branch: + On branch: $_.BranchName -notin 'main', 'master' @@ -2897,7 +2894,6 @@ $BackgroundColor @(& ${ugit_Format-RichText} -ForegroundColor 'Warning' ) -join '' - $_.Status -notlike 'Nothing*' @@ -2913,6 +2909,12 @@ $BackgroundColor (use git commit -m to commit)" + [Environment]::NewLine + + + $_.Staged + + @(& ${ugit_Format-RichText} -ForegroundColor 'Green' -NoClear) -join '' + $_.Staged @@ -2923,15 +2925,27 @@ $BackgroundColor }) -join [Environment]::NewLine) + [Environment]::NewLine + + + $_.Staged + + @(& ${ugit_Format-RichText} -ForegroundColor 'Green' ) -join '' + $_.Unstaged - + "Changes Not Staged For Commit: (use git add <file> to add, git restore <file> to discard changes)" + [Environment]::NewLine + + + $_.Unstaged + + @(& ${ugit_Format-RichText} -ForegroundColor 'Red' -NoClear) -join '' + $_.Unstaged @@ -2942,6 +2956,12 @@ $BackgroundColor }) -join [Environment]::NewLine) + [Environment]::NewLine + + + $_.Unstaged + + @(& ${ugit_Format-RichText} -ForegroundColor 'Red' ) -join '' + $_.Untracked @@ -2951,6 +2971,12 @@ $BackgroundColor (use git add <file> to include in commit)" + [Environment]::NewLine + + + $_.Untracked + + @(& ${ugit_Format-RichText} -ForegroundColor 'Red' -NoClear) -join '' + $_.Untracked @@ -2961,7 +2987,20 @@ $BackgroundColor }) -join [Environment]::NewLine - Nothing to commit, working tree clean + + + $_.Untracked + + @(& ${ugit_Format-RichText} -ForegroundColor 'Red' ) -join '' + + + + if(($_.Untracked.Count + $_.Unstaged.Count + $_.Staged.Count) -eq 0) + { + "Nothing to commit, working tree clean" + } + + From bec8468f11327076bac7176f097ac3ecd3007e64 Mon Sep 17 00:00:00 2001 From: Derek Lomax Date: Thu, 15 May 2025 11:15:44 -0600 Subject: [PATCH 5/5] fix(git.status): branch line does still require a newline In some cases removing this line helped, but no files in status it looks bad! --- Types/git.status/Git.Status.format.ps1 | 1 + ugit.format.ps1xml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Types/git.status/Git.Status.format.ps1 b/Types/git.status/Git.Status.format.ps1 index b6e2f35d..119747b6 100644 --- a/Types/git.status/Git.Status.format.ps1 +++ b/Types/git.status/Git.Status.format.ps1 @@ -2,6 +2,7 @@ Write-FormatView -TypeName Git.Status -Action { Write-FormatViewExpression -Text "On branch: " Write-FormatViewExpression -ScriptBlock { $_.BranchName } -if { $_.BranchName -notin 'main', 'master' } -ForegroundColor Verbose Write-FormatViewExpression -ScriptBlock { $_.BranchName } -if { $_.BranchName -in 'main', 'master' } -ForegroundColor Warning + Write-FormatViewExpression -Newline Write-FormatViewExpression -If { $_.Status -notlike 'Nothing*' } -ScriptBlock { $_.Status + [Environment]::NewLine } Write-formatviewExpression -If { $_.Staged } -ScriptBlock { "Changes Staged For Commit: diff --git a/ugit.format.ps1xml b/ugit.format.ps1xml index 7587686c..97fc61df 100644 --- a/ugit.format.ps1xml +++ b/ugit.format.ps1xml @@ -2894,6 +2894,7 @@ $BackgroundColor @(& ${ugit_Format-RichText} -ForegroundColor 'Warning' ) -join '' + $_.Status -notlike 'Nothing*' @@ -2904,7 +2905,7 @@ $BackgroundColor $_.Staged - + "Changes Staged For Commit: (use git commit -m to commit)" + [Environment]::NewLine