-
Notifications
You must be signed in to change notification settings - Fork 654
Fall back to master
if main
is missing
#3037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thinking more about this, why aren't we using the configured branch name regex for the main branch? The main branch could be |
Hm, tests seem to fail at random. I at least don't understand what I've done in the PR which causes the following test to fail in some environments, while being successful in others. Shouldly.ShouldAssertException : result.ExitCode
Failed VerifyAzurePipelinesPullRequest("refs/pull-requests/5/merge") [281 ms]
Error Message:
should be
0
but was
1
Stack Trace:
at GitVersion.App.Tests.PullRequestInBuildAgentTest.VerifyPullRequestVersionIsCalculatedProperly(String pullRequestRef, Dictionary`2 env) in /home/runner/work/GitVersion/GitVersion/src/GitVersion.App.Tests/PullRequestInBuildAgentTest.cs:line 163
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at GitVersion.App.Tests.PullRequestInBuildAgentTest.VerifyAzurePipelinesPullRequest(String pullRequestRef) in /home/runner/work/GitVersion/GitVersion/src/GitVersion.App.Tests/PullRequestInBuildAgentTest.cs:line 29
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.GetResult()
at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(TestExecutionContext context)
at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
at NUnit.Framework.Internal.Execution.SimpleWorkItem.<>c__DisplayClass4_0.<PerformWork>b__0()
at NUnit.Framework.Internal.ContextUtils.<>c__DisplayClass1_0`1.<DoIsolated>b__0(Object _)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at NUnit.Framework.Internal.ContextUtils.DoIsolated(ContextCallback callback, Object state)
at NUnit.Framework.Internal.ContextUtils.DoIsolated[T](Func`1 func)
at NUnit.Framework.Internal.Execution.SimpleWorkItem.PerformWork() Do you have any ideas, @arturcic? |
Usually these test are failing for the build agents because the environment variables are not properly reset |
Are the environment variables not reset between different builds, or within the same build? If it's within the same build, is the problem related to parallelization? Can we make the tests execute serially to ensure a proper cleanup between each test execution? |
It needs more investigation |
ed46aa2
to
d3dacee
Compare
Fall back to `master` if `main` is missing. Fixes GitToolsGH-2590.
Refactor `ConfigExtensions.CalculateEffectiveConfiguration()` into `EffectiveConfiguration.ctor()`.
9c7e713
to
33a583b
Compare
Use the `Config` class to find the `main` branch via its configured regex instead of using a hard coded branch name.
33a583b
to
0985daa
Compare
Seems like the problem was the following line attempting to resolve Line 38 in 9c7e713
I've fixed this now by resolving the configuration more lazily inside the |
Fall back to the `master` configuration regex if `main` is missing from the configuration. If none of them are found, do a verbatim string search for branches named `main` with fallback to `master`.
Thank you @asbjornu for your contribution! |
Fall back to
master
ifmain
is missing.Description
Since the default branch was changed from
master
tomain
in #2573, some scenarios have stopped working as explained in #2590. This PR attempts to fix that by falling back tomaster
ifmain
is missing. Hopefully, this shouldn't break any existing tests.Related Issue
Fixes #2590.
Motivation and Context
The change introduced in #2573 wasn't meant to be breaking, so we should do what we can to remedy any breaking it may have lead to.
How Has This Been Tested?
I haven't written any tests for this yet. I'm not sure how to reproduce it, so if all tests are still green I think this should be merged even without a regression test.
Screenshots (if appropriate):
Checklist: