diff --git a/modules/core/src/main/scala/org/scalasteward/core/forge/github/GitHubApiAlg.scala b/modules/core/src/main/scala/org/scalasteward/core/forge/github/GitHubApiAlg.scala index 18c4a1f7c6..acdda79b8b 100644 --- a/modules/core/src/main/scala/org/scalasteward/core/forge/github/GitHubApiAlg.scala +++ b/modules/core/src/main/scala/org/scalasteward/core/forge/github/GitHubApiAlg.scala @@ -99,7 +99,7 @@ final class GitHubApiAlg[F[_]]( F.raiseWhen(repoOut.archived)(RepositoryArchived(repo)) } - /** https://docs.github.com/en/rest/pulls?apiVersion=2022-11-28#list-pull-requests */ + /** https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#list-pull-requests */ override def listPullRequests(repo: Repo, head: String, base: Branch): F[List[PullRequestOut]] = client.get(url.listPullRequests(repo, head, base), modify) diff --git a/modules/core/src/main/scala/org/scalasteward/core/forge/package.scala b/modules/core/src/main/scala/org/scalasteward/core/forge/package.scala index 95c934aa6c..7533c78471 100644 --- a/modules/core/src/main/scala/org/scalasteward/core/forge/package.scala +++ b/modules/core/src/main/scala/org/scalasteward/core/forge/package.scala @@ -23,21 +23,9 @@ import org.scalasteward.core.git.Branch package object forge { /** Determines the `head` (GitHub) / `source_branch` (GitLab, Bitbucket) parameter for searching - * for already existing pull requests. + * for already existing pull requests or creating new pull requests. */ - def listingBranch(forgeType: ForgeType, fork: Repo, updateBranch: Branch): String = - forgeType match { - case GitHub => - s"${fork.owner}/${fork.repo}:${updateBranch.name}" - - case GitLab | Bitbucket | BitbucketServer | AzureRepos | Gitea => - updateBranch.name - } - - /** Determines the `head` (GitHub) / `source_branch` (GitLab, Bitbucket) parameter for creating a - * new pull requests. - */ - def createBranch(forgeType: ForgeType, fork: Repo, updateBranch: Branch): String = + def headFor(forgeType: ForgeType, fork: Repo, updateBranch: Branch): String = forgeType match { case GitHub => s"${fork.owner}:${updateBranch.name}" diff --git a/modules/core/src/main/scala/org/scalasteward/core/nurture/NurtureAlg.scala b/modules/core/src/main/scala/org/scalasteward/core/nurture/NurtureAlg.scala index 856753d702..d552a25ec4 100644 --- a/modules/core/src/main/scala/org/scalasteward/core/nurture/NurtureAlg.scala +++ b/modules/core/src/main/scala/org/scalasteward/core/nurture/NurtureAlg.scala @@ -92,7 +92,7 @@ final class NurtureAlg[F[_]](config: ForgeCfg)(implicit private def processUpdate(data: UpdateData): F[ProcessResult] = for { _ <- logger.info(s"Process update ${data.update.show}") - head = forge.listingBranch(config.tpe, data.fork, data.updateBranch) + head = forge.headFor(config.tpe, data.fork, data.updateBranch) pullRequests <- forgeApiAlg.listPullRequests(data.repo, head, data.baseBranch) result <- pullRequests.headOption match { case Some(pr) if pr.state.isClosed && data.update.isInstanceOf[Update.Single] => @@ -230,7 +230,7 @@ final class NurtureAlg[F[_]](config: ForgeCfg)(implicit .on(u => List(u.currentVersion.value), _.updates.map(_.currentVersion.value)) .flatTraverse(gitAlg.findFilesContaining(data.repo, _)) .map(_.distinct) - branchName = forge.createBranch(config.tpe, data.fork, data.updateBranch) + branchName = forge.headFor(config.tpe, data.fork, data.updateBranch) allLabels = labelsFor(data.update, edits, filesWithOldVersion, artifactIdToVersionScheme) labels = filterLabels(allLabels, data.repoData.config.pullRequests.includeMatchedLabels) requestData = NewPullRequestData.from( diff --git a/modules/core/src/test/scala/org/scalasteward/core/forge/ForgePackageTest.scala b/modules/core/src/test/scala/org/scalasteward/core/forge/ForgePackageTest.scala index add624510b..ade11d0b49 100644 --- a/modules/core/src/test/scala/org/scalasteward/core/forge/ForgePackageTest.scala +++ b/modules/core/src/test/scala/org/scalasteward/core/forge/ForgePackageTest.scala @@ -16,14 +16,9 @@ class ForgePackageTest extends FunSuite { val update = ("ch.qos.logback".g % "logback-classic".a % "1.2.0" %> "1.2.3").single val updateBranch = git.branchFor(update, None) - test("listingBranch (single)") { - assertEquals(listingBranch(GitHub, repo, updateBranch), s"foo/bar:${updateBranch.name}") - assertEquals(listingBranch(GitLab, repo, updateBranch), updateBranch.name) - } - - test("createBranch (single)") { - assertEquals(createBranch(GitHub, repo, updateBranch), s"foo:${updateBranch.name}") - assertEquals(createBranch(GitLab, repo, updateBranch), updateBranch.name) + test("headFor (single)") { + assertEquals(headFor(GitHub, repo, updateBranch), s"foo:${updateBranch.name}") + assertEquals(headFor(GitLab, repo, updateBranch), updateBranch.name) } } @@ -40,14 +35,9 @@ class ForgePackageTest extends FunSuite { val updateBranch = git.branchFor(update, None) - test("listingBranch (grouped)") { - assertEquals(listingBranch(GitHub, repo, updateBranch), s"foo/bar:update/my-group") - assertEquals(listingBranch(GitLab, repo, updateBranch), updateBranch.name) - } - - test("createBranch (grouped)") { - assertEquals(createBranch(GitHub, repo, updateBranch), s"foo:update/my-group") - assertEquals(createBranch(GitLab, repo, updateBranch), updateBranch.name) + test("headFor (grouped)") { + assertEquals(headFor(GitHub, repo, updateBranch), s"foo:update/my-group") + assertEquals(headFor(GitLab, repo, updateBranch), updateBranch.name) } } @@ -62,16 +52,10 @@ class ForgePackageTest extends FunSuite { val updateBranch = git.branchFor(update, None) - test("listingBranch (grouped) with $hash") { - assertEquals(listingBranch(GitHub, repo, updateBranch), s"foo/bar:update/my-group-1164623676") - assertEquals(listingBranch(GitLab, repo, updateBranch), updateBranch.name) + test("headFor (grouped) with $hash") { + assertEquals(headFor(GitHub, repo, updateBranch), s"foo:update/my-group-1164623676") + assertEquals(headFor(GitLab, repo, updateBranch), updateBranch.name) } - - test("createBranch (grouped) with $hash") { - assertEquals(createBranch(GitHub, repo, updateBranch), s"foo:update/my-group-1164623676") - assertEquals(createBranch(GitLab, repo, updateBranch), updateBranch.name) - } - } }