-
Hello everybody, I'm trying to migrate to GitVersion.MSBuild but I'm struggling with configuration. I've a GitVersion.yml configuration file and everything was fine, but for MSBuild seems not enough. My problem is that I've a project with a submodule, and GitVersion get a version for the main git project and a version for the submodule. Because of the commit reference to the submodule, I usually have a detached commit for this one, and here comes the troubles, because I haven't found how to set a fallback. Digging into the code, I've found in public GitVersionContext Create(GitVersionOptions gitVersionOptions)
{
var currentBranch = repositoryStore.GetTargetBranch(gitVersionOptions.RepositoryInfo.TargetBranch);
if (currentBranch == null)
throw new InvalidOperationException("Need a branch to operate on");
var configuration = configProvider.Provide(overrideConfig: options.Value.ConfigInfo.OverrideConfig);
var currentCommit = repositoryStore.GetCurrentCommit(currentBranch, gitVersionOptions.RepositoryInfo.CommitId);
if (currentBranch.IsDetachedHead)
{
var branchForCommit = repositoryStore.GetBranchesContainingCommit(currentCommit, onlyTrackedBranches: gitVersionOptions.Settings.OnlyTrackedBranches).OnlyOrDefault();
currentBranch = branchForCommit ?? currentBranch;
}
var currentBranchConfig = branchConfigurationCalculator.GetBranchConfiguration(currentBranch, currentCommit, configuration);
var effectiveConfiguration = configuration.CalculateEffectiveConfiguration(currentBranchConfig);
var currentCommitTaggedVersion = repositoryStore.GetCurrentCommitTaggedVersion(currentCommit, effectiveConfiguration);
var numberOfUncommittedChanges = repositoryStore.GetNumberOfUncommittedChanges();
return new GitVersionContext(currentBranch, currentCommit, configuration, effectiveConfiguration, currentCommitTaggedVersion, numberOfUncommittedChanges);
}
I can manually set the right branch, but I can't do it on Azure devops pipeline. Any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
As documented, GitVersion does not support a detached |
Beta Was this translation helpful? Give feedback.
It's unfortunately not possible to configure the currently built branch with configuration, sorry. 😕