forked from gitextensions/gitextensions
/
FormRevisionFilter.cs
144 lines (123 loc) · 5.01 KB
/
FormRevisionFilter.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
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
using System;
using GitCommands;
namespace GitUI
{
public partial class FormRevisionFilter : GitExtensionsForm
{
public FormRevisionFilter()
{
InitializeComponent();
Translate();
LimitCheck.Checked = Settings.MaxRevisionGraphCommits > 0;
_NO_TRANSLATE_Limit.Value = Settings.MaxRevisionGraphCommits;
}
private void FormRevisionFilterLoad(object sender, EventArgs e)
{
EnableFilters();
}
private void SinceCheckCheckedChanged(object sender, EventArgs e)
{
EnableFilters();
}
private void OnBranchFilterCheckedChanged(object sender, EventArgs e)
{
Settings.BranchFilterEnabled = BranchFilterCheck.Checked;
EnableFilters();
}
private void OnShowCurrentBranchOnlyCheckedChanged(object sender, EventArgs e)
{
Settings.ShowCurrentBranchOnly = CurrentBranchOnlyCheck.Checked;
EnableFilters();
}
private void EnableFilters()
{
Since.Enabled = SinceCheck.Checked;
Until.Enabled = CheckUntil.Checked;
Author.Enabled = AuthorCheck.Checked;
Committer.Enabled = CommitterCheck.Checked;
Message.Enabled = MessageCheck.Checked;
_NO_TRANSLATE_Limit.Enabled = LimitCheck.Checked;
FileFilter.Enabled = FileFilterCheck.Checked;
BranchFilterCheck.Checked = Settings.BranchFilterEnabled;
CurrentBranchOnlyCheck.Checked = Settings.ShowCurrentBranchOnly;
CurrentBranchOnlyCheck.Enabled = BranchFilterCheck.Checked;
BranchFilter.Enabled = BranchFilterCheck.Checked &&
!CurrentBranchOnlyCheck.Checked;
}
public bool FilterEnabled()
{
return (AuthorCheck.Checked ||
CommitterCheck.Checked ||
MessageCheck.Checked ||
SinceCheck.Checked ||
CheckUntil.Checked ||
FileFilterCheck.Checked);
}
public string GetFilter()
{
var filter = "";
if (AuthorCheck.Checked && GitCommandHelpers.VersionInUse.IsRegExStringCmdPassable(Author.Text))
filter += string.Format(" --author=\"{0}\"", Author.Text);
if (CommitterCheck.Checked && GitCommandHelpers.VersionInUse.IsRegExStringCmdPassable(Committer.Text))
filter += string.Format(" --committer=\"{0}\"", Committer.Text);
if (MessageCheck.Checked && GitCommandHelpers.VersionInUse.IsRegExStringCmdPassable(Message.Text))
filter += string.Format(" --grep=\"{0}\"", Message.Text);
if (!string.IsNullOrEmpty(filter) && IgnoreCase.Checked)
filter += " --regexp-ignore-case";
if (SinceCheck.Checked)
filter += string.Format(" --since=\"{0}\"", Since.Value.ToString("yyyy-MM-dd hh:mm:ss"));
if (CheckUntil.Checked)
filter += string.Format(" --until=\"{0}\"", Until.Value.ToString("yyyy-MM-dd hh:mm:ss"));
if (LimitCheck.Checked && _NO_TRANSLATE_Limit.Value > 0)
filter += string.Format(" --max-count=\"{0}\"", (int)_NO_TRANSLATE_Limit.Value);
if (FileFilterCheck.Checked)
filter += string.Format(" -- \"{0}\"", FileFilter.Text.Replace('\\', '/'));
return filter;
}
public bool ShouldHideGraph()
{
return AuthorCheck.Checked || CommitterCheck.Checked ||
MessageCheck.Checked || FileFilterCheck.Checked;
}
public string GetInMemAuthorFilter()
{
if (AuthorCheck.Checked && !GitCommandHelpers.VersionInUse.IsRegExStringCmdPassable(Author.Text))
return Author.Text;
return string.Empty;
}
public string GetInMemCommitterFilter()
{
if (CommitterCheck.Checked && !GitCommandHelpers.VersionInUse.IsRegExStringCmdPassable(Committer.Text))
return Committer.Text;
return string.Empty;
}
public string GetInMemMessageFilter()
{
if (MessageCheck.Checked && !GitCommandHelpers.VersionInUse.IsRegExStringCmdPassable(Message.Text))
return Message.Text;
return string.Empty;
}
public bool GetIgnoreCase()
{
return IgnoreCase.Checked;
}
public string GetBranchFilter()
{
if (!Settings.BranchFilterEnabled || Settings.ShowCurrentBranchOnly)
return String.Empty;
return BranchFilter.Text;
}
public void SetBranchFilter(string filter)
{
BranchFilter.Text = filter;
}
public void SetLimit(int limit)
{
_NO_TRANSLATE_Limit.Value = limit;
}
private void OkClick(object sender, EventArgs e)
{
Close();
}
}
}