diff --git a/src/App.axaml.cs b/src/App.axaml.cs index 5f730c9b..1b623334 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -458,12 +458,8 @@ namespace SourceGit var args = desktop.Args; if (args.Length <= 1 || !args[0].Equals("--askpass", StringComparison.Ordinal)) return false; - - var match = REG_ASKPASS().Match(args[1]); - if (!match.Success) - return false; - desktop.MainWindow = new Views.Askpass(Path.GetFileName(match.Groups[1].Value)); + desktop.MainWindow = new Views.Askpass(args[1]); return true; } @@ -483,9 +479,6 @@ namespace SourceGit } } - [GeneratedRegex(@"Enter\s+passphrase\s*for\s*key\s*['""]([^'""]+)['""]\:\s*", RegexOptions.IgnoreCase)] - private static partial Regex REG_ASKPASS(); - private ViewModels.Launcher _launcher = null; private ResourceDictionary _activeLocale = null; private ResourceDictionary _themeOverrides = null; diff --git a/src/Commands/Command.cs b/src/Commands/Command.cs index e3abcf04..1adb9422 100644 --- a/src/Commands/Command.cs +++ b/src/Commands/Command.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Text; using System.Text.RegularExpressions; + using Avalonia.Threading; namespace SourceGit.Commands @@ -38,11 +39,16 @@ namespace SourceGit.Commands public Dictionary Envs { get; set; } = new Dictionary(); public void UseSSHKey(string key) + { + UseSSHAskpass(); + Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{key}'"); + } + + public void UseSSHAskpass() { Envs.Add("DISPLAY", "required"); Envs.Add("SSH_ASKPASS", $"\"{Process.GetCurrentProcess().MainModule.FileName}\" --askpass"); Envs.Add("SSH_ASKPASS_REQUIRE", "prefer"); - Envs.Add("GIT_SSH_COMMAND", $"ssh -i '{key}'"); } public bool Exec() diff --git a/src/Commands/Commit.cs b/src/Commands/Commit.cs index 492d00c7..17da30ac 100644 --- a/src/Commands/Commit.cs +++ b/src/Commands/Commit.cs @@ -1,4 +1,5 @@ -using System.IO; +using System.Diagnostics; +using System.IO; namespace SourceGit.Commands { @@ -11,6 +12,7 @@ namespace SourceGit.Commands WorkingDirectory = repo; Context = repo; + TraitErrorAsOutput = true; Args = $"commit --file=\"{file}\""; if (autoStage) Args += " --all"; @@ -18,6 +20,8 @@ namespace SourceGit.Commands Args += " --amend --no-edit"; if (allowEmpty) Args += " --allow-empty"; + + UseSSHAskpass(); } } } diff --git a/src/Views/Askpass.axaml b/src/Views/Askpass.axaml index 0c88cccf..32b0a4b9 100644 --- a/src/Views/Askpass.axaml +++ b/src/Views/Askpass.axaml @@ -50,12 +50,9 @@ - - - - - - + + + SetValue(ShowPasswordProperty, value); } - public string KeyName + public string Description { get; private set; @@ -35,9 +35,9 @@ namespace SourceGit.Views InitializeComponent(); } - public Askpass(string keyname) + public Askpass(string description) { - KeyName = keyname; + Description = description; DataContext = this; InitializeComponent(); }