Created
December 20, 2019 22:34
-
-
Save chetkhatri/6524b2d940ee4176c0361c17dba99a5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private def monotonizeCommitTimestamps[T <: CommitMarker](commits: Array[T]): Array[T] = { | |
var i = 0 | |
val length = commits.length | |
while (i < length - 1) { | |
val prevTimestamp = commits(i).getTimestamp | |
assert(commits(i).getVersion < commits(i + 1).getVersion, "Unordered commits provided.") | |
if (prevTimestamp >= commits(i + 1).getTimestamp) { | |
logWarning(s"Found Delta commit ${commits(i).getVersion} with a timestamp $prevTimestamp " + | |
s"which is greater than the next commit timestamp ${commits(i + 1).getTimestamp}.") | |
commits(i + 1) = commits(i + 1).withTimestamp(prevTimestamp + 1).asInstanceOf[T] | |
} | |
i += 1 | |
} | |
commits | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment