Skip to content

Commit 32eb7fb

Browse files
committed
Merge branch 'release/v2025.31'
2 parents cb03b07 + 6f7c695 commit 32eb7fb

File tree

104 files changed

+1896
-1156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1896
-1156
lines changed

TRANSLATION.md

Lines changed: 77 additions & 29 deletions
Large diffs are not rendered by default.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025.30
1+
2025.31

src/App.Commands.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Windows.Input;
3+
34
using Avalonia.Controls;
5+
using Avalonia.Controls.ApplicationLifetimes;
46

57
namespace SourceGit
68
{
@@ -53,5 +55,17 @@ public static bool IsCheckForUpdateCommandVisible
5355
else if (!string.IsNullOrEmpty(textBlock.Text))
5456
await CopyTextAsync(textBlock.Text);
5557
});
58+
59+
public static readonly Command HideAppCommand = new Command(_ =>
60+
{
61+
if (Current is App app && app.TryGetFeature(typeof(IActivatableLifetime)) is IActivatableLifetime lifetime)
62+
lifetime.TryEnterBackground();
63+
});
64+
65+
public static readonly Command ShowAppCommand = new Command(_ =>
66+
{
67+
if (Current is App app && app.TryGetFeature(typeof(IActivatableLifetime)) is IActivatableLifetime lifetime)
68+
lifetime.TryLeaveBackground();
69+
});
5670
}
5771
}

src/App.axaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<NativeMenuItem Header="{DynamicResource Text.Preferences}" Command="{x:Static s:App.OpenPreferencesCommand}" Gesture="⌘+,"/>
4343
<NativeMenuItem Header="{DynamicResource Text.OpenAppDataDir}" Command="{x:Static s:App.OpenAppDataDirCommand}"/>
4444
<NativeMenuItemSeparator/>
45+
<NativeMenuItem Header="{DynamicResource Text.App.Hide}" Command="{x:Static s:App.HideAppCommand}" Gesture="⌘+H"/>
46+
<NativeMenuItem Header="{DynamicResource Text.App.ShowAll}" Command="{x:Static s:App.ShowAppCommand}"/>
47+
<NativeMenuItemSeparator/>
4548
<NativeMenuItem Header="{DynamicResource Text.Quit}" Command="{x:Static s:App.QuitCommand}" Gesture="⌘+Q"/>
4649
</NativeMenu>
4750
</NativeMenu.Menu>

src/App.axaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,12 @@ public static void ShowWindow(object data)
158158
}
159159
}
160160

161-
public static async Task<bool> AskConfirmAsync(string message, Action onSure)
161+
public static async Task<bool> AskConfirmAsync(string message)
162162
{
163163
if (Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime { MainWindow: { } owner })
164164
{
165165
var confirm = new Views.Confirm();
166166
confirm.Message.Text = message;
167-
confirm.OnSure = onSure;
168167
return await confirm.ShowDialog<bool>(owner);
169168
}
170169

@@ -578,7 +577,7 @@ private void TryOpenRepository(string repo)
578577
{
579578
if (!string.IsNullOrEmpty(repo) && Directory.Exists(repo))
580579
{
581-
var test = new Commands.QueryRepositoryRootPath(repo).GetResultAsync().Result;
580+
var test = new Commands.QueryRepositoryRootPath(repo).GetResult();
582581
if (test.IsSuccess && !string.IsNullOrEmpty(test.StdOut))
583582
{
584583
Dispatcher.UIThread.Invoke(() =>

src/Commands/Command.cs

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,6 @@ public enum EditorType
3737
public bool RaiseError { get; set; } = true;
3838
public Models.ICommandLog Log { get; set; } = null;
3939

40-
public void Exec()
41-
{
42-
try
43-
{
44-
var start = CreateGitStartInfo(false);
45-
Process.Start(start);
46-
}
47-
catch (Exception ex)
48-
{
49-
App.RaiseException(Context, ex.Message);
50-
}
51-
}
52-
5340
public async Task<bool> ExecAsync()
5441
{
5542
Log?.AppendLine($"$ git {Args}\n");
@@ -127,6 +114,28 @@ public async Task<bool> ExecAsync()
127114
return true;
128115
}
129116

117+
protected Result ReadToEnd()
118+
{
119+
using var proc = new Process() { StartInfo = CreateGitStartInfo(true) };
120+
121+
try
122+
{
123+
proc.Start();
124+
}
125+
catch (Exception e)
126+
{
127+
return Result.Failed(e.Message);
128+
}
129+
130+
var rs = new Result() { IsSuccess = true };
131+
rs.StdOut = proc.StandardOutput.ReadToEnd();
132+
rs.StdErr = proc.StandardError.ReadToEnd();
133+
proc.WaitForExit();
134+
135+
rs.IsSuccess = proc.ExitCode == 0;
136+
return rs;
137+
}
138+
130139
protected async Task<Result> ReadToEndAsync()
131140
{
132141
using var proc = new Process() { StartInfo = CreateGitStartInfo(true) };
@@ -149,7 +158,7 @@ protected async Task<Result> ReadToEndAsync()
149158
return rs;
150159
}
151160

152-
private ProcessStartInfo CreateGitStartInfo(bool redirect)
161+
protected ProcessStartInfo CreateGitStartInfo(bool redirect)
153162
{
154163
var start = new ProcessStartInfo();
155164
start.FileName = Native.OS.GitExecutable;
@@ -167,8 +176,10 @@ private ProcessStartInfo CreateGitStartInfo(bool redirect)
167176
// Force using this app as SSH askpass program
168177
var selfExecFile = Process.GetCurrentProcess().MainModule!.FileName;
169178
start.Environment.Add("SSH_ASKPASS", selfExecFile); // Can not use parameter here, because it invoked by SSH with `exec`
170-
start.Environment.Add("SSH_ASKPASS_REQUIRE", "force");
179+
start.Environment.Add("SSH_ASKPASS_REQUIRE", "prefer");
171180
start.Environment.Add("SOURCEGIT_LAUNCH_AS_ASKPASS", "TRUE");
181+
if (!OperatingSystem.IsLinux())
182+
start.Environment.Add("DISPLAY", "required");
172183

173184
// If an SSH private key was provided, sets the environment.
174185
if (!start.Environment.ContainsKey("GIT_SSH_COMMAND") && !string.IsNullOrEmpty(SSHKey))

src/Commands/Config.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ public Config(string repository)
2020
}
2121
}
2222

23+
public Dictionary<string, string> ReadAll()
24+
{
25+
Args = "config -l";
26+
27+
var output = ReadToEnd();
28+
var rs = new Dictionary<string, string>();
29+
if (output.IsSuccess)
30+
{
31+
var lines = output.StdOut.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries);
32+
foreach (var line in lines)
33+
{
34+
var parts = line.Split('=', 2);
35+
if (parts.Length == 2)
36+
rs[parts[0]] = parts[1];
37+
}
38+
}
39+
40+
return rs;
41+
}
42+
2343
public async Task<Dictionary<string, string>> ReadAllAsync()
2444
{
2545
Args = "config -l";
@@ -40,6 +60,12 @@ public async Task<Dictionary<string, string>> ReadAllAsync()
4060
return rs;
4161
}
4262

63+
public string Get(string key)
64+
{
65+
Args = $"config {key}";
66+
return ReadToEnd().StdOut.Trim();
67+
}
68+
4369
public async Task<string> GetAsync(string key)
4470
{
4571
Args = $"config {key}";

src/Commands/DiffTool.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
namespace SourceGit.Commands
1+
using System;
2+
using System.Diagnostics;
3+
4+
namespace SourceGit.Commands
25
{
36
public class DiffTool : Command
47
{
@@ -28,7 +31,14 @@ public void Open()
2831
Args = $"-c difftool.sourcegit.cmd={cmd.Quoted()} difftool --tool=sourcegit --no-prompt {_option}";
2932
}
3033

31-
Exec();
34+
try
35+
{
36+
Process.Start(CreateGitStartInfo(false));
37+
}
38+
catch (Exception ex)
39+
{
40+
App.RaiseException(Context, ex.Message);
41+
}
3242
}
3343

3444
private Models.DiffOption _option;

src/Commands/Fetch.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public Fetch(string repo, string remote, bool noTags, bool force)
2121
Args += "--force ";
2222

2323
Args += remote;
24-
2524
}
2625

2726
public Fetch(string repo, Models.Branch local, Models.Branch remote)

src/Commands/IsBareRepository.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ public IsBareRepository(string path)
1111
Args = "rev-parse --is-bare-repository";
1212
}
1313

14+
public bool GetResult()
15+
{
16+
if (!Directory.Exists(Path.Combine(WorkingDirectory, "refs")) ||
17+
!Directory.Exists(Path.Combine(WorkingDirectory, "objects")) ||
18+
!File.Exists(Path.Combine(WorkingDirectory, "HEAD")))
19+
return false;
20+
21+
var rs = ReadToEnd();
22+
return rs.IsSuccess && rs.StdOut.Trim() == "true";
23+
}
24+
1425
public async Task<bool> GetResultAsync()
1526
{
1627
if (!Directory.Exists(Path.Combine(WorkingDirectory, "refs")) ||

0 commit comments

Comments
 (0)