Skip to content

Commit 1cf835f

Browse files
author
exoego
committed
Fix possibleReleaseNoteFiles
* GitHub & GitLab: "/owner/repo/blob/<branch>/path/to/file" * BitBucket: "/owner/repo/<branch>/path/to/file" * Other pages: Empty to skip release note detection
1 parent d7783d3 commit 1cf835f

File tree

2 files changed

+89
-4
lines changed

2 files changed

+89
-4
lines changed

modules/core/src/main/scala/org/scalasteward/core/vcs/package.scala

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,22 @@ package object vcs {
7575
)
7676
else
7777
List.empty
78-
val files = for {
79-
name <- List("CHANGELOG", "Changelog", "changelog", "RELEASES", "Releases", "releases")
80-
ext <- List("md", "markdown", "rst")
81-
} yield s"${canonicalized}/${name}.${ext}"
78+
val files = {
79+
val pathToFile =
80+
if (repoUrl.startsWith("https://github.com/") || repoUrl.startsWith("https://gitlab.com/")) {
81+
Some("blob/master")
82+
} else if (repoUrl.startsWith("https://bitbucket.org/")) {
83+
Some("master")
84+
} else {
85+
None
86+
}
87+
pathToFile.toList.flatMap { path =>
88+
for {
89+
name <- List("CHANGELOG", "Changelog", "changelog", "RELEASES", "Releases", "releases")
90+
ext <- List("md", "markdown", "rst")
91+
} yield s"${canonicalized}/${path}/${name}.${ext}"
92+
}
93+
}
8294
files ++ vcsSpecific
8395
}
8496
}

modules/core/src/test/scala/org/scalasteward/core/vcs/VCSPackageTest.scala

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,77 @@ class VCSPackageTest extends AnyFunSuite with Matchers {
4343

4444
possibleCompareUrls("https://scalacenter.github.io/scalafix/", update) shouldBe List()
4545
}
46+
47+
test("possibleReleaseNoteFiles") {
48+
// blob/<branch>
49+
possibleReleaseNoteFiles("https://github.com/foo/bar", update) shouldBe List(
50+
"https://github.com/foo/bar/blob/master/CHANGELOG.md",
51+
"https://github.com/foo/bar/blob/master/CHANGELOG.markdown",
52+
"https://github.com/foo/bar/blob/master/CHANGELOG.rst",
53+
"https://github.com/foo/bar/blob/master/Changelog.md",
54+
"https://github.com/foo/bar/blob/master/Changelog.markdown",
55+
"https://github.com/foo/bar/blob/master/Changelog.rst",
56+
"https://github.com/foo/bar/blob/master/changelog.md",
57+
"https://github.com/foo/bar/blob/master/changelog.markdown",
58+
"https://github.com/foo/bar/blob/master/changelog.rst",
59+
"https://github.com/foo/bar/blob/master/RELEASES.md",
60+
"https://github.com/foo/bar/blob/master/RELEASES.markdown",
61+
"https://github.com/foo/bar/blob/master/RELEASES.rst",
62+
"https://github.com/foo/bar/blob/master/Releases.md",
63+
"https://github.com/foo/bar/blob/master/Releases.markdown",
64+
"https://github.com/foo/bar/blob/master/Releases.rst",
65+
"https://github.com/foo/bar/blob/master/releases.md",
66+
"https://github.com/foo/bar/blob/master/releases.markdown",
67+
"https://github.com/foo/bar/blob/master/releases.rst",
68+
"https://github.com/foo/bar/releases/tag/1.2.3",
69+
"https://github.com/foo/bar/releases/tag/v1.2.3"
70+
)
71+
72+
// blob/<branch>
73+
possibleReleaseNoteFiles("https://gitlab.com/foo/bar", update) shouldBe List(
74+
"https://gitlab.com/foo/bar/blob/master/CHANGELOG.md",
75+
"https://gitlab.com/foo/bar/blob/master/CHANGELOG.markdown",
76+
"https://gitlab.com/foo/bar/blob/master/CHANGELOG.rst",
77+
"https://gitlab.com/foo/bar/blob/master/Changelog.md",
78+
"https://gitlab.com/foo/bar/blob/master/Changelog.markdown",
79+
"https://gitlab.com/foo/bar/blob/master/Changelog.rst",
80+
"https://gitlab.com/foo/bar/blob/master/changelog.md",
81+
"https://gitlab.com/foo/bar/blob/master/changelog.markdown",
82+
"https://gitlab.com/foo/bar/blob/master/changelog.rst",
83+
"https://gitlab.com/foo/bar/blob/master/RELEASES.md",
84+
"https://gitlab.com/foo/bar/blob/master/RELEASES.markdown",
85+
"https://gitlab.com/foo/bar/blob/master/RELEASES.rst",
86+
"https://gitlab.com/foo/bar/blob/master/Releases.md",
87+
"https://gitlab.com/foo/bar/blob/master/Releases.markdown",
88+
"https://gitlab.com/foo/bar/blob/master/Releases.rst",
89+
"https://gitlab.com/foo/bar/blob/master/releases.md",
90+
"https://gitlab.com/foo/bar/blob/master/releases.markdown",
91+
"https://gitlab.com/foo/bar/blob/master/releases.rst"
92+
)
93+
94+
// just <branch>
95+
possibleReleaseNoteFiles("https://bitbucket.org/foo/bar", update) shouldBe List(
96+
"https://bitbucket.org/foo/bar/master/CHANGELOG.md",
97+
"https://bitbucket.org/foo/bar/master/CHANGELOG.markdown",
98+
"https://bitbucket.org/foo/bar/master/CHANGELOG.rst",
99+
"https://bitbucket.org/foo/bar/master/Changelog.md",
100+
"https://bitbucket.org/foo/bar/master/Changelog.markdown",
101+
"https://bitbucket.org/foo/bar/master/Changelog.rst",
102+
"https://bitbucket.org/foo/bar/master/changelog.md",
103+
"https://bitbucket.org/foo/bar/master/changelog.markdown",
104+
"https://bitbucket.org/foo/bar/master/changelog.rst",
105+
"https://bitbucket.org/foo/bar/master/RELEASES.md",
106+
"https://bitbucket.org/foo/bar/master/RELEASES.markdown",
107+
"https://bitbucket.org/foo/bar/master/RELEASES.rst",
108+
"https://bitbucket.org/foo/bar/master/Releases.md",
109+
"https://bitbucket.org/foo/bar/master/Releases.markdown",
110+
"https://bitbucket.org/foo/bar/master/Releases.rst",
111+
"https://bitbucket.org/foo/bar/master/releases.md",
112+
"https://bitbucket.org/foo/bar/master/releases.markdown",
113+
"https://bitbucket.org/foo/bar/master/releases.rst"
114+
)
115+
116+
// Empty for homepage
117+
possibleReleaseNoteFiles("https://scalacenter.github.io/scalafix/", update) shouldBe List()
118+
}
46119
}

0 commit comments

Comments
 (0)