|
2 | 2 | .Synopsis |
3 | 3 | Log Extension |
4 | 4 | .Description |
5 | | - Outputs git log entries as objects |
| 5 | + Outputs git log as objects. |
6 | 6 | .Example |
7 | | - git log | Group-Object GitUserEmail -NoElement | Sort-Object Count -Descending |
8 | | -.EXAMPLE |
9 | | - git log | Where-Object -Not Merged |
10 | | -.EXAMPLE |
11 | | - git log | Group-Object { $_.CommitDate.DayOfWeek } -NoElement |
| 7 | + # Get all logs |
| 8 | + git log | |
| 9 | + # until the first merged pull request |
| 10 | + Where-Object -Not Merged |
| 11 | +.Example |
| 12 | + # Get a single log entry |
| 13 | + git log -n 1 | |
| 14 | + # and see what the log object can do. |
| 15 | + Get-Member |
| 16 | +.Example |
| 17 | + # Get all logs |
| 18 | + git log | |
| 19 | + # Group them by the author |
| 20 | + Group-Object GitUserEmail -NoElement | |
| 21 | + # sort them by count |
| 22 | + Sort-Object Count -Descending |
| 23 | +.Example |
| 24 | + # Get all logs |
| 25 | + git log | |
| 26 | + # Group them by day of week |
| 27 | + Group-Object { $_.CommitDate.DayOfWeek } -NoElement |
| 28 | +.Example |
| 29 | + # Get all logs |
| 30 | + git log | |
| 31 | + # where there is a pull request number |
| 32 | + Where-Object PullRequestNumber | |
| 33 | + # pick out the PullRequestNumber and CommitDate |
| 34 | + Select PullRequestNumber, CommitDate |
| 35 | +.Example |
| 36 | + git log --merges |
12 | 37 | #> |
13 | 38 | [Management.Automation.Cmdlet("Out","Git")] # It's an extension for Out-Git |
14 | 39 | [ValidatePattern("^git log",Options='IgnoreCase')] # when the pattern is "git log" |
@@ -66,9 +91,27 @@ begin { |
66 | 91 | if ($gitLogOut.CommitMessage) { |
67 | 92 | $gitLogOut.CommitMessage = $gitLogOut.CommitMessage.Trim() |
68 | 93 | } |
69 | | - if ($gitLogOut.MergeHash) { |
| 94 | + if ($gitLogOut.MergeHash -and |
| 95 | + $gitLogOut.CommitMessage -notmatch '^merge branch') { |
70 | 96 | $script:LogChangesMerged = $true |
| 97 | + if ($gitLogOut.CommitMessage -match '^Merge pull request \#(?<Num>\d+)') { |
| 98 | + $gitLogOut.PullRequestNumber = [int]$matches.Num |
| 99 | + } |
| 100 | + if ($gitLogOut.CommitMessage -match 'from[\r\n\s]{0,}(?<Src>\S+)') { |
| 101 | + $gitLogOut.Source = $matches.Src |
| 102 | + } |
| 103 | + } |
| 104 | + elseif ( |
| 105 | + $gitLogOut.MergeHash |
| 106 | + ) { |
| 107 | + if ($gitLogOut.CommitMessage -match "^merge branch '(?<Branch>[^']+)'") { |
| 108 | + $gitLogOut.Source = $matches.Branch |
| 109 | + } |
| 110 | + if ($gitLogOut.CommitMessage -match 'into (?<Branch>.+)$') { |
| 111 | + $gitLogOut.Destination = $matches.Branch |
| 112 | + } |
71 | 113 | } |
| 114 | + |
72 | 115 | $gitLogOut.Merged = $script:LogChangesMerged |
73 | 116 | $gitLogOut.GitRoot = $GitRoot |
74 | 117 | [PSCustomObject]$gitLogOut |
|
0 commit comments