Skip to content

Commit

Permalink
Git: Suppress interactive prompts for credentials
Browse files Browse the repository at this point in the history
The changes are confirmed to work as expected on Linux. However, while
doing no harm on Windows compared to before, the test hangs on Windows,
so only enable it on non-Windows for now.

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@here.com>
  • Loading branch information
sschuberth committed Mar 27, 2019
1 parent 3bd9491 commit 0f07ac1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion downloader/src/main/kotlin/vcs/Git.kt
Expand Up @@ -30,6 +30,7 @@ import com.here.ort.utils.ProcessCapture
import com.here.ort.utils.log
import com.here.ort.utils.safeMkdirs
import com.here.ort.utils.showStackTrace
import com.here.ort.utils.suppressInput

import com.vdurmont.semver4j.Semver

Expand All @@ -43,7 +44,9 @@ class Git : GitBase() {
override val priority: Int = 100

override fun isApplicableUrlInternal(vcsUrl: String) =
ProcessCapture("git", "ls-remote", vcsUrl).isSuccess
suppressInput {
ProcessCapture("git", "-c", "credential.helper=", "-c", "core.askpass=", "ls-remote", vcsUrl).isSuccess
}

override fun download(
pkg: Package, targetDir: File, allowMovingRevisions: Boolean,
Expand Down
5 changes: 5 additions & 0 deletions downloader/src/test/kotlin/GitTest.kt
Expand Up @@ -20,6 +20,7 @@
package com.here.ort.downloader.vcs

import com.here.ort.downloader.VersionControlSystem
import com.here.ort.utils.OS
import com.here.ort.utils.getUserOrtDirectory
import com.here.ort.utils.safeDeleteRecursively
import com.here.ort.utils.unpack
Expand Down Expand Up @@ -66,6 +67,10 @@ class GitTest : StringSpec() {
git.isApplicableUrl("https://bitbucket.org/paniq/masagin") shouldBe false
}

"Git does not prompt for credentials for non-existing repositories".config(enabled = !OS.isWindows) {
git.isApplicableUrl("https://github.com/heremaps/foobar.git") shouldBe false
}

"Detected Git working tree information is correct" {
val workingTree = git.getWorkingTree(zipContentDir)

Expand Down

0 comments on commit 0f07ac1

Please sign in to comment.