mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
feature<GPG>: add gpg signing feature #5
This commit is contained in:
parent
a677f409a2
commit
c1c57f9b1d
6 changed files with 157 additions and 10 deletions
|
@ -91,11 +91,11 @@
|
||||||
<sys:String x:Key="Text.CommitViewer.Files">FILES</sys:String>
|
<sys:String x:Key="Text.CommitViewer.Files">FILES</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.Configure">Configure</sys:String>
|
<sys:String x:Key="Text.Configure">Configure</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.User">User :</sys:String>
|
<sys:String x:Key="Text.Configure.User">User Name</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.User.Placeholder">User name for this repository</sys:String>
|
<sys:String x:Key="Text.Configure.User.Placeholder">User name for this repository</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.Email">Email :</sys:String>
|
<sys:String x:Key="Text.Configure.Email">Email Address</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.Email.Placeholder">Email address</sys:String>
|
<sys:String x:Key="Text.Configure.Email.Placeholder">Email address</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.Proxy">Proxy :</sys:String>
|
<sys:String x:Key="Text.Configure.Proxy">HTTP Proxy</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.Proxy.Placeholder">HTTP proxy used by this repository</sys:String>
|
<sys:String x:Key="Text.Configure.Proxy.Placeholder">HTTP proxy used by this repository</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.CreateBranch">Create Branch</sys:String>
|
<sys:String x:Key="Text.CreateBranch">Create Branch</sys:String>
|
||||||
|
@ -507,6 +507,13 @@
|
||||||
<sys:String x:Key="Text.Sort.RecentlyOpened">By Recently Opened</sys:String>
|
<sys:String x:Key="Text.Sort.RecentlyOpened">By Recently Opened</sys:String>
|
||||||
<sys:String x:Key="Text.Sort.Bookmark">By Bookmark Color</sys:String>
|
<sys:String x:Key="Text.Sort.Bookmark">By Bookmark Color</sys:String>
|
||||||
|
|
||||||
|
<sys:String x:Key="Text.GPG">GPG SIGNING</sys:String>
|
||||||
|
<sys:String x:Key="Text.GPG.Enabled">Commit GPG signing</sys:String>
|
||||||
|
<sys:String x:Key="Text.GPG.Path">Install Path</sys:String>
|
||||||
|
<sys:String x:Key="Text.GPG.Path.Placeholder">Input path for installed gpg program</sys:String>
|
||||||
|
<sys:String x:Key="Text.GPG.UserKey">User Signing Key</sys:String>
|
||||||
|
<sys:String x:Key="Text.GPG.UserKey.Placeholder">User's gpg signing key</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.NotConfigured">Git has NOT been configured. Please to go [Preference] and configure it first.</sys:String>
|
<sys:String x:Key="Text.NotConfigured">Git has NOT been configured. Please to go [Preference] and configure it first.</sys:String>
|
||||||
<sys:String x:Key="Text.PathNotFound">Path[{0}] not exists!</sys:String>
|
<sys:String x:Key="Text.PathNotFound">Path[{0}] not exists!</sys:String>
|
||||||
<sys:String x:Key="Text.MissingBash">Can NOT locate bash.exe. Make sure bash.exe exists under the same folder with git.exe</sys:String>
|
<sys:String x:Key="Text.MissingBash">Can NOT locate bash.exe. Make sure bash.exe exists under the same folder with git.exe</sys:String>
|
||||||
|
|
|
@ -90,11 +90,11 @@
|
||||||
<sys:String x:Key="Text.CommitViewer.Files">文件列表</sys:String>
|
<sys:String x:Key="Text.CommitViewer.Files">文件列表</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.Configure">仓库配置</sys:String>
|
<sys:String x:Key="Text.Configure">仓库配置</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.User">用户 :</sys:String>
|
<sys:String x:Key="Text.Configure.User">用户名</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.User.Placeholder">应用于本仓库的用户名</sys:String>
|
<sys:String x:Key="Text.Configure.User.Placeholder">应用于本仓库的用户名</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.Email">邮箱 :</sys:String>
|
<sys:String x:Key="Text.Configure.Email">电子邮箱</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.Email.Placeholder">邮箱地址</sys:String>
|
<sys:String x:Key="Text.Configure.Email.Placeholder">邮箱地址</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.Proxy">代理 :</sys:String>
|
<sys:String x:Key="Text.Configure.Proxy">HTTP代理</sys:String>
|
||||||
<sys:String x:Key="Text.Configure.Proxy.Placeholder">HTTP网络代理</sys:String>
|
<sys:String x:Key="Text.Configure.Proxy.Placeholder">HTTP网络代理</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.CreateBranch">新建分支</sys:String>
|
<sys:String x:Key="Text.CreateBranch">新建分支</sys:String>
|
||||||
|
@ -506,6 +506,13 @@
|
||||||
<sys:String x:Key="Text.Sort.RecentlyOpened">按最近访问</sys:String>
|
<sys:String x:Key="Text.Sort.RecentlyOpened">按最近访问</sys:String>
|
||||||
<sys:String x:Key="Text.Sort.Bookmark">按书签颜色</sys:String>
|
<sys:String x:Key="Text.Sort.Bookmark">按书签颜色</sys:String>
|
||||||
|
|
||||||
|
<sys:String x:Key="Text.GPG">GPG签名</sys:String>
|
||||||
|
<sys:String x:Key="Text.GPG.Enabled">启用提交签名</sys:String>
|
||||||
|
<sys:String x:Key="Text.GPG.Path">可执行文件位置</sys:String>
|
||||||
|
<sys:String x:Key="Text.GPG.Path.Placeholder">gpg.exe所在路径</sys:String>
|
||||||
|
<sys:String x:Key="Text.GPG.UserKey">用户签名KEY</sys:String>
|
||||||
|
<sys:String x:Key="Text.GPG.UserKey.Placeholder">输入签名提交所使用的KEY</sys:String>
|
||||||
|
|
||||||
<sys:String x:Key="Text.NotConfigured">GIT尚未配置。请打开【偏好设置】配置GIT路径。</sys:String>
|
<sys:String x:Key="Text.NotConfigured">GIT尚未配置。请打开【偏好设置】配置GIT路径。</sys:String>
|
||||||
<sys:String x:Key="Text.PathNotFound">路径({0})不存在或不可读取!</sys:String>
|
<sys:String x:Key="Text.PathNotFound">路径({0})不存在或不可读取!</sys:String>
|
||||||
<sys:String x:Key="Text.MissingBash">无法找到bash.exe,请确保其在git.exe同目录中!</sys:String>
|
<sys:String x:Key="Text.MissingBash">无法找到bash.exe,请确保其在git.exe同目录中!</sys:String>
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
<RowDefinition Height="32"/>
|
<RowDefinition Height="32"/>
|
||||||
<RowDefinition Height="32"/>
|
<RowDefinition Height="32"/>
|
||||||
<RowDefinition Height="32"/>
|
<RowDefinition Height="32"/>
|
||||||
|
<RowDefinition Height="32"/>
|
||||||
|
<RowDefinition Height="32"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
@ -52,5 +54,25 @@
|
||||||
Text="{Binding ElementName=me, Path=Proxy, Mode=TwoWay}"
|
Text="{Binding ElementName=me, Path=Proxy, Mode=TwoWay}"
|
||||||
Height="24"
|
Height="24"
|
||||||
Placeholder="{DynamicResource Text.Configure.Proxy.Placeholder}"/>
|
Placeholder="{DynamicResource Text.Configure.Proxy.Placeholder}"/>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="3" Grid.Column="0"
|
||||||
|
Margin="0,0,8,0"
|
||||||
|
Text="{DynamicResource Text.GPG.Enabled}"
|
||||||
|
HorizontalAlignment="Right"/>
|
||||||
|
<CheckBox
|
||||||
|
Grid.Row="3" Grid.Column="1"
|
||||||
|
IsChecked="{Binding ElementName=me, Path=GPGSigningEnabled, Mode=TwoWay}"/>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="4" Grid.Column="0"
|
||||||
|
Margin="0,0,8,0"
|
||||||
|
Text="{DynamicResource Text.GPG.UserKey}"
|
||||||
|
HorizontalAlignment="Right"/>
|
||||||
|
<controls:TextEdit
|
||||||
|
Grid.Row="4" Grid.Column="1"
|
||||||
|
Text="{Binding ElementName=me, Path=GPGUserSigningKey, Mode=TwoWay}"
|
||||||
|
Height="24"
|
||||||
|
Placeholder="{DynamicResource Text.GPG.UserKey.Placeholder}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</controls:PopupWidget>
|
</controls:PopupWidget>
|
||||||
|
|
|
@ -9,6 +9,8 @@ namespace SourceGit.Views.Popups {
|
||||||
|
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
public string UserEmail { get; set; }
|
public string UserEmail { get; set; }
|
||||||
|
public bool GPGSigningEnabled { get; set; }
|
||||||
|
public string GPGUserSigningKey { get; set; }
|
||||||
public string Proxy { get; set; }
|
public string Proxy { get; set; }
|
||||||
|
|
||||||
public Configure(string repo) {
|
public Configure(string repo) {
|
||||||
|
@ -17,6 +19,8 @@ namespace SourceGit.Views.Popups {
|
||||||
var cmd = new Commands.Config(repo);
|
var cmd = new Commands.Config(repo);
|
||||||
UserName = cmd.Get("user.name");
|
UserName = cmd.Get("user.name");
|
||||||
UserEmail = cmd.Get("user.email");
|
UserEmail = cmd.Get("user.email");
|
||||||
|
GPGSigningEnabled = cmd.Get("commit.gpgsign") == "true";
|
||||||
|
GPGUserSigningKey = cmd.Get("user.signingkey");
|
||||||
Proxy = cmd.Get("http.proxy");
|
Proxy = cmd.Get("http.proxy");
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -36,6 +40,11 @@ namespace SourceGit.Views.Popups {
|
||||||
if (oldEmail != UserEmail) cmd.Set("user.email", UserEmail);
|
if (oldEmail != UserEmail) cmd.Set("user.email", UserEmail);
|
||||||
var oldProxy = cmd.Get("http.proxy");
|
var oldProxy = cmd.Get("http.proxy");
|
||||||
if (oldProxy != Proxy) cmd.Set("http.proxy", Proxy);
|
if (oldProxy != Proxy) cmd.Set("http.proxy", Proxy);
|
||||||
|
var oldGPGSigningEnabled = cmd.Get("commit.gpgsign") == "true";
|
||||||
|
if (oldGPGSigningEnabled != GPGSigningEnabled) cmd.Set("commit.gpgsign", GPGSigningEnabled ? "true" : "false");
|
||||||
|
var oldGPGUserSigningKey = cmd.Get("user.signingkey");
|
||||||
|
if (oldGPGUserSigningKey != GPGUserSigningKey) cmd.Set("user.signingkey", GPGUserSigningKey);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,6 +287,69 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
|
<!-- GPG Signing -->
|
||||||
|
<TabItem Header="{DynamicResource Text.GPG}">
|
||||||
|
<Grid Margin="8">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="28"/>
|
||||||
|
<RowDefinition Height="28"/>
|
||||||
|
<RowDefinition Height="28"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="140"/>
|
||||||
|
<ColumnDefinition Width="8"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="0" Grid.Column="0"
|
||||||
|
Text="{DynamicResource Text.GPG.Enabled}"
|
||||||
|
HorizontalAlignment="Right"/>
|
||||||
|
<CheckBox
|
||||||
|
Grid.Row="0" Grid.Column="2"
|
||||||
|
IsChecked="{Binding ElementName=me, Path=GPGSigningEnabled, Mode=TwoWay}"/>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="1" Grid.Column="0"
|
||||||
|
Text="{DynamicResource Text.GPG.Path}"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Margin="0,0,8,0"/>
|
||||||
|
<Grid Grid.Row="1" Grid.Column="2">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<controls:TextEdit
|
||||||
|
Grid.Column="0"
|
||||||
|
Height="24"
|
||||||
|
x:Name="txtGPGExec"
|
||||||
|
Placeholder="{DynamicResource Text.GPG.Path.Placeholder}"
|
||||||
|
Text="{Binding ElementName=me, Path=GPGExec, Mode=TwoWay}"/>
|
||||||
|
<controls:IconButton
|
||||||
|
Grid.Column="1"
|
||||||
|
Click="SelectGPGExec"
|
||||||
|
Width="24" Height="24"
|
||||||
|
Margin="4,0,0,0" Padding="4"
|
||||||
|
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
|
||||||
|
Icon="{StaticResource Icon.Folder.Open}"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Grid.Row="2" Grid.Column="0"
|
||||||
|
Text="{DynamicResource Text.GPG.UserKey}"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Margin="0,0,8,0"/>
|
||||||
|
<controls:TextEdit
|
||||||
|
Grid.Row="2" Grid.Column="2"
|
||||||
|
Height="24"
|
||||||
|
Text="{Binding ElementName=me, Path=GPGUserSigningKey, Mode=TwoWay}"
|
||||||
|
Placeholder="{DynamicResource Text.GPG.UserKey.Placeholder}"/>
|
||||||
|
</Grid>
|
||||||
|
</TabItem>
|
||||||
|
|
||||||
|
<!-- External Merger -->
|
||||||
<TabItem Header="{DynamicResource Text.Preference.Merger}">
|
<TabItem Header="{DynamicResource Text.Preference.Merger}">
|
||||||
<Grid Margin="8">
|
<Grid Margin="8">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
@ -295,7 +358,7 @@
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="100"/>
|
<ColumnDefinition Width="120"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ namespace SourceGit.Views {
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public string CRLF { get; set; }
|
public string CRLF { get; set; }
|
||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
|
public string GPGExec { get; set; }
|
||||||
|
public bool GPGSigningEnabled { get; set; }
|
||||||
|
public string GPGUserSigningKey { get; set; }
|
||||||
|
|
||||||
public Preference() {
|
public Preference() {
|
||||||
UpdateGitInfo(false);
|
UpdateGitInfo(false);
|
||||||
|
@ -24,22 +27,35 @@ namespace SourceGit.Views {
|
||||||
private bool UpdateGitInfo(bool updateUi) {
|
private bool UpdateGitInfo(bool updateUi) {
|
||||||
var isReady = Models.Preference.Instance.IsReady;
|
var isReady = Models.Preference.Instance.IsReady;
|
||||||
if (isReady) {
|
if (isReady) {
|
||||||
User = new Commands.Config().Get("user.name");
|
var cmd = new Commands.Config();
|
||||||
Email = new Commands.Config().Get("user.email");
|
User = cmd.Get("user.name");
|
||||||
CRLF = new Commands.Config().Get("core.autocrlf");
|
Email = cmd.Get("user.email");
|
||||||
|
CRLF = cmd.Get("core.autocrlf");
|
||||||
Version = new Commands.Version().Query();
|
Version = new Commands.Version().Query();
|
||||||
if (string.IsNullOrEmpty(CRLF)) CRLF = "false";
|
if (string.IsNullOrEmpty(CRLF)) CRLF = "false";
|
||||||
|
GPGExec = cmd.Get("gpg.program");
|
||||||
|
if (string.IsNullOrEmpty(GPGExec)) {
|
||||||
|
string gitInstallFolder = Path.GetDirectoryName(Models.Preference.Instance.Git.Path);
|
||||||
|
string defaultGPG = Path.GetFullPath(Path.Join(gitInstallFolder, "..", "usr", "bin", "gpg.exe"));
|
||||||
|
if (File.Exists(defaultGPG)) GPGExec = defaultGPG;
|
||||||
|
}
|
||||||
|
GPGSigningEnabled = cmd.Get("commit.gpgsign") == "true";
|
||||||
|
GPGUserSigningKey = cmd.Get("user.signingkey");
|
||||||
} else {
|
} else {
|
||||||
User = "";
|
User = "";
|
||||||
Email = "";
|
Email = "";
|
||||||
CRLF = "false";
|
CRLF = "false";
|
||||||
Version = "Unknown";
|
Version = "Unknown";
|
||||||
|
GPGExec = "";
|
||||||
|
GPGSigningEnabled = false;
|
||||||
|
GPGUserSigningKey = "";
|
||||||
}
|
}
|
||||||
if (updateUi) {
|
if (updateUi) {
|
||||||
editGitUser?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
editGitUser?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||||
editGitEmail?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
editGitEmail?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||||
editGitCrlf?.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateTarget();
|
editGitCrlf?.GetBindingExpression(ComboBox.SelectedValueProperty).UpdateTarget();
|
||||||
textGitVersion?.GetBindingExpression(TextBlock.TextProperty).UpdateTarget();
|
textGitVersion?.GetBindingExpression(TextBlock.TextProperty).UpdateTarget();
|
||||||
|
txtGPGExec?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||||
}
|
}
|
||||||
return isReady;
|
return isReady;
|
||||||
}
|
}
|
||||||
|
@ -81,6 +97,19 @@ namespace SourceGit.Views {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SelectGPGExec(object sender, RoutedEventArgs e) {
|
||||||
|
var dialog = new OpenFileDialog();
|
||||||
|
dialog.Filter = $"GPG Executable|gpg.exe";
|
||||||
|
dialog.Title = App.Text("Text.GPG.Path.Placeholder");
|
||||||
|
dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
||||||
|
dialog.CheckFileExists = true;
|
||||||
|
|
||||||
|
if (dialog.ShowDialog() == true) {
|
||||||
|
GPGExec = dialog.FileName;
|
||||||
|
txtGPGExec?.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SelectMergeTool(object sender, RoutedEventArgs e) {
|
private void SelectMergeTool(object sender, RoutedEventArgs e) {
|
||||||
var type = Models.Preference.Instance.MergeTool.Type;
|
var type = Models.Preference.Instance.MergeTool.Type;
|
||||||
var tool = Models.MergeTool.Supported.Find(x => x.Type == type);
|
var tool = Models.MergeTool.Supported.Find(x => x.Type == type);
|
||||||
|
@ -123,6 +152,16 @@ namespace SourceGit.Views {
|
||||||
|
|
||||||
var oldCRLF = cmd.Get("core.autocrlf");
|
var oldCRLF = cmd.Get("core.autocrlf");
|
||||||
if (oldCRLF != CRLF) cmd.Set("core.autocrlf", CRLF);
|
if (oldCRLF != CRLF) cmd.Set("core.autocrlf", CRLF);
|
||||||
|
|
||||||
|
var oldGPGExec = cmd.Get("gpg.program");
|
||||||
|
if (oldGPGExec != GPGExec) cmd.Set("gpg.program", GPGExec);
|
||||||
|
|
||||||
|
var oldGPGSigningEnabledStr = cmd.Get("commit.gpgsign");
|
||||||
|
var oldGPGSigningEnabled = "true" == oldGPGSigningEnabledStr;
|
||||||
|
if (oldGPGSigningEnabled != GPGSigningEnabled) cmd.Set("commit.gpgsign", GPGSigningEnabled ? "true" : "false");
|
||||||
|
|
||||||
|
var oldGPGUserSigningKey = cmd.Get("user.signingkey");
|
||||||
|
if (oldGPGUserSigningKey != GPGUserSigningKey) cmd.Set("user.signingkey", GPGUserSigningKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
Models.Preference.Save();
|
Models.Preference.Save();
|
||||||
|
|
Loading…
Reference in a new issue