예제 #1
0
        /// <inheritdoc />
        protected override ChangeLogTaskResult Run(ApplicationChangeLog changeLog)
        {
            if (String.IsNullOrEmpty(m_Configuration.CurrentVersion))
            {
                return(ChangeLogTaskResult.Skipped);
            }

            if (!NuGetVersion.TryParse(m_Configuration.CurrentVersion, out var version))
            {
                m_Logger.LogError($"Invalid 'currentVersion' setting: '{m_Configuration.CurrentVersion}' is not a valid version");
                return(ChangeLogTaskResult.Error);
            }

            var head = m_Repository.Head;

            if (changeLog.ContainsVersion(version))
            {
                var existingEntry = changeLog[version];
                if (existingEntry.Version.Commit == head.Id)
                {
                    m_Logger.LogError($"Skipping adding of current version '{version}' because the changelog already contains the version and references the same commit.");
                    return(ChangeLogTaskResult.Success);
                }

                m_Logger.LogError($"Cannot add current version '{version}' because the changelog already contains this version.");
                return(ChangeLogTaskResult.Error);
            }

            m_Logger.LogDebug($"Adding version '{version.ToNormalizedString()}' (commit '{head.Id}', current repository HEAD)");
            var versionInfo = new VersionInfo(version, head.Id);

            changeLog.Add(new SingleVersionChangeLog(versionInfo));
            return(ChangeLogTaskResult.Success);
        }
        protected override ChangeLogTaskResult Run(ApplicationChangeLog changeLog)
        {
            if (m_TagPatterns.Count == 0)
            {
                m_Logger.LogWarning("No tag patterns configured, skipping loading of versions from tags.");
                return(ChangeLogTaskResult.Skipped);
            }

            m_Logger.LogInformation("Loading versions from git tags");

            foreach (var versionInfo in GetVersions())
            {
                if (changeLog.ContainsVersion(versionInfo.Version))
                {
                    m_Logger.LogError($"Cannot add version '{versionInfo.Version}' from tags because the changelog already contains this version.");
                    return(ChangeLogTaskResult.Error);
                }

                m_Logger.LogDebug($"Adding version '{versionInfo.Version}' to changelog");
                var versionChangeLog = new SingleVersionChangeLog(versionInfo);
                changeLog.Add(versionChangeLog);
            }

            return(ChangeLogTaskResult.Success);
        }
예제 #3
0
        public void Add_throws_InvalidOperationException_if_version_already_exists()
        {
            // ARRANGE
            var versionInfo1 = GetSingleVersionChangeLog("4.5.6", TestGitIds.Id1);
            var versionInfo2 = GetSingleVersionChangeLog("4.5.6", TestGitIds.Id2);

            var sut = new ApplicationChangeLog()
            {
                versionInfo1
            };

            // ACT / ASSERT
            Assert.Throws <InvalidOperationException>(() => sut.Add(versionInfo2));
        }
예제 #4
0
        /// <inheritdoc />
        protected override ChangeLogTaskResult Run(ApplicationChangeLog changeLog)
        {
            if (String.IsNullOrEmpty(m_Configuration.CurrentVersion))
            {
                return(ChangeLogTaskResult.Skipped);
            }

            if (!NuGetVersion.TryParse(m_Configuration.CurrentVersion, out var version))
            {
                m_Logger.LogError($"Invalid 'currentVersion' setting: '{m_Configuration.CurrentVersion}' is not a valid version");
                return(ChangeLogTaskResult.Error);
            }

            var head = m_Repository.Head;

            m_Logger.LogDebug($"Adding version '{version.ToNormalizedString()}' (commit '{head.Id}', current repository HEAD)");
            var versionInfo = new VersionInfo(version, head.Id);

            changeLog.Add(new SingleVersionChangeLog(versionInfo));
            return(ChangeLogTaskResult.Success);
        }