Skip to content

Commit

Permalink
Add a guard to PureGitExtendedFileCommit>>#initializeFromParent: for …
Browse files Browse the repository at this point in the history
…when the estimated number of lines becomes zero
  • Loading branch information
svenvc committed Nov 4, 2024
1 parent cfd5043 commit cef2aca
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Iceberg-Git-CLI/PureGitExtendedFileCommit.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,23 @@ PureGitExtendedFileCommit >> initializeAsFirst [

{ #category : #operations }
PureGitExtendedFileCommit >> initializeFromParent: parent [
| authorFraction |
| authorFraction correction |
self numberOfLines: parent numberOfLines + self numberOfLinesChanged.
parent authors keysAndValuesDo: [ :author :fraction |
correction := self numberOfLines - self numberOfLinesAdded.
self numberOfLines > 0
ifTrue: [ correction := correction / self numberOfLines ].
self authors
at: author
put: fraction * (self numberOfLines - self numberOfLinesAdded) / self numberOfLines ].
put: fraction * correction ].
authorFraction := self authors
at: self author ifAbsent: [ 0.0 ].
correction := self numberOfLinesAdded.
self numberOfLines > 0
ifTrue: [ correction := correction / self numberOfLines ].
self authors
at: self author
put: authorFraction + (self numberOfLinesAdded / self numberOfLines).
put: authorFraction + correction
]

{ #category : #accessing }
Expand Down

0 comments on commit cef2aca

Please sign in to comment.