Example #1
0
		public Config(Switches switches)
		{
			m_switches = switches;
			m_debugLogDir = Path.Combine(Environment.CurrentDirectory, "DebugLogs");

			ObserveCollection(m_switches.GitConfigSet, x => AddGitConfigOption(x, add: false));
			ObserveCollection(m_switches.GitConfigAdd, x => AddGitConfigOption(x, add: true));

			TagMatcher = new InclusionMatcher(ignoreCase: false);
			TagRename = new Renamer();

			BranchMatcher = new InclusionMatcher(ignoreCase: false);
			BranchRename = new Renamer();
			BranchRename.AddRule(new RenameRule("^MAIN$", "master"));

			ObserveCollection(m_switches.IncludeFile, x => AddIncludeRule(m_fileMatcher, x, include: true));
			ObserveCollection(m_switches.ExcludeFile, x => AddIncludeRule(m_fileMatcher, x, include: false));
			ObserveCollection(m_switches.HeadOnly, x => AddIncludeRule(m_headOnlyMatcher, x, include:true));

			ObserveCollection(m_switches.IncludeTag, x => AddIncludeRule(TagMatcher, x, include: true));
			ObserveCollection(m_switches.ExcludeTag, x => AddIncludeRule(TagMatcher, x, include: false));
			ObserveCollection(m_switches.RenameTag, x => AddRenameRule(TagRename, x));

			ObserveCollection(m_switches.IncludeBranch, x => AddIncludeRule(BranchMatcher, x, include: true));
			ObserveCollection(m_switches.ExcludeBranch, x => AddIncludeRule(BranchMatcher, x, include: false));
			ObserveCollection(m_switches.RenameBranch, x => AddRenameRule(BranchRename, x));
		}
Example #2
0
		public void Rename_Match()
		{
			var renamer = new Renamer();
			renamer.AddRule(new RenameRule("a(.)", "b$1"));
			var renamed = renamer.Process("blah");
			Assert.AreEqual(renamed, "blbh");
		}
		public ExclusionFilter(ILogger log, IConfig config)
		{
			m_log = log;
			m_config = config;
			m_branchRenamer = config.BranchRename;
			m_headOnlyState = RepositoryState.CreateWithBranchChangesOnly();
		}
Example #4
0
		public void Rename_MultipleMatches_FirstWins()
		{
			var renamer = new Renamer();
			renamer.AddRule(new RenameRule("a", "b"));
			renamer.AddRule(new RenameRule("h", "x"));

			var renamed = renamer.Process("blah");
			Assert.AreEqual(renamed, "blbh");
		}
Example #5
0
        private static string PrintPossibleRename(string tag, Renamer renamer)
        {
            var renamed = renamer.Process(tag);

            if (renamed == tag)
            {
                return(tag);
            }
            else
            {
                return(String.Format("{0} (renamed to {1})", tag, renamed));
            }
        }
Example #6
0
		public void Rename_NoMatch()
		{
			var renamer = new Renamer();
			var renamed = renamer.Process("blah");
			Assert.AreEqual(renamed, "blah");
		}
Example #7
0
		private static string PrintPossibleRename(string tag, Renamer renamer)
		{
			var renamed = renamer.Process(tag);
			if (renamed == tag)
				return tag;
			else
				return String.Format("{0} (renamed to {1})", tag, renamed);
		}
Example #8
0
		private static void WriteTagLog(string filename, ITagResolver resolver, IEnumerable<string> excluded, Renamer renamer)
		{
			if (m_log.DebugEnabled)
			{
				using (var log = m_log.OpenDebugFile(filename))
				{
					if (resolver.ResolvedTags().Any())
					{
						var included = resolver.ResolvedTags()
								.Select(t => "  " + PrintPossibleRename(t, renamer))
								.ToList();

						log.WriteLine("Included:");
						log.Write(String.Join(Environment.NewLine, included));
						log.WriteLine();
						log.WriteLine();
					}

					if (excluded.Any())
					{
						var excludedDisplay = excluded
								.Select(t => "  " + PrintPossibleRename(t, renamer))
								.ToList();

						log.WriteLine("Excluded:");
						log.Write(String.Join(Environment.NewLine, excludedDisplay));
						log.WriteLine();
					}
				}
			}
		}
Example #9
0
		private void AddRenameRule(Renamer renamer, string rule)
		{
			try
			{
				renamer.AddRule(RenameRule.Parse(rule));
			}
			catch (ArgumentException ae)
			{
				throw new CommandLineArgsException("Invalid rename rule: {0}", ae.Message);
			}
		}
Example #10
0
        private static void WriteTagLog(string filename, ITagResolver resolver, IEnumerable <string> excluded, Renamer renamer)
        {
            if (m_log.DebugEnabled)
            {
                using (var log = m_log.OpenDebugFile(filename))
                {
                    if (resolver.ResolvedTags().Any())
                    {
                        var included = resolver.ResolvedTags()
                                       .Select(t => "  " + PrintPossibleRename(t, renamer))
                                       .ToList();

                        log.WriteLine("Included:");
                        log.Write(String.Join(Environment.NewLine, included));
                        log.WriteLine();
                        log.WriteLine();
                    }

                    if (excluded.Any())
                    {
                        var excludedDisplay = excluded
                                              .Select(t => "  " + PrintPossibleRename(t, renamer))
                                              .ToList();

                        log.WriteLine("Excluded:");
                        log.Write(String.Join(Environment.NewLine, excludedDisplay));
                        log.WriteLine();
                    }
                }
            }
        }