Skip to content

AheadBehindTest relies on defaultBranch=master in .gitconfig #653

Open
@jkylling

Description

@jkylling

Describe the bug (required)

The AheadBehindTest fails if defaultBranch is not equal to master in .gitconfig.

Tell us about your plugin configuration (required)

Not applicable

Tell us about the Plugin version used (required)

Master branch

Tell us about the Maven version used (required)

Not applicable

Steps to Reproduce (required)

Change all references to master to test in AheadBehindTest. See jkylling@32de0ed

Are there any stacktraces or any error messages? (required)

org.eclipse.jgit.api.errors.TransportException: Remote branch 'master' not found in upstream origin

	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:249)
	at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:325)
	at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:191)
	at pl.project13.maven.git.AheadBehindTest.setupSecondLocalRepository(AheadBehindTest.java:156)
	at pl.project13.maven.git.AheadBehindTest.setup(AheadBehindTest.java:61)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at org.junit.internal.runners.statements.RunBefores.invokeMethod(RunBefores.java:33)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:54)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:54)
	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:54)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
	at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: org.eclipse.jgit.errors.TransportException: Remote branch 'master' not found in upstream origin
	at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:157)
	at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:105)
	at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1462)
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:238)
	... 36 more

Is there a (public) project where this issue can be reproduced? (optional)

No response

Your Environment (optional)

No response

Context (optional)

The cause seems to be within jgit which does not set the initialBranch when initializing a repository when cloning. A workaround is to modify .gitconfig defaultBranch, or change master in the test to the value of defaultBranch. There is probably a way to fix the test to not rely on the value of initialBranch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions