Skip to content

Commit 9219ba7

Browse files
committed
fix(vcs): Make URL replacements also work for the root repository
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
1 parent 85ab727 commit 9219ba7

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

plugins/version-control-systems/git/src/funTest/kotlin/GitFunTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ class GitFunTest : WordSpec({
152152
)
153153
}
154154

155+
"apply URL replacements" {
156+
val pkg = Package.EMPTY.copy(
157+
vcsProcessed = VcsInfo(VcsType.GIT, REPO_URL.replace("https://", "git://"), REPO_REV)
158+
)
159+
160+
// Using GitHub with the deprecated "git://" protocol actually hangs instead of failing explicitly.
161+
shouldCompleteWithin(10, TimeUnit.SECONDS) {
162+
git.download(pkg, outputDir)
163+
}
164+
}
165+
155166
"apply URL replacements recursively" {
156167
val url = "https://github.com/oss-review-toolkit/ort-test-data-git-submodules.git"
157168
val pkg = Package.EMPTY.copy(vcsProcessed = VcsInfo(VcsType.GIT, url, "git-protocol-submodule-urls"))

plugins/version-control-systems/git/src/main/kotlin/Git.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ class Git(
182182
gitInfoDir.resolve("sparse-checkout").writeText(globPatterns.joinToString("\n"))
183183
}
184184

185+
REPOSITORY_URL_PREFIX_REPLACEMENTS.groupBy(
186+
{ it.second }, { it.first }
187+
).forEach { (replacement, prefixes) ->
188+
git.repository.config.setStringList("url", replacement, "insteadOf", prefixes)
189+
}
190+
185191
git.repository.config.save()
186192
}
187193
} catch (e: GitAPIException) {

0 commit comments

Comments
 (0)