mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
git tests: setup default username for auxiliary repositories
Otherwise Git tries to get a username/email from the OS settings, which sometimes fail on test server agents, and it leads to commit failure.
This commit is contained in:
@@ -23,6 +23,7 @@ import git4idea.config.GitVersion
|
||||
import git4idea.test.GitPlatformTest
|
||||
import git4idea.test.git
|
||||
import git4idea.test.registerRepo
|
||||
import git4idea.test.setupDefaultUsername
|
||||
import org.junit.Assume.assumeTrue
|
||||
import java.io.File
|
||||
|
||||
@@ -44,6 +45,7 @@ abstract class GitWorkTreeBaseTest : GitPlatformTest() {
|
||||
val gitDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(File(projectPath, GitUtil.DOT_GIT))
|
||||
assertNotNull(gitDir)
|
||||
myRepo = registerRepo(project, projectPath)
|
||||
setupDefaultUsername()
|
||||
assertEquals(1, repositoryManager.repositories.size)
|
||||
assertNotNull(repositoryManager.getRepositoryForRoot(projectRoot))
|
||||
}
|
||||
|
||||
@@ -91,11 +91,12 @@ fun GitPlatformTest.cloneRepo(source: String, destination: String, bare: Boolean
|
||||
else {
|
||||
git("clone -- . $destination")
|
||||
}
|
||||
cd(destination)
|
||||
setupDefaultUsername()
|
||||
}
|
||||
|
||||
fun setupDefaultUsername(project: Project) {
|
||||
setupUsername(project, USER_NAME, USER_EMAIL)
|
||||
}
|
||||
fun setupDefaultUsername(project: Project) = setupUsername(project, USER_NAME, USER_EMAIL)
|
||||
fun GitPlatformTest.setupDefaultUsername() = setupDefaultUsername(project)
|
||||
|
||||
fun setupUsername(project: Project, name: String, email: String) {
|
||||
assertFalse("Can not set empty user name ", name.isEmpty())
|
||||
|
||||
@@ -169,7 +169,7 @@ class GitSubmoduleTest : GitPlatformTest() {
|
||||
git("init $moduleName")
|
||||
val child = File(testRoot, moduleName)
|
||||
cd(child)
|
||||
setupDefaultUsername(project)
|
||||
setupDefaultUsername()
|
||||
tac("initial.txt", "initial")
|
||||
val parent = "$moduleName.git"
|
||||
git("remote add origin ${testRoot}/$parent")
|
||||
@@ -185,7 +185,10 @@ class GitSubmoduleTest : GitPlatformTest() {
|
||||
private fun prepareSecondClone(): File {
|
||||
cd(testRoot)
|
||||
git("clone --recurse-submodules parent.git bro")
|
||||
return File(testRoot, "bro")
|
||||
val broDir = File(testRoot, "bro")
|
||||
cd(broDir)
|
||||
setupDefaultUsername()
|
||||
return broDir
|
||||
}
|
||||
|
||||
private fun commitAndPushFromSecondClone(bro: File) {
|
||||
|
||||
Reference in New Issue
Block a user