Пример #1
0
        private static ITagResolver ResolveTags(IEnumerable <Commit> commits, FileCollection includedFiles)
        {
            var tagResolver = new TagResolver(m_log, includedFiles)
            {
                PartialTagThreshold = m_config.PartialTagThreshold
            };

            // resolve tags
            var allTags = includedFiles.SelectMany(f => f.AllTags).Where(t => m_config.TagMatcher.Match(t));

            if (!tagResolver.Resolve(allTags.Distinct(), commits))
            {
                // ignore branchpoint tags that are unresolved
                var unresolvedTags = tagResolver.UnresolvedTags.OrderBy(i => i);
                m_log.WriteLine("Unresolved tags:");

                using (m_log.Indent())
                {
                    foreach (var tag in unresolvedTags)
                    {
                        m_log.WriteLine("{0}", tag);
                    }
                }

                throw new ImportFailedException(String.Format("Unable to resolve all tags to a single commit: {0}",
                                                              unresolvedTags.StringJoin(", ")));
            }

            m_resolvedTags = tagResolver.ResolvedTags;
            return(tagResolver);
        }
Пример #2
0
        private static ITagResolver ResolveBranches(IEnumerable <Commit> commits, FileCollection includedFiles)
        {
            ITagResolver branchResolver;
            var          autoBranchResolver = new AutoBranchResolver(m_log, includedFiles)
            {
                PartialTagThreshold = m_config.PartialTagThreshold
            };

            branchResolver = autoBranchResolver;

            // if we're matching branchpoints, resolve those tags first
            if (m_config.BranchpointRule != null)
            {
                var tagResolver = new TagResolver(m_log, includedFiles)
                {
                    PartialTagThreshold = m_config.PartialTagThreshold
                };

                var allBranches     = includedFiles.SelectMany(f => f.AllBranches).Distinct();
                var rule            = m_config.BranchpointRule;
                var branchpointTags = allBranches.Where(b => rule.IsMatch(b)).Select(b => rule.Apply(b));

                if (!tagResolver.Resolve(branchpointTags, commits))
                {
                    var unresolvedTags = tagResolver.UnresolvedTags.OrderBy(i => i);
                    m_log.WriteLine("Unresolved branchpoint tags:");

                    using (m_log.Indent())
                    {
                        foreach (var tag in unresolvedTags)
                        {
                            m_log.WriteLine("{0}", tag);
                        }
                    }
                }

                commits        = tagResolver.Commits;
                branchResolver = new ManualBranchResolver(m_log, autoBranchResolver, tagResolver, m_config.BranchpointRule);
            }

            // resolve remaining branchpoints
            if (!branchResolver.Resolve(includedFiles.SelectMany(f => f.AllBranches).Distinct(), commits))
            {
                var unresolvedTags = branchResolver.UnresolvedTags.OrderBy(i => i);
                m_log.WriteLine("Unresolved branches:");

                using (m_log.Indent())
                {
                    foreach (var tag in unresolvedTags)
                    {
                        m_log.WriteLine("{0}", tag);
                    }
                }

                throw new ImportFailedException(String.Format("Unable to resolve all branches to a single commit: {0}",
                                                              branchResolver.UnresolvedTags.StringJoin(", ")));
            }

            return(branchResolver);
        }
Пример #3
0
		private static ITagResolver ResolveTags(IEnumerable<Commit> commits, FileCollection includedFiles)
		{
			var tagResolver = new TagResolver(m_log, includedFiles)
			{
				PartialTagThreshold = m_config.PartialTagThreshold
			};

			// resolve tags
			var allTags = includedFiles.SelectMany(f => f.AllTags).Where(t => m_config.TagMatcher.Match(t));
			if (!tagResolver.Resolve(allTags.Distinct(), commits))
			{
				// ignore branchpoint tags that are unresolved
				var unresolvedTags = tagResolver.UnresolvedTags.OrderBy(i => i);
				m_log.WriteLine("Unresolved tags:");

				using (m_log.Indent())
				{
					foreach (var tag in unresolvedTags)
						m_log.WriteLine("{0}", tag);
				}

				throw new ImportFailedException(String.Format("Unable to resolve all tags to a single commit: {0}",
						unresolvedTags.StringJoin(", ")));
			}

			m_resolvedTags = tagResolver.ResolvedTags;
			return tagResolver;
		}
Пример #4
0
		private static ITagResolver ResolveBranches(IEnumerable<Commit> commits, FileCollection includedFiles)
		{
			ITagResolver branchResolver;
			var autoBranchResolver = new AutoBranchResolver(m_log, includedFiles)
			{
				PartialTagThreshold = m_config.PartialTagThreshold
			};
			branchResolver = autoBranchResolver;

			// if we're matching branchpoints, resolve those tags first
			if (m_config.BranchpointRule != null)
			{
				var tagResolver = new TagResolver(m_log, includedFiles)
				{
					PartialTagThreshold = m_config.PartialTagThreshold
				};

				var allBranches = includedFiles.SelectMany(f => f.AllBranches).Distinct();
				var rule = m_config.BranchpointRule;
				var branchpointTags = allBranches.Where(b => rule.IsMatch(b)).Select(b => rule.Apply(b));

				if (!tagResolver.Resolve(branchpointTags, commits))
				{
					var unresolvedTags = tagResolver.UnresolvedTags.OrderBy(i => i);
					m_log.WriteLine("Unresolved branchpoint tags:");

					using (m_log.Indent())
					{
						foreach (var tag in unresolvedTags)
							m_log.WriteLine("{0}", tag);
					}
				}

				commits = tagResolver.Commits;
				branchResolver = new ManualBranchResolver(m_log, autoBranchResolver, tagResolver, m_config.BranchpointRule);
			}

			// resolve remaining branchpoints 
			if (!branchResolver.Resolve(includedFiles.SelectMany(f => f.AllBranches).Distinct(), commits))
			{
				var unresolvedTags = branchResolver.UnresolvedTags.OrderBy(i => i);
				m_log.WriteLine("Unresolved branches:");

				using (m_log.Indent())
				{
					foreach (var tag in unresolvedTags)
						m_log.WriteLine("{0}", tag);
				}

				throw new ImportFailedException(String.Format("Unable to resolve all branches to a single commit: {0}",
						branchResolver.UnresolvedTags.StringJoin(", ")));
			}

			return branchResolver;
		}