Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SimilarityOptions.cs « LibGit2Sharp - github.com/mono/libgit2sharp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 13d26abf2305e59399976a6f504fe2c198485d98 (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
namespace LibGit2Sharp
{
    /// <summary>
    /// Represents a mode for handling whitespace while detecting renames and copies.
    /// </summary>
    public enum WhitespaceMode
    {
        /// <summary>
        /// Don't consider leading whitespace when comparing files
        /// </summary>
        IgnoreLeadingWhitespace,

        /// <summary>
        /// Don't consider any whitespace when comparing files
        /// </summary>
        IgnoreAllWhitespace,

        /// <summary>
        /// Include all whitespace when comparing files
        /// </summary>
        DontIgnoreWhitespace,
    }

    /// <summary>
    /// Represents a mode for detecting renames and copies.
    /// </summary>
    public enum RenameDetectionMode
    {
        /// <summary>
        /// Obey the user's `diff.renames` configuration setting
        /// </summary>
        Default,

        /// <summary>
        /// Attempt no rename or copy detection
        /// </summary>
        None,

        /// <summary>
        /// Detect exact renames and copies (compare SHA hashes only)
        /// </summary>
        Exact,

        /// <summary>
        /// Detect fuzzy renames (use similarity metric)
        /// </summary>
        Renames,

        /// <summary>
        /// Detect renames and copies
        /// </summary>
        Copies,

        /// <summary>
        /// Detect renames, and include unmodified files when looking for copies
        /// </summary>
        CopiesHarder,
    }

    /// <summary>
    /// Options for handling file similarity
    /// </summary>
    public sealed class SimilarityOptions
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SimilarityOptions"/> class.
        /// </summary>
        public SimilarityOptions()
        {
            RenameDetectionMode = RenameDetectionMode.Default;
            WhitespaceMode = WhitespaceMode.IgnoreLeadingWhitespace;
            RenameThreshold = 50;
            RenameFromRewriteThreshold = 50;
            CopyThreshold = 50;
            BreakRewriteThreshold = 60;
            RenameLimit = 200;
        }

        /// <summary>
        /// Get a <see cref="SimilarityOptions"/> instance that does no rename detection
        /// </summary>
        public static SimilarityOptions None
        {
            get { return new SimilarityOptions {RenameDetectionMode = RenameDetectionMode.None}; }
        }

        /// <summary>
        /// Get a <see cref="SimilarityOptions"/> instance that detects renames
        /// </summary>
        public static SimilarityOptions Renames
        {
            get { return new SimilarityOptions {RenameDetectionMode = RenameDetectionMode.Renames}; }
        }

        /// <summary>
        /// Get a <see cref="SimilarityOptions"/> instance that detects exact renames only
        /// </summary>
        public static SimilarityOptions Exact
        {
            get { return new SimilarityOptions {RenameDetectionMode = RenameDetectionMode.Exact}; }
        }

        /// <summary>
        /// Get a <see cref="SimilarityOptions"/> instance that detects renames and copies
        /// </summary>
        public static SimilarityOptions Copies
        {
            get { return new SimilarityOptions {RenameDetectionMode = RenameDetectionMode.Copies}; }
        }

        /// <summary>
        /// Get a <see cref="SimilarityOptions"/> instance that detects renames, and includes unmodified files when detecting copies
        /// </summary>
        public static SimilarityOptions CopiesHarder
        {
            get { return new SimilarityOptions {RenameDetectionMode = RenameDetectionMode.CopiesHarder}; }
        }

        /// <summary>
        /// Get a <see cref="SimilarityOptions"/> instance that obeys the user's `diff.renames` setting
        /// </summary>
        public static SimilarityOptions Default
        {
            get { return new SimilarityOptions {RenameDetectionMode = RenameDetectionMode.Default}; }
        }

        /// <summary>
        /// The mode for detecting renames and copies
        /// </summary>
        public RenameDetectionMode RenameDetectionMode { get; set; }

        /// <summary>
        /// The mode for handling whitespace when comparing files
        /// </summary>
        public WhitespaceMode WhitespaceMode { get; set; }

        /// <summary>
        /// Similarity in order to consider a rename
        /// </summary>
        public int RenameThreshold { get; set; }

        /// <summary>
        /// Similarity of a modified file in order to be eligible as a rename source
        /// </summary>
        public int RenameFromRewriteThreshold { get; set; }

        /// <summary>
        /// Similarity to consider a file a copy
        /// </summary>
        public int CopyThreshold { get; set; }

        /// <summary>
        /// Similarity to split modify into an add/delete pair
        /// </summary>
        public int BreakRewriteThreshold { get; set; }

        /// <summary>
        /// Maximum similarity sources to examine for a file
        /// </summary>
        public int RenameLimit { get; set; }

        // TODO: custom metric
    }
}