예제 #1
0
        public VersionVariables CalculateVersionVariables()
        {
            var buildServer = buildServerResolver.Resolve();

            // Normalize if we are running on build server
            var normalizeGitDirectory = !arguments.NoNormalize && buildServer != null;
            var shouldCleanUpRemotes  = buildServer != null && buildServer.ShouldCleanUpRemotes();

            var currentBranch = ResolveCurrentBranch(buildServer, arguments.TargetBranch, !string.IsNullOrWhiteSpace(arguments.DynamicRepositoryLocation));

            gitPreparer.Prepare(normalizeGitDirectory, currentBranch, shouldCleanUpRemotes);

            var dotGitDirectory = gitPreparer.GetDotGitDirectory();
            var projectRoot     = gitPreparer.GetProjectRootDirectory();

            log.Info($"Project root is: {projectRoot}");
            log.Info($"DotGit directory is: {dotGitDirectory}");
            if (string.IsNullOrEmpty(dotGitDirectory) || string.IsNullOrEmpty(projectRoot))
            {
                // TODO Link to wiki article
                throw new Exception($"Failed to prepare or find the .git directory in path '{arguments.TargetPath}'.");
            }

            return(GetCachedGitVersionInfo(arguments.TargetBranch, arguments.CommitId, arguments.OverrideConfig, arguments.NoCache));
        }
예제 #2
0
        public string SelectConfigFilePath(IGitPreparer gitPreparer)
        {
            var workingDirectory     = gitPreparer.GetWorkingDirectory();
            var projectRootDirectory = gitPreparer.GetProjectRootDirectory();

            return(GetConfigFilePath(HasConfigFileAt(workingDirectory) ? workingDirectory : projectRootDirectory));
        }
예제 #3
0
        public Config Provide(bool applyDefaults = true, Config overrideConfig = null)
        {
            var workingDirectory     = gitPreparer.GetWorkingDirectory();
            var projectRootDirectory = gitPreparer.GetProjectRootDirectory();

            var rootDirectory = configFileLocator.HasConfigFileAt(workingDirectory) ? workingDirectory : projectRootDirectory;

            return(Provide(rootDirectory, applyDefaults, overrideConfig));
        }
예제 #4
0
        public void Verify(IGitPreparer gitPreparer)
        {
            if (!string.IsNullOrWhiteSpace(gitPreparer.TargetUrl))
            {
                // Assuming this is a dynamic repository. At this stage it's unsure whether we have
                // any .git info so we need to skip verification
                return;
            }

            var workingDirectory     = gitPreparer.WorkingDirectory;
            var projectRootDirectory = gitPreparer.GetProjectRootDirectory();

            Verify(workingDirectory, projectRootDirectory);
        }