Exemple #1
0
 /// <summary>Determine if an entry path matches an ignore rule.</summary>
 /// <remarks>Determine if an entry path matches an ignore rule.</remarks>
 /// <param name="entryPath">
 /// the path to test. The path must be relative to this ignore
 /// node's own repository path, and in repository path format
 /// (uses '/' and not '\').
 /// </param>
 /// <param name="isDirectory">true if the target item is a directory.</param>
 /// <returns>status of the path.</returns>
 public virtual IgnoreNode.MatchResult IsIgnored(string entryPath, bool isDirectory
                                                 )
 {
     if (rules.IsEmpty())
     {
         return(IgnoreNode.MatchResult.CHECK_PARENT);
     }
     // Parse rules in the reverse order that they were read
     for (int i = rules.Count - 1; i > -1; i--)
     {
         IgnoreRule rule = rules[i];
         if (rule.IsMatch(entryPath, isDirectory))
         {
             if (rule.GetResult())
             {
                 return(IgnoreNode.MatchResult.IGNORED);
             }
             else
             {
                 return(IgnoreNode.MatchResult.NOT_IGNORED);
             }
         }
     }
     return(IgnoreNode.MatchResult.CHECK_PARENT);
 }
Exemple #2
0
        /// <summary>Check for a match.</summary>
        /// <remarks>
        /// Check for a match. If target ends with "/", match will assume that the
        /// target is meant to be a directory.
        /// </remarks>
        /// <param name="pattern">Pattern as it would appear in a .gitignore file</param>
        /// <param name="target">Target file path relative to repository's GIT_DIR</param>
        /// <returns>
        /// Result of
        /// <see cref="IgnoreRule.IsMatch(string, bool)">IgnoreRule.IsMatch(string, bool)</see>
        /// </returns>
        private bool Match(string pattern, string target)
        {
            IgnoreRule r = new IgnoreRule(pattern);

            //If speed of this test is ever an issue, we can use a presetRule field
            //to avoid recompiling a pattern each time.
            return(r.IsMatch(target, target.EndsWith("/")));
        }
		/// <summary>Check for a match.</summary>
		/// <remarks>
		/// Check for a match. If target ends with "/", match will assume that the
		/// target is meant to be a directory.
		/// </remarks>
		/// <param name="pattern">Pattern as it would appear in a .gitignore file</param>
		/// <param name="target">Target file path relative to repository's GIT_DIR</param>
		/// <returns>
		/// Result of
		/// <see cref="IgnoreRule.IsMatch(string, bool)">IgnoreRule.IsMatch(string, bool)</see>
		/// </returns>
		private bool Match(string pattern, string target)
		{
			IgnoreRule r = new IgnoreRule(pattern);
			//If speed of this test is ever an issue, we can use a presetRule field
			//to avoid recompiling a pattern each time.
			return r.IsMatch(target, target.EndsWith("/"));
		}