feature<GPG>: add gpg signing feature #5

This commit is contained in:
leo 2022-10-20 18:59:13 +08:00
parent a677f409a2
commit c1c57f9b1d
6 changed files with 157 additions and 10 deletions

View file

@ -13,6 +13,8 @@
<RowDefinition Height="32"/>
<RowDefinition Height="32"/>
<RowDefinition Height="32"/>
<RowDefinition Height="32"/>
<RowDefinition Height="32"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@ -52,5 +54,25 @@
Text="{Binding ElementName=me, Path=Proxy, Mode=TwoWay}"
Height="24"
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>
</controls:PopupWidget>

View file

@ -9,6 +9,8 @@ namespace SourceGit.Views.Popups {
public string UserName { get; set; }
public string UserEmail { get; set; }
public bool GPGSigningEnabled { get; set; }
public string GPGUserSigningKey { get; set; }
public string Proxy { get; set; }
public Configure(string repo) {
@ -17,6 +19,8 @@ namespace SourceGit.Views.Popups {
var cmd = new Commands.Config(repo);
UserName = cmd.Get("user.name");
UserEmail = cmd.Get("user.email");
GPGSigningEnabled = cmd.Get("commit.gpgsign") == "true";
GPGUserSigningKey = cmd.Get("user.signingkey");
Proxy = cmd.Get("http.proxy");
InitializeComponent();
@ -36,6 +40,11 @@ namespace SourceGit.Views.Popups {
if (oldEmail != UserEmail) cmd.Set("user.email", UserEmail);
var oldProxy = cmd.Get("http.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;
});
}