示例#1
0
        public bool ShouldBeMerged(string versionBeingReleased, string versionToCheck)
        {
            Argument.IsNotNull(() => versionBeingReleased);
            Argument.IsNotNull(() => versionToCheck);

            if (!_versionInfoService.IsStableVersion(versionBeingReleased))
            {
                return(false);
            }

            if (versionToCheck.StartsWith(versionBeingReleased))
            {
                return(true);
            }

            return(false);
        }
示例#2
0
        public void MergeVersions(IJiraRestClient jiraRestClient, string projectKey, string version)
        {
            Argument.IsNotNull(() => jiraRestClient);
            Argument.IsNotNullOrWhitespace(() => projectKey);
            Argument.IsNotNullOrWhitespace(() => version);

            Log.Info("Merging all prerelease versions into '{0}'", version);

            if (!_versionInfoService.IsStableVersion(version))
            {
                Log.Info("Version '{0}' is not a stable version, versions will not be merged", version);
                return;
            }

            var allVersions = jiraRestClient.GetProjectVersions(projectKey);

            var newVersion      = allVersions.First(x => string.Equals(x.Name, version));
            var versionsToMerge = new List <JiraProjectVersion>();

            foreach (var remoteVersion in allVersions)
            {
                if (_mergeVersionService.ShouldBeMerged(version, remoteVersion.Name))
                {
                    versionsToMerge.Add(remoteVersion);
                }
            }

            foreach (var versionToMerge in versionsToMerge)
            {
                if (string.Equals(versionToMerge.Id, newVersion.Id))
                {
                    continue;
                }

                Log.Debug("Deleting version '{0}' and moving issues to '{1}'", versionToMerge, newVersion);

                jiraRestClient.DeleteProjectVersion(versionToMerge, newVersion, newVersion);
            }

            Log.Info("Merged all prerelease versions into '{0}'", version);
        }