Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 13 additions & 12 deletions Types/git.status/Git.Status.format.ps1
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
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
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
}
Write-FormatViewExpression -If { $_.Staged } -ScriptBlock {
(@(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 <file> to add, git restore <file> to discard changes)" + [Environment]::NewLine
}
Expand All @@ -23,7 +23,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:
Expand All @@ -34,11 +34,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
}
} -ForegroundColor Red

Write-FormatViewExpression -if {
$gitStatus = $_
(-not $gitStatus.Untracked) -and (-not $gitStatus.Unstaged) -and (-not $gitStatus.Staged)
} -Text "Nothing to commit, working tree clean"

} -GroupByProperty GitRoot
Write-FormatViewExpression -ScriptBlock {
if(($_.Untracked.Count + $_.Unstaged.Count + $_.Staged.Count) -eq 0)
{
"Nothing to commit, working tree clean"
}
}
}
54 changes: 47 additions & 7 deletions ugit.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -2826,14 +2826,11 @@ $BackgroundColor
<ViewSelectedBy>
<TypeName>Git.Status</TypeName>
</ViewSelectedBy>
<GroupBy>
<PropertyName>GitRoot</PropertyName>
</GroupBy>
<CustomControl>
<CustomEntries>
<CustomEntry>
<CustomItem>
<Text>On Branch: </Text>
<Text>On branch: </Text>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.BranchName -notin 'main', 'master' </ScriptBlock>
Expand Down Expand Up @@ -2908,11 +2905,17 @@ $BackgroundColor
<ItemSelectionCondition>
<ScriptBlock> $_.Staged </ScriptBlock>
</ItemSelectionCondition>
<ScriptBlock>
<ScriptBlock>
"Changes Staged For Commit:
(use git commit -m to commit)" + [Environment]::NewLine
</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Staged </ScriptBlock>
</ItemSelectionCondition>
<ScriptBlock>@(&amp; ${ugit_Format-RichText} -ForegroundColor 'Green' -NoClear) -join ''</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Staged </ScriptBlock>
Expand All @@ -2923,15 +2926,27 @@ $BackgroundColor
}) -join [Environment]::NewLine) + [Environment]::NewLine
</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Staged </ScriptBlock>
</ItemSelectionCondition>
<ScriptBlock>@(&amp; ${ugit_Format-RichText} -ForegroundColor 'Green' ) -join ''</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Unstaged </ScriptBlock>
</ItemSelectionCondition>
<ScriptBlock>
<ScriptBlock>
"Changes Not Staged For Commit:
(use git add &lt;file&gt; to add, git restore &lt;file&gt; to discard changes)" + [Environment]::NewLine
</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Unstaged</ScriptBlock>
</ItemSelectionCondition>
<ScriptBlock>@(&amp; ${ugit_Format-RichText} -ForegroundColor 'Red' -NoClear) -join ''</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Unstaged</ScriptBlock>
Expand All @@ -2942,6 +2957,12 @@ $BackgroundColor
}) -join [Environment]::NewLine) + [Environment]::NewLine
</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Unstaged</ScriptBlock>
</ItemSelectionCondition>
<ScriptBlock>@(&amp; ${ugit_Format-RichText} -ForegroundColor 'Red' ) -join ''</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Untracked </ScriptBlock>
Expand All @@ -2951,6 +2972,12 @@ $BackgroundColor
(use git add &lt;file&gt; to include in commit)" + [Environment]::NewLine
</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Untracked</ScriptBlock>
</ItemSelectionCondition>
<ScriptBlock>@(&amp; ${ugit_Format-RichText} -ForegroundColor 'Red' -NoClear) -join ''</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Untracked</ScriptBlock>
Expand All @@ -2961,7 +2988,20 @@ $BackgroundColor
}) -join [Environment]::NewLine
</ScriptBlock>
</ExpressionBinding>
<Text>Nothing to commit, working tree clean</Text>
<ExpressionBinding>
<ItemSelectionCondition>
<ScriptBlock> $_.Untracked</ScriptBlock>
</ItemSelectionCondition>
<ScriptBlock>@(&amp; ${ugit_Format-RichText} -ForegroundColor 'Red' ) -join ''</ScriptBlock>
</ExpressionBinding>
<ExpressionBinding>
<ScriptBlock>
if(($_.Untracked.Count + $_.Unstaged.Count + $_.Staged.Count) -eq 0)
{
"Nothing to commit, working tree clean"
}
</ScriptBlock>
</ExpressionBinding>
</CustomItem>
</CustomEntry>
</CustomEntries>
Expand Down