Example #1
0
        public static void NoCommits(string path, Repository repo, Version actualVersion)
        {
            $"Given an empty git repository in '{path = GetScenarioDirectory($"minimum-major-minor-not-tagged")}'"
            .x(c => repo = EnsureEmptyRepository(path).Using(c));

            "When the version is determined using minimum major minor '1.2'"
            .x(() => actualVersion = Versioner.GetVersion(repo, default, new MajorMinor(1, 2), default, new TestLogger()));
Example #2
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();
            }
        }
Example #3
0
        public static void NoCommits(string path, Version actualVersion)
        {
            $"Given an empty git repository in {path = MethodBase.GetCurrentMethod().GetTestDirectory()}"
            .x(() => EnsureEmptyRepository(path));

            "When the version is determined using minimum major minor '1.2'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, new MajorMinor(1, 2), default, default, default, default));
Example #4
0
        public static void TagPrefix(string tag, string prefix, string expectedVersion, string path, Repository repo, Version actualVersion)
        {
            $"Given a git repository with a commit in '{path = GetScenarioDirectory($"tag-prefixes-{tag}")}'"
            .x(c => repo = EnsureEmptyRepositoryAndCommit(path).Using(c));

            $"And the commit is tagged '{tag}'"
            .x(() => repo.ApplyTag(tag));

            $"When the version is determined using the tag prefix '{prefix}'"
            .x(() => actualVersion = Versioner.GetVersion(path, prefix, default, default, new TestLogger()));
Example #5
0
        public static void TagPrefix(string tag, string prefix, string expectedVersion, string path, Version actualVersion)
        {
            $"Given a git repository with a commit in {path = MethodBase.GetCurrentMethod().GetTestDirectory(tag)}"
            .x(() => EnsureEmptyRepositoryAndCommit(path));

            $"And the commit is tagged '{tag}'"
            .x(() => Tag(path, tag));

            $"When the version is determined using the tag prefix '{prefix}'"
            .x(() => actualVersion = Versioner.GetVersion(path, prefix, default, default, default, default, default));
Example #6
0
        public static void NoCommits(string buildMetadata, string expectedVersion, string path, Version actualVersion)
        {
            $"Given an empty git repository in '{path = GetScenarioDirectory($"build-metadata-no-tag-{buildMetadata}")}'"
            .x(c => EnsureEmptyRepository(path).Using(c));

            $"When the version is determined using build metadata '{buildMetadata}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, buildMetadata, default, new TestLogger()));
Example #7
0
        public static void RtmVersionIncrement(string tag, VersionPart autoIncrement, string expectedVersion, string path, Repository repo, Version actualVersion)
        {
            $"Given a git repository with a commit in '{path = GetScenarioDirectory($"rtm-auto-increment-{tag}")}'"
            .x(c => repo = EnsureEmptyRepositoryAndCommit(path).Using(c));

            $"And the commit is tagged '{tag}'"
            .x(() => repo.ApplyTag(tag));

            $"And another commit"
            .x(() => Commit(path));

            $"When the version is determined using auto-increment '{autoIncrement}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, default, autoIncrement, default, new TestLogger()));
Example #8
0
        public static void DefaultPreReleasePhase(string phase, string expectedVersion, string path, Version actualVersion)
        {
            $"Given a git repository with a commit in '{path = GetScenarioDirectory($"default-pre-release-phase-{phase}")}'"
            .x(() => EnsureEmptyRepositoryAndCommit(path));

            $"When the version is determined using the default pre-release phase '{phase}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, default, default, phase, new TestLogger()));
Example #9
0
        public static void NoCommits(string buildMetadata, string expectedVersion, string path, Version actualVersion)
        {
            $"Given an empty git repository in {path = MethodBase.GetCurrentMethod().GetTestDirectory(buildMetadata)}"
            .x(() => EnsureEmptyRepository(path));

            $"When the version is determined using build metadata '{buildMetadata}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, buildMetadata, default, default, default));
Example #10
0
        public static void RtmVersionIncrement(string tag, VersionPart autoIncrement, string expectedVersion, string path, Version actualVersion)
        {
            $"Given a git repository with a commit in {path = MethodBase.GetCurrentMethod().GetTestDirectory(autoIncrement)}"
            .x(() => EnsureEmptyRepositoryAndCommit(path));

            $"And the commit is tagged '{tag}'"
            .x(() => Tag(path, tag));

            "And another commit"
            .x(() => Commit(path));

            $"When the version is determined using auto-increment '{autoIncrement}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, default, autoIncrement, default, default));
Example #11
0
        public static void DefaultPreReleasePhase(string phase, string expectedVersion, string path, Version actualVersion)
        {
            $"Given a git repository with a commit in {path = MethodBase.GetCurrentMethod().GetTestDirectory(phase)}"
            .x(() => EnsureEmptyRepositoryAndCommit(path));

            $"When the version is determined using the default pre-release phase '{phase}'"
            .x(() => actualVersion = Versioner.GetVersion(path, default, default, default, default, phase, default));