Skip to content

Update PR Actor to always add a combined status #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions server/src/main/scala/scabot/server/Actors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -497,20 +497,32 @@ trait Actors extends github.GithubApi with jenkins.JenkinsApi with lightbend.Lig
}

if (lastOnly(pull.title)) Future.successful(Nil)
else (for {
commits <- pullRequestCommits
else {
val temp = for {
commits <- pullRequestCommits
lastSha = commits.lastOption.map(_.sha).getOrElse("")
} yield (commits, lastSha)

lastSha = commits.lastOption.map(_.sha).getOrElse("")
if commits.nonEmpty && commits.tail.nonEmpty && causeSha != lastSha // ignore if caused by an update to the last commit

earlierStati <- Future.sequence(commits.init.map(c => githubApi.commitStatus(c.sha)))
(for {
(commits, lastSha) <- temp
if commits.nonEmpty && commits.tail.nonEmpty && causeSha != lastSha // ignore if caused by an update to the last commit

lastStss <- githubApi.commitStatus(lastSha).map(_.statuses)
earlierStati <- Future.sequence(commits.init.map(c => githubApi.commitStatus(c.sha)))

posting <- combine(earlierStati, lastSha, lastStss)
lastStss <- githubApi.commitStatus(lastSha).map(_.statuses)

} yield posting).recover { case _: NoSuchElementException => Nil }
posting <- combine(earlierStati, lastSha, lastStss)
} yield posting).recoverWith {
case _: NoSuchElementException => {
for {
(commits, lastSha) <- temp
if commits.nonEmpty && commits.tail.isEmpty
posting <- postLast(lastSha, "Single commit Pull Request", SUCCESS, List[CommitStatus]())
} yield List(posting)
}
} recover { case _: NoSuchElementException => Nil }
}
}


// MILESTONE
Expand Down