forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FilterAttributeEntry.cs
53 lines (47 loc) · 1.94 KB
/
FilterAttributeEntry.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// The definition for a given filter found in the .gitattributes file.
/// The filter definition will result as 'filter=filterName'
///
/// In the .gitattributes file a filter will be matched to a pathspec like so
/// '*.txt filter=filterName'
/// </summary>
public class FilterAttributeEntry
{
private const string AttributeFilterDefinition = "filter=";
private readonly string filterDefinition;
/// <summary>
/// For testing purposes
/// </summary>
protected FilterAttributeEntry() { }
/// <summary>
/// The name of the filter found in a .gitattributes file.
/// </summary>
/// <param name="filterName">The name of the filter as found in the .gitattributes file without the "filter=" prefix</param>
/// <remarks>
/// "filter=" will be prepended to the filterDefinition, therefore the "filter=" portion of the filter
/// name shouldbe omitted on declaration. Inclusion of the "filter=" prefix will cause the FilterDefinition to
/// fail to match the .gitattributes entry and thefore no be invoked correctly.
/// </remarks>
public FilterAttributeEntry(string filterName)
{
Ensure.ArgumentNotNullOrEmptyString(filterName, "filterName");
if (filterName.StartsWith("filter=", StringComparison.OrdinalIgnoreCase))
{
throw new ArgumentException("The filterName parameter should not begin with \"filter=\"", filterName);
}
filterName = AttributeFilterDefinition + filterName;
this.filterDefinition = filterName;
}
/// <summary>
/// The filter name in the form of 'filter=filterName'
/// </summary>
public virtual string FilterDefinition
{
get { return filterDefinition; }
}
}
}