@@ -6,45 +6,52 @@ enum Part {
6
6
None
7
7
}
8
8
9
- function Get-Log {
10
- [CmdletBinding ()]
11
- param ()
12
- # # We have to transform the object to keep the data around after .Dispose()
13
- $Branches = $repo.Branches | Select-Object CanonicalName, FriendlyName, Is* , RemoteName, Tip, Track* , Upstream* , Ahead, Behind
14
-
15
- $Tags = @ ($repo.Tags )
16
- $Log = $repo.Commits | Select-Object Id,
17
- @ {name = " Branch" ; expr = { $c = $_ ; $Branches.Where {$c.Id -eq $_.Tip.Id } }},
18
- @ {name = " Tags" ; expr = { $c = $_ ; $Tags.Where {$c.Id -eq $_.Target.Id } }},
19
- Parents, Author,
20
- @ {name = " Date" ; expr = { $_.Author.When }},
21
- @ {name = " Message" ; expr = { $_.MessageShort }} |
22
- ForEach-Object { $_.PSTypeNames.Insert (0 , " PSGit.Commit" ), $_ }
23
-
24
- # Make the branch tip be one of the objects in the Log
25
- foreach ($branch in $Branches ) {
26
- $branch.Tip = $Log.Where ( {$_.Id -eq $branch.Tip.Id }, 1 )
27
- }
9
+ function Get-Log {
10
+ [CmdletBinding ()]
11
+ param ()
12
+ # # We have to transform the object to keep the data around after .Dispose()
13
+ $Branches = $repo.Branches | Select-Object CanonicalName, FriendlyName, Is* ,
14
+ RemoteName, Tip, Track* , Upstream* , Ahead, Behind,
15
+ @ {name = " IsMerged" ; expr = { $false } }
16
+
17
+ $Tags = @ ($repo.Tags )
18
+ $Log = $repo.Commits | Select-Object Id,
19
+ @ {name = " Branch" ; expr = { $c = $_ ; $Branches.Where ({$c.Id -eq $_.Tip.Id }, 1 ) }},
20
+ @ {name = " Tags" ; expr = { $c = $_ ; $Tags.Where {$c.Id -eq $_.Target.Id } }},
21
+ Parents, Author,
22
+ @ {name = " Date" ; expr = { $_.Author.When }},
23
+ @ {name = " Message" ; expr = { $_.MessageShort }} |
24
+ ForEach-Object { $_.PSTypeNames.Insert (0 , " PSGit.Commit" ), $_ }
25
+
26
+ # Make the branch tip be one of the objects in the Log
27
+ foreach ($branch in $Branches ) {
28
+ if ($tip = $Log.Where ( {$_.Id -eq $branch.Tip.Id }, 1 )) {
29
+ $branch.Tip = $tip
30
+ }
31
+ }
28
32
29
- # We need to fix:
30
- # - only the tips of each branch have branch data
31
- # - the parent commit objects are separate (but identical) objects
32
- foreach ($commit in $Log ) {
33
- Write-Verbose " Commit $ ( $commit.Id ) Branch: $ ( $commit.Branch.FriendlyName ) "
34
- # Reset the "Parents" to be pointers to their representation in the Log
35
- $commit.Parents = $Log.Where {$_.Id -in $commit.Parents.Id }
36
- # Set the branch on all the parents
37
- foreach ($parent in $commit.Parents ) {
38
- # How do we pick which "branch" a merge commit is in?
39
- if (! $parent.Branch ) {
40
- # Write-Verbose "+ Update $($parent.Id) Branch: $($commit.Branch.FriendlyName)"
41
- $parent.Branch = $commit.Branch
42
- }
43
- }
33
+ # We need to fix:
34
+ # - only the tips of each branch have branch data
35
+ # - the parent commit objects are separate (but identical) objects
36
+ foreach ($commit in $Log ) {
37
+ Write-Verbose " Commit $ ( $commit.Id ) Branch: $ ( $commit.Branch.FriendlyName ) "
38
+ # Reset the "Parents" to be pointers to their representation in the Log
39
+ $commit.Parents = $Log.Where {$_.Id -in $commit.Parents.Id }
40
+ # Set the branch on all the parents
41
+ foreach ($parent in $commit.Parents ) {
42
+ # A merge commit is always in the master branch
43
+ if (! $parent.Branch ) {
44
+ # Write-Verbose "+ Update $($parent.Id) Branch: $($commit.Branch.FriendlyName)"
45
+ $parent.Branch = $commit.Branch
46
+ } elseif (@ ($commit.Parents ).Count -gt 1 -and $commit.Branch.CanonicalName -ne $parent.Branch.CanonicalName ) {
47
+ Write-Verbose ($parent.Branch.FriendlyName + " was merged into " + $commit.Branch.FriendlyName )
48
+ $parent.Branch.IsMerged = $true
44
49
}
45
-
46
- Add-Member - Input $Log - Type NoteProperty - Name Branches - Value $Branches - Passthru
47
50
}
51
+ }
52
+
53
+ Add-Member - Input $Log - Type NoteProperty - Name Branches - Value $Branches - Passthru
54
+ }
48
55
49
56
function Get-GitVersion {
50
57
[CmdletBinding ()]
0 commit comments