public void AddIncludeThenExclude_Matches() { var matcher = new InclusionMatcher(); matcher.AddIncludeRule(@"xx"); matcher.AddExcludeRule(@"yy"); var result = matcher.Match("aaxx"); Assert.IsTrue(result); result = matcher.Match("xxyy"); Assert.IsFalse(result); }
public void CaseInsensitive_IgnoresCase() { var matcher = new InclusionMatcher(ignoreCase: true); matcher.AddIncludeRule(@"xx"); var result = matcher.Match("XX"); Assert.IsTrue(result); }
public void CaseSensitive_MatchesCase() { var matcher = new InclusionMatcher(ignoreCase: false); matcher.AddIncludeRule(@"xx"); var result = matcher.Match("XX"); Assert.IsFalse(result); }
public void AddExcludeRuleFirst_IncludesByDefault() { var matcher = new InclusionMatcher(); matcher.AddExcludeRule(@"xx"); var result = matcher.Match("blah"); Assert.IsTrue(result); }
/// <summary> /// Should a file be imported? /// </summary> /// <remarks>Excludes files that are "head-only"</remarks> public bool IncludeFile(string filename) { return(m_fileMatcher.Match(filename) && !m_headOnlyMatcher.Match(filename)); }
/// <summary> /// Parse the log returning a list of the individual commits to the individual files. /// </summary> public IEnumerable <FileRevision> Parse() { var state = State.Start; FileInfo currentFile = null; Revision revision = Revision.Empty; FileRevision commit = null; m_repo = GetCvsRepo(); foreach (var line in m_reader) { switch (state) { case State.Start: if (line.StartsWith("RCS file: ")) { currentFile = new FileInfo(ExtractFileName(line)); m_files.Add(currentFile); state = State.InFileHeader; } break; case State.InFileHeader: if (line == LogSeparator) { state = State.ExpectCommitRevision; } else if (line == "symbolic names:") { state = State.InTags; } break; case State.InTags: if (!line.StartsWith("\t")) { state = State.InFileHeader; } else { var tagMatch = Regex.Match(line, @"^\t(\S+): (\S+)"); if (!tagMatch.Success) { throw MakeParseException("Invalid tag line: '{0}'", line); } var tagName = tagMatch.Groups[1].Value; var tagRevision = Revision.Create(tagMatch.Groups[2].Value); if (tagRevision.IsBranch) { if (m_branchMatcher.Match(tagName)) { currentFile.AddBranchTag(tagName, tagRevision); } else { m_excludedBranches.Add(tagName); } } else { currentFile.AddTag(tagName, tagRevision); } } break; case State.ExpectCommitRevision: if (line.StartsWith("revision ")) { revision = Revision.Create(line.Substring(9)); state = State.ExpectCommitInfo; } else { throw MakeParseException("Expected revision line, found '{0}'", line); } break; case State.ExpectCommitInfo: commit = ParseFields(currentFile, revision, line); state = State.ExpectCommitMessage; break; case State.ExpectCommitMessage: if (line == LogSeparator) { if (commit != null) { yield return(commit); } state = State.ExpectCommitRevision; } else if (line == FileSeparator) { if (commit != null) { yield return(commit); } state = State.Start; } else if (!line.StartsWith("branches: ")) { if (commit != null) { commit.AddMessage(line); } } break; } } }