Skip to content

Commit

Permalink
Fix sourceFor for GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
fthomas committed Jul 1, 2019
1 parent 0e98ec0 commit ad7f55f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
package org.scalasteward.core.github

import org.scalasteward.core.model.Update
import org.scalasteward.core.vcs.data.Repo
import org.scalasteward.core.vcs
import org.scalasteward.core.git
import org.scalasteward.core.vcs.VCSSpecifics
import org.scalasteward.core.vcs.data.Repo

class GitHubSpecifics extends VCSSpecifics {
override def sourceFor(repo: Repo, update: Update): String =
s"${vcs.headFor(repo.owner, update)}:${git.branchFor(update).name}"
override def headForListingPullRequests(fork: Repo, update: Update): String =
vcs.headFor(fork.show, update)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ import org.scalasteward.core.git
import org.scalasteward.core.vcs.VCSSpecifics

class GitlabSpecifics extends VCSSpecifics {
override def sourceFor(repo: Repo, update: Update): String =
override def headForListingPullRequests(fork: Repo, update: Update): String =
git.branchFor(update).name
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ final class NurtureAlg[F[_]](
def processUpdate(data: UpdateData): F[Unit] =
for {
_ <- logger.info(s"Process update ${data.update.show}")
head = vcsSpecifics.sourceFor(data.repo, data.update)
head = vcsSpecifics.headForListingPullRequests(data.fork, data.update)
pullRequests <- vcsApiAlg.listPullRequests(data.repo, head, data.baseBranch)
_ <- pullRequests.headOption match {
case Some(pr) if pr.isClosed =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ import org.scalasteward.core.model.Update
import org.scalasteward.core.vcs.data.Repo

trait VCSSpecifics {
def sourceFor(repo: Repo, update: Update): String

/** Determines the `head` (GitHub) / `source_branch` (GitLab) parameter for searching
* for already existing pull requests.
*/
def headForListingPullRequests(fork: Repo, update: Update): String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.scalasteward.core.github

import org.scalasteward.core.model.Update
import org.scalasteward.core.vcs.data.Repo
import org.scalatest.{FunSuite, Matchers}
import org.scalasteward.core.util.Nel

class GitHubSpecificsTest extends FunSuite with Matchers {
val specifics = new GitHubSpecifics

test("headForListingPullRequests") {
specifics.headForListingPullRequests(
Repo("scala-steward", "bar"),
Update.Single("ch.qos.logback", "logback-classic", "1.2.0", Nel.of("1.2.3"))
) shouldBe "scala-steward/bar:update/logback-classic-1.2.3"
}
}

0 comments on commit ad7f55f

Please sign in to comment.