Skip to content
Permalink
Browse files

Add CHANGES as basename of possible changelog filenames (#1085)

`CHANGES.md` is used by Monix for example:
fthomas/refined-sjs-example#69

Without this, we link to `RELEASES.md` (which describes Monix'
release process):
softwaremill/bootzooka#206
  • Loading branch information...
fthomas committed Nov 8, 2019
1 parent 2976b40 commit 1564d9fcbaefddfec5f17ffca66e3ba9d4491245
@@ -37,6 +37,6 @@ object VCSExtraAlg {
vcs.possibleCompareUrls(repoUrl, update).findM(existenceClient.exists)

override def getReleaseNoteUrl(repoUrl: String, update: Update): F[Option[String]] =
vcs.possibleReleaseNoteFiles(repoUrl, update).findM(existenceClient.exists)
vcs.possibleChangelogUrls(repoUrl, update).findM(existenceClient.exists)
}
}
@@ -16,6 +16,7 @@

package org.scalasteward.core

import cats.implicits._
import org.scalasteward.core.application.SupportedVCS
import org.scalasteward.core.application.SupportedVCS.{Bitbucket, BitbucketServer, GitHub, Gitlab}
import org.scalasteward.core.data.Update
@@ -49,6 +50,21 @@ package object vcs {
def possibleTags(version: String): List[String] =
List(s"v$version", version, s"release-$version")

val possibleChangelogFilenames: List[String] = {
val basenames = List(
"CHANGELOG",
"Changelog",
"changelog",
"CHANGES",
"ReleaseNotes",
"RELEASES",
"Releases",
"releases"
)
val extensions = List("md", "markdown", "rst")
(basenames, extensions).mapN { case (base, ext) => s"$base.$ext" }
}

def possibleCompareUrls(repoUrl: String, update: Update): List[String] = {
val from = update.currentVersion
val to = update.nextVersion
@@ -65,7 +81,7 @@ package object vcs {
List.empty
}

def possibleReleaseNoteFiles(repoUrl: String, update: Update): List[String] = {
def possibleChangelogUrls(repoUrl: String, update: Update): List[String] = {
val canonicalized = repoUrl.replaceAll("/$", "")
val vcsSpecific =
if (repoUrl.startsWith("https://github.com/"))
@@ -82,18 +98,7 @@ package object vcs {
None
}
pathToFile.toList.flatMap { path =>
for {
name <- List(
"CHANGELOG",
"Changelog",
"changelog",
"RELEASES",
"Releases",
"releases",
"ReleaseNotes"
)
ext <- List("md", "markdown", "rst")
} yield s"${canonicalized}/${path}/${name}.${ext}"
possibleChangelogFilenames.map(name => s"${canonicalized}/${path}/$name")
}
}
files ++ vcsSpecific
@@ -48,9 +48,8 @@ class VCSPackageTest extends AnyFunSuite with Matchers {
possibleCompareUrls("https://scalacenter.github.io/scalafix/", update) shouldBe List()
}

test("possibleReleaseNoteFiles") {
// blob/<branch>
possibleReleaseNoteFiles("https://github.com/foo/bar", update) shouldBe List(
test("possibleChangelogUrls: github.com") {
possibleChangelogUrls("https://github.com/foo/bar", update) shouldBe List(
"https://github.com/foo/bar/blob/master/CHANGELOG.md",
"https://github.com/foo/bar/blob/master/CHANGELOG.markdown",
"https://github.com/foo/bar/blob/master/CHANGELOG.rst",
@@ -60,6 +59,12 @@ class VCSPackageTest extends AnyFunSuite with Matchers {
"https://github.com/foo/bar/blob/master/changelog.md",
"https://github.com/foo/bar/blob/master/changelog.markdown",
"https://github.com/foo/bar/blob/master/changelog.rst",
"https://github.com/foo/bar/blob/master/CHANGES.md",
"https://github.com/foo/bar/blob/master/CHANGES.markdown",
"https://github.com/foo/bar/blob/master/CHANGES.rst",
"https://github.com/foo/bar/blob/master/ReleaseNotes.md",
"https://github.com/foo/bar/blob/master/ReleaseNotes.markdown",
"https://github.com/foo/bar/blob/master/ReleaseNotes.rst",
"https://github.com/foo/bar/blob/master/RELEASES.md",
"https://github.com/foo/bar/blob/master/RELEASES.markdown",
"https://github.com/foo/bar/blob/master/RELEASES.rst",
@@ -69,65 +74,23 @@ class VCSPackageTest extends AnyFunSuite with Matchers {
"https://github.com/foo/bar/blob/master/releases.md",
"https://github.com/foo/bar/blob/master/releases.markdown",
"https://github.com/foo/bar/blob/master/releases.rst",
"https://github.com/foo/bar/blob/master/ReleaseNotes.md",
"https://github.com/foo/bar/blob/master/ReleaseNotes.markdown",
"https://github.com/foo/bar/blob/master/ReleaseNotes.rst",
"https://github.com/foo/bar/releases/tag/v1.2.3",
"https://github.com/foo/bar/releases/tag/1.2.3",
"https://github.com/foo/bar/releases/tag/release-1.2.3"
)
}

// blob/<branch>
possibleReleaseNoteFiles("https://gitlab.com/foo/bar", update) shouldBe List(
"https://gitlab.com/foo/bar/blob/master/CHANGELOG.md",
"https://gitlab.com/foo/bar/blob/master/CHANGELOG.markdown",
"https://gitlab.com/foo/bar/blob/master/CHANGELOG.rst",
"https://gitlab.com/foo/bar/blob/master/Changelog.md",
"https://gitlab.com/foo/bar/blob/master/Changelog.markdown",
"https://gitlab.com/foo/bar/blob/master/Changelog.rst",
"https://gitlab.com/foo/bar/blob/master/changelog.md",
"https://gitlab.com/foo/bar/blob/master/changelog.markdown",
"https://gitlab.com/foo/bar/blob/master/changelog.rst",
"https://gitlab.com/foo/bar/blob/master/RELEASES.md",
"https://gitlab.com/foo/bar/blob/master/RELEASES.markdown",
"https://gitlab.com/foo/bar/blob/master/RELEASES.rst",
"https://gitlab.com/foo/bar/blob/master/Releases.md",
"https://gitlab.com/foo/bar/blob/master/Releases.markdown",
"https://gitlab.com/foo/bar/blob/master/Releases.rst",
"https://gitlab.com/foo/bar/blob/master/releases.md",
"https://gitlab.com/foo/bar/blob/master/releases.markdown",
"https://gitlab.com/foo/bar/blob/master/releases.rst",
"https://gitlab.com/foo/bar/blob/master/ReleaseNotes.md",
"https://gitlab.com/foo/bar/blob/master/ReleaseNotes.markdown",
"https://gitlab.com/foo/bar/blob/master/ReleaseNotes.rst"
)
test("possibleChangelogUrls: gitlab.com") {
possibleChangelogUrls("https://gitlab.com/foo/bar", update) shouldBe
possibleChangelogFilenames.map(name => s"https://gitlab.com/foo/bar/blob/master/$name")
}

// just <branch>
possibleReleaseNoteFiles("https://bitbucket.org/foo/bar", update) shouldBe List(
"https://bitbucket.org/foo/bar/master/CHANGELOG.md",
"https://bitbucket.org/foo/bar/master/CHANGELOG.markdown",
"https://bitbucket.org/foo/bar/master/CHANGELOG.rst",
"https://bitbucket.org/foo/bar/master/Changelog.md",
"https://bitbucket.org/foo/bar/master/Changelog.markdown",
"https://bitbucket.org/foo/bar/master/Changelog.rst",
"https://bitbucket.org/foo/bar/master/changelog.md",
"https://bitbucket.org/foo/bar/master/changelog.markdown",
"https://bitbucket.org/foo/bar/master/changelog.rst",
"https://bitbucket.org/foo/bar/master/RELEASES.md",
"https://bitbucket.org/foo/bar/master/RELEASES.markdown",
"https://bitbucket.org/foo/bar/master/RELEASES.rst",
"https://bitbucket.org/foo/bar/master/Releases.md",
"https://bitbucket.org/foo/bar/master/Releases.markdown",
"https://bitbucket.org/foo/bar/master/Releases.rst",
"https://bitbucket.org/foo/bar/master/releases.md",
"https://bitbucket.org/foo/bar/master/releases.markdown",
"https://bitbucket.org/foo/bar/master/releases.rst",
"https://bitbucket.org/foo/bar/master/ReleaseNotes.md",
"https://bitbucket.org/foo/bar/master/ReleaseNotes.markdown",
"https://bitbucket.org/foo/bar/master/ReleaseNotes.rst"
)
test("possibleChangelogUrls: bitbucket.org") {
possibleChangelogUrls("https://bitbucket.org/foo/bar", update) shouldBe
possibleChangelogFilenames.map(name => s"https://bitbucket.org/foo/bar/master/$name")
}

// Empty for homepage
possibleReleaseNoteFiles("https://scalacenter.github.io/scalafix/", update) shouldBe List()
test("possibleChangelogUrls: homepage") {
possibleChangelogUrls("https://scalacenter.github.io/scalafix/", update) shouldBe List()
}
}

0 comments on commit 1564d9f

Please sign in to comment.
You can’t perform that action at this time.