Skip to content

Commit

Permalink
Remove previousSha from GitHUb PR events
Browse files Browse the repository at this point in the history
  • Loading branch information
rbro112 committed Oct 17, 2024
1 parent 4bc121b commit 531051e
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ internal class GitHub(private val execOperations: ExecOperations) {
fun previousSha(): String? {
return when {
isPush() -> getPushEventData().before
// In the case of the first commit on a PR, the before sha is not available.
// We want previousSha to be the last commit on main, so we'll fallback to baseSha
isPullRequest() -> getPullRequestEventData().before ?: baseSha()
// In the case of branches, `before` can't be relied on from GitHub event data, so we'll skip
// previousSha for now on `pull_request` events
else -> null
}
}
Expand Down Expand Up @@ -112,7 +111,6 @@ internal class GitHub(private val execOperations: ExecOperations) {
@SerialName("pull_request")
val pr: GitHubPullRequest,
val number: Int,
val before: String? = null,
)

@Serializable
Expand Down

0 comments on commit 531051e

Please sign in to comment.