@@ -2,6 +2,7 @@ package org.scalasteward.core.vcs
22
33import org .http4s .syntax .literals ._
44import org .scalasteward .core .TestSyntax ._
5+ import org .scalasteward .core .application .SupportedVCS
56import org .scalasteward .core .application .SupportedVCS .{GitHub , Gitlab }
67import org .scalasteward .core .data .Update
78import org .scalasteward .core .util .Nel
@@ -25,38 +26,63 @@ class VCSPackageTest extends AnyFunSuite with Matchers {
2526 }
2627
2728 test(" possibleCompareUrls" ) {
28- possibleCompareUrls(uri " https://github.com/foo/bar " , update)
29+ val onPremVCS = " https://github.onprem.io/"
30+ val onPremVCSUri = uri " https://github.onprem.io/ "
31+
32+ possibleCompareUrls(SupportedVCS .GitHub , onPremVCSUri, uri " https://github.com/foo/bar " , update)
2933 .map(_.url.renderString) shouldBe List (
3034 " https://github.com/foo/bar/compare/v1.2.0...v1.2.3" ,
3135 " https://github.com/foo/bar/compare/1.2.0...1.2.3" ,
3236 " https://github.com/foo/bar/compare/release-1.2.0...release-1.2.3"
3337 )
3438 // should canonicalize (drop last slash)
35- possibleCompareUrls(uri " https://github.com/foo/bar/ " , update)
39+ possibleCompareUrls(SupportedVCS . GitHub , onPremVCSUri, uri " https://github.com/foo/bar/ " , update)
3640 .map(_.url.renderString) shouldBe List (
3741 " https://github.com/foo/bar/compare/v1.2.0...v1.2.3" ,
3842 " https://github.com/foo/bar/compare/1.2.0...1.2.3" ,
3943 " https://github.com/foo/bar/compare/release-1.2.0...release-1.2.3"
4044 )
4145
42- possibleCompareUrls(uri " https://gitlab.com/foo/bar " , update)
46+ possibleCompareUrls(SupportedVCS . GitHub , onPremVCSUri, uri " https://gitlab.com/foo/bar " , update)
4347 .map(_.url.renderString) shouldBe List (
4448 " https://gitlab.com/foo/bar/compare/v1.2.0...v1.2.3" ,
4549 " https://gitlab.com/foo/bar/compare/1.2.0...1.2.3" ,
4650 " https://gitlab.com/foo/bar/compare/release-1.2.0...release-1.2.3"
4751 )
48- possibleCompareUrls(uri " https://bitbucket.org/foo/bar " , update)
52+ possibleCompareUrls(
53+ SupportedVCS .GitHub ,
54+ onPremVCSUri,
55+ uri " https://bitbucket.org/foo/bar " ,
56+ update
57+ )
4958 .map(_.url.renderString) shouldBe List (
5059 " https://bitbucket.org/foo/bar/compare/v1.2.3..v1.2.0#diff" ,
5160 " https://bitbucket.org/foo/bar/compare/1.2.3..1.2.0#diff" ,
5261 " https://bitbucket.org/foo/bar/compare/release-1.2.3..release-1.2.0#diff"
5362 )
5463
55- possibleCompareUrls(uri " https://scalacenter.github.io/scalafix/ " , update) shouldBe List ()
64+ possibleCompareUrls(
65+ SupportedVCS .GitHub ,
66+ onPremVCSUri,
67+ uri " https://scalacenter.github.io/scalafix/ " ,
68+ update
69+ ) shouldBe List .empty
70+
71+ possibleCompareUrls(SupportedVCS .GitHub , onPremVCSUri, onPremVCSUri.addPath(" /foo/bar" ), update)
72+ .map(_.url.renderString) shouldBe List (
73+ s " ${onPremVCS}foo/bar/compare/v1.2.0...v1.2.3 " ,
74+ s " ${onPremVCS}foo/bar/compare/1.2.0...1.2.3 " ,
75+ s " ${onPremVCS}foo/bar/compare/release-1.2.0...release-1.2.3 "
76+ )
5677 }
5778
5879 test(" possibleChangelogUrls: github.com" ) {
59- possibleReleaseRelatedUrls(uri " https://github.com/foo/bar " , update)
80+ possibleReleaseRelatedUrls(
81+ SupportedVCS .GitHub ,
82+ uri " https://github.com " ,
83+ uri " https://github.com/foo/bar " ,
84+ update
85+ )
6086 .map(_.url.renderString) shouldBe List (
6187 " https://github.com/foo/bar/releases/tag/v1.2.3" ,
6288 " https://github.com/foo/bar/releases/tag/1.2.3" ,
@@ -92,7 +118,12 @@ class VCSPackageTest extends AnyFunSuite with Matchers {
92118 }
93119
94120 test(" possibleChangelogUrls: gitlab.com" ) {
95- possibleReleaseRelatedUrls(uri " https://gitlab.com/foo/bar " , update)
121+ possibleReleaseRelatedUrls(
122+ SupportedVCS .GitHub ,
123+ uri " https://github.com " ,
124+ uri " https://gitlab.com/foo/bar " ,
125+ update
126+ )
96127 .map(_.url.renderString) shouldBe
97128 possibleReleaseNotesFilenames.map(name => s " https://gitlab.com/foo/bar/blob/master/ $name" ) ++
98129 possibleChangelogFilenames.map(name => s " https://gitlab.com/foo/bar/blob/master/ $name" ) ++
@@ -103,8 +134,34 @@ class VCSPackageTest extends AnyFunSuite with Matchers {
103134 )
104135 }
105136
137+ test(" possibleChangelogUrls: on-prem gitlab" ) {
138+ possibleReleaseRelatedUrls(
139+ SupportedVCS .Gitlab ,
140+ uri " https://gitlab.on-prem.net " ,
141+ uri " https://gitlab.on-prem.net/foo/bar " ,
142+ update
143+ )
144+ .map(_.url.renderString) shouldBe
145+ possibleReleaseNotesFilenames.map(name =>
146+ s " https://gitlab.on-prem.net/foo/bar/blob/master/ $name"
147+ ) ++
148+ possibleChangelogFilenames.map(name =>
149+ s " https://gitlab.on-prem.net/foo/bar/blob/master/ $name"
150+ ) ++
151+ List (
152+ " https://gitlab.on-prem.net/foo/bar/compare/v1.2.0...v1.2.3" ,
153+ " https://gitlab.on-prem.net/foo/bar/compare/1.2.0...1.2.3" ,
154+ " https://gitlab.on-prem.net/foo/bar/compare/release-1.2.0...release-1.2.3"
155+ )
156+ }
157+
106158 test(" possibleChangelogUrls: bitbucket.org" ) {
107- possibleReleaseRelatedUrls(uri " https://bitbucket.org/foo/bar " , update)
159+ possibleReleaseRelatedUrls(
160+ SupportedVCS .GitHub ,
161+ uri " https://github.com " ,
162+ uri " https://bitbucket.org/foo/bar " ,
163+ update
164+ )
108165 .map(_.url.renderString) shouldBe
109166 possibleReleaseNotesFilenames.map(name => s " https://bitbucket.org/foo/bar/master/ $name" ) ++
110167 possibleChangelogFilenames.map(name => s " https://bitbucket.org/foo/bar/master/ $name" ) ++
@@ -116,7 +173,12 @@ class VCSPackageTest extends AnyFunSuite with Matchers {
116173 }
117174
118175 test(" possibleChangelogUrls: homepage" ) {
119- possibleReleaseRelatedUrls(uri " https://scalacenter.github.io/scalafix/ " , update)
120- .map(_.url.renderString) shouldBe List ()
176+ possibleReleaseRelatedUrls(
177+ SupportedVCS .GitHub ,
178+ uri " https://github.com " ,
179+ uri " https://scalacenter.github.io/scalafix/ " ,
180+ update
181+ )
182+ .map(_.url.renderString) shouldBe List .empty
121183 }
122184}
0 commit comments