Exemplo n.º 1
0
        private static Version GetVersion(string repoOrWorkDir, string tagPrefix, MajorMinor minMajorMinor, string buildMeta, Verbosity verbosity)
        {
            var log = new Logger(verbosity);

            if (log.IsDebugEnabled)
            {
                log.Debug($"MinVer {informationalVersion}.");
            }

            if (!RepositoryEx.TryCreateRepo(repoOrWorkDir, out var repo))
            {
                var version = new Version(minMajorMinor?.Major ?? 0, minMajorMinor?.Minor ?? 0, buildMeta);

                log.WarnIsNotAValidRepositoryOrWorkDirUsingDefaultVersion(repoOrWorkDir, version);

                return(version);
            }

            try
            {
                return(Versioner.GetVersion(repo, tagPrefix, minMajorMinor, buildMeta, log));
            }
            finally
            {
                repo.Dispose();
            }
        }
Exemplo n.º 2
0
        private static Version GetVersion(string repoOrWorkDir, string tagPrefix, VersionPart autoIncrement, ILogger log)
        {
            if (!RepositoryEx.TryCreateRepo(repoOrWorkDir, out var repo))
            {
                var version = new Version();

                log.Warn(1001, $"'{repoOrWorkDir}' is not a valid repository or working directory. Using default version {version}.");

                return(version);
            }

            try
            {
                return(repo.GetVersion(tagPrefix, autoIncrement, log));
            }
            finally
            {
                repo.Dispose();
            }
        }