Formats/LibGit2Sharp.Commit.Format.ps1xml

<?xml version="1.0" encoding="utf-8" ?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<Configuration>
    <ViewDefinitions>
        <!-- Resembles the git log output with format=medium (default) -->
        <View>
            <Name>Medium</Name>
            <ViewSelectedBy>
                <TypeName>LibGit2Sharp.Commit</TypeName>
            </ViewSelectedBy>
            <ListControl>
                <ListEntries>
                    <ListEntry>
                        <ListItems>
                            <ListItem>
                                <!-- Yellow -->
                                <Label>&#27;[33mSha</Label>
                                <ScriptBlock>"$($_.Sha)`e[0m"</ScriptBlock>
                            </ListItem>
                            <ListItem>
                                <Label>Author</Label>
                                <PropertyName>Author</PropertyName>
                            </ListItem>
                            <ListItem>
                                <Label>Date</Label>
                                <ScriptBlock>"$($_.Author.When)"</ScriptBlock>
                            </ListItem>
                            <ListItem>
                                <Label>Message</Label>
                                <ScriptBlock>
                                    $_.Message.Trim()
                                </ScriptBlock>
                            </ListItem>
                        </ListItems>
                    </ListEntry>
                </ListEntries>
            </ListControl>
        </View>
        <!-- Resembles the git log output with format=full -->
        <View>
            <Name>Full</Name>
            <ViewSelectedBy>
                <TypeName>LibGit2Sharp.Commit</TypeName>
            </ViewSelectedBy>
            <ListControl>
                <ListEntries>
                    <ListEntry>
                        <ListItems>
                            <ListItem>
                                <!-- Yellow -->
                                <Label>&#27;[33mSha</Label>
                                <ScriptBlock>"$($_.Sha)`e[0m"</ScriptBlock>
                            </ListItem>
                            <ListItem>
                                <Label>Author</Label>
                                <PropertyName>Author</PropertyName>
                            </ListItem>
                            <ListItem>
                                <Label>Committer</Label>
                                <PropertyName>Committer</PropertyName>
                            </ListItem>
                            <ListItem>
                                <Label>Message</Label>
                                <ScriptBlock>$_.Message.Trim()</ScriptBlock>
                            </ListItem>
                        </ListItems>
                    </ListEntry>
                </ListEntries>
            </ListControl>
        </View>
        <!-- Resembles the default git log output with format=fuller -->
        <View>
            <Name>Fuller</Name>
            <ViewSelectedBy>
                <TypeName>LibGit2Sharp.Commit</TypeName>
            </ViewSelectedBy>
            <ListControl>
                <ListEntries>
                    <ListEntry>
                        <ListItems>
                            <ListItem>
                                <!-- Yellow -->
                                <Label>&#27;[33mSha</Label>
                                <ScriptBlock>"$($_.Sha)`e[0m"</ScriptBlock>
                            </ListItem>
                            <ListItem>
                                <Label>Author</Label>
                                <PropertyName>Author</PropertyName>
                            </ListItem>
                            <ListItem>
                                <Label>AuthorDate</Label>
                                <ScriptBlock>$_.Author.When</ScriptBlock>
                            </ListItem>
                            <ListItem>
                                <Label>Committer</Label>
                                <PropertyName>Committer</PropertyName>
                            </ListItem>
                            <ListItem>
                                <Label>CommitterDate</Label>
                                <ScriptBlock>$_.Committer.When</ScriptBlock>
                            </ListItem>
                            <ListItem>
                                <Label>Message</Label>
                                <ScriptBlock>$_.Message.Trim()</ScriptBlock>
                            </ListItem>
                        </ListItems>
                    </ListEntry>
                </ListEntries>
            </ListControl>
        </View>
        <!-- Resembles the default git log output with format=fuller and patch -->
        <View>
            <Name>Patch</Name>
            <ViewSelectedBy>
                <TypeName>LibGit2Sharp.Commit</TypeName>
            </ViewSelectedBy>
            <ListControl>
                <ListEntries>
                    <ListEntry>
                        <ListItems>
                            <ListItem>
                                <!-- Yellow -->
                                <Label>&#27;[33mSha</Label>
                                <ScriptBlock>"$($_.Sha)`e[0m"</ScriptBlock>
                            </ListItem>
                            <ListItem>
                                <Label>Author</Label>
                                <PropertyName>Author</PropertyName>
                            </ListItem>
                            <ListItem>
                                <Label>AuthorDate</Label>
                                <ScriptBlock>$_.Author.When</ScriptBlock>
                            </ListItem>
                            <ListItem>
                                <Label>Committer</Label>
                                <PropertyName>Committer</PropertyName>
                            </ListItem>
                            <ListItem>
                                <Label>CommitterDate</Label>
                                <ScriptBlock>$_.Committer.When</ScriptBlock>
                            </ListItem>
                            <ListItem>
                                <Label>Message</Label>
                                <ScriptBlock>
                                    $_.Message.Trim()
                                </ScriptBlock>
                            </ListItem>
                            <ListItem>
                                <Label>Patch</Label>
                                <ScriptBlock>
                                    $parent = [System.Linq.Enumerable]::FirstOrDefault($_.Parents)
                                    $getPatch = $_.Repository.Diff.GetType().GetMethod('Compare', [Type[]]@([LibGit2Sharp.Tree], [LibGit2Sharp.Tree])).MakeGenericMethod([LibGit2Sharp.Patch])
                                    $getPatch.Invoke($_.Repository.Diff, @($_.Tree, $parent.Tree)) | ConvertTo-ColoredPatch
                                </ScriptBlock>
                            </ListItem>
                        </ListItems>
                    </ListEntry>
                </ListEntries>
            </ListControl>
        </View>
        <!-- Resembles the git log output with format=oneline -->
        <View>
            <Name>Oneline</Name>
            <ViewSelectedBy>
                <TypeName>LibGit2Sharp.Commit</TypeName>
            </ViewSelectedBy>
            <TableControl>
                <AutoSize />
                <TableHeaders>
                    <TableColumnHeader>
                        <Label>Sha</Label>
                    </TableColumnHeader>
                    <TableColumnHeader>
                        <Label>Message</Label>
                    </TableColumnHeader>
                </TableHeaders>
                <TableRowEntries>
                    <TableRowEntry>
                        <TableColumnItems>
                            <TableColumnItem>
                                <!-- Yellow -->
                                <ScriptBlock>"`e[33m$($_.Sha.Substring(0, 7))`e[0m"</ScriptBlock>
                            </TableColumnItem>
                            <TableColumnItem>
                                <PropertyName>MessageShort</PropertyName>
                            </TableColumnItem>
                        </TableColumnItems>
                    </TableRowEntry>
                </TableRowEntries>
            </TableControl>
        </View>
    </ViewDefinitions>
</Configuration>