public GitVersionContext Create(GitVersionOptions gitVersionOptions)
        {
            var currentBranch = repositoryMetadataProvider.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 = repositoryMetadataProvider.GetCurrentCommit(currentBranch, gitVersionOptions.RepositoryInfo.CommitId);

            if (currentBranch.IsDetachedHead)
            {
                var branchForCommit = repositoryMetadataProvider.GetBranchesContainingCommit(currentCommit, onlyTrackedBranches: gitVersionOptions.Settings.OnlyTrackedBranches).OnlyOrDefault();
                currentBranch = branchForCommit ?? currentBranch;
            }

            var currentBranchConfig        = branchConfigurationCalculator.GetBranchConfiguration(currentBranch, currentCommit, configuration);
            var effectiveConfiguration     = configuration.CalculateEffectiveConfiguration(currentBranchConfig);
            var currentCommitTaggedVersion = repositoryMetadataProvider.GetCurrentCommitTaggedVersion(currentCommit, effectiveConfiguration);
            var numberOfUncommittedChanges = repositoryMetadataProvider.GetNumberOfUncommittedChanges();

            return(new GitVersionContext(currentBranch, currentCommit, configuration, effectiveConfiguration, currentCommitTaggedVersion, numberOfUncommittedChanges));
        }
        public GitVersionContext Create(GitVersionOptions gitVersionOptions)
        {
            var currentBranch = gitVersionOptions.Settings.UseBuildAgentBranch
                ? ResolveCurrentBranch()
                : gitVersionOptions.RepositoryInfo.TargetBranch;

            var targetBranch = repositoryMetadataProvider.GetTargetBranch(currentBranch);

            return(Init(targetBranch, gitVersionOptions.RepositoryInfo.CommitId, gitVersionOptions.Settings.OnlyTrackedBranches));
        }
        public GitVersionContext Create(Arguments arguments)
        {
            var targetBranch = repositoryMetadataProvider.GetTargetBranch(arguments.TargetBranch);

            return(Init(targetBranch, arguments.CommitId, arguments.OnlyTrackedBranches));
        }
Exemple #4
0
        public GitVersionContext Create(GitVersionOptions gitVersionOptions)
        {
            var targetBranch = repositoryMetadataProvider.GetTargetBranch(gitVersionOptions.RepositoryInfo.TargetBranch);

            return(Init(targetBranch, gitVersionOptions.RepositoryInfo.CommitId, gitVersionOptions.Settings.OnlyTrackedBranches));
        }