Skip to content

Commit 1455065

Browse files
authored
Merge branch 'master' into feature/resx
2 parents ad1fdbe + 18aaa0a commit 1455065

File tree

235 files changed

+8624
-4380
lines changed

Some content is hidden

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

235 files changed

+8624
-4380
lines changed

.editorconfig

Lines changed: 364 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Opensouce Git GUI client.
2626
* Revision Diffs
2727
* GitFlow support
2828

29+
> **Linux** only tested on **Ubuntu 22.04** on **X11**.
30+
2931
## How to use
3032

3133
**To use this tool, you need to install Git first.**
@@ -43,7 +45,7 @@ For **macOS** users:
4345
For **Linux** users:
4446

4547
* `xdg-open` must be installed to support open native file manager.
46-
* Only tested on `Ubuntu 22.04`.
48+
* Maybe you need to set environment variable `AVALONIA_SCREEN_SCALE_FACTORS`. See https://github.com/AvaloniaUI/Avalonia/wiki/Configuring-X11-per-monitor-DPI.
4749

4850
## Screen Shots
4951

@@ -55,12 +57,10 @@ For **Linux** users:
5557

5658
![Theme Light](./screenshots/theme_light.png)
5759

58-
## Thanks
60+
## Contributing
61+
62+
Thanks to all the people who contribute.
5963

60-
* [gigi81](https://github.com/gigi81) Github actions integration
61-
* [kekekeks](https://github.com/kekekeks) Way to stage/unstage/discard selected changes in a file.
62-
* [XiaoLinger](https://gitee.com/LingerNN) Hotkey: `CTRL + Enter` to commit
63-
* [carterl](https://gitee.com/carterl) Supports Windows Terminal; Rewrite way to find git executable
64-
* [PUMA](https://gitee.com/whgfu) Configure for default user
65-
* [Rwing](https://gitee.com/rwing) GitFlow: add an option to keep branch after finish
66-
* [XiaoLinger](https://gitee.com/LingerNN) Fix localizations in popup panel
64+
<a href="https://github.com/sourcegit-scm/sourcegit/graphs/contributors">
65+
<img src="https://contrib.rocks/image?repo=sourcegit-scm/sourcegit" />
66+
</a>

src/App.axaml.cs

Lines changed: 73 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
using System;
2+
using System.IO;
3+
using System.Reflection;
4+
using System.Text;
5+
using System.Globalization;
6+
using System.Linq;
7+
using System.Reflection;
8+
using System.Threading;
9+
110
using Avalonia;
211
using Avalonia.Controls;
312
using Avalonia.Controls.ApplicationLifetimes;
@@ -6,22 +15,21 @@
615
using Avalonia.Media;
716
using Avalonia.Media.Fonts;
817
using Avalonia.Styling;
9-
using System;
10-
using System.Globalization;
11-
using System.IO;
12-
using System.Linq;
13-
using System.Reflection;
14-
using System.Text;
15-
using System.Threading;
1618

17-
namespace SourceGit {
18-
public partial class App : Application {
19+
namespace SourceGit
20+
{
21+
public partial class App : Application
22+
{
1923

2024
[STAThread]
21-
public static void Main(string[] args) {
22-
try {
25+
public static void Main(string[] args)
26+
{
27+
try
28+
{
2329
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
24-
} catch (Exception ex) {
30+
}
31+
catch (Exception ex)
32+
{
2533
var builder = new StringBuilder();
2634
builder.Append("Crash: ");
2735
builder.Append(ex.Message);
@@ -39,40 +47,48 @@ public static void Main(string[] args) {
3947
"SourceGit",
4048
$"crash_{time}.log");
4149
File.WriteAllText(file, builder.ToString());
42-
}
50+
}
4351
}
4452

45-
public static AppBuilder BuildAvaloniaApp() {
53+
public static AppBuilder BuildAvaloniaApp()
54+
{
4655
var builder = AppBuilder.Configure<App>();
4756
builder.UsePlatformDetect();
4857
builder.LogToTrace();
49-
builder.ConfigureFonts(manager => {
58+
builder.ConfigureFonts(manager =>
59+
{
5060
var monospace = new EmbeddedFontCollection(
5161
new Uri("fonts:SourceGit", UriKind.Absolute),
5262
new Uri("avares://SourceGit/Resources/Fonts", UriKind.Absolute));
5363
manager.AddFontCollection(monospace);
5464
});
5565

56-
Native.OS.SetupFonts(builder);
66+
Native.OS.SetupApp(builder);
5767
return builder;
5868
}
5969

60-
public static void RaiseException(string context, string message) {
61-
if (Current is App app && app._notificationReceiver != null) {
70+
public static void RaiseException(string context, string message)
71+
{
72+
if (Current is App app && app._notificationReceiver != null)
73+
{
6274
var notice = new Models.Notification() { IsError = true, Message = message };
6375
app._notificationReceiver.OnReceiveNotification(context, notice);
6476
}
6577
}
6678

67-
public static void SendNotification(string context, string message) {
68-
if (Current is App app && app._notificationReceiver != null) {
79+
public static void SendNotification(string context, string message)
80+
{
81+
if (Current is App app && app._notificationReceiver != null)
82+
{
6983
var notice = new Models.Notification() { IsError = false, Message = message };
7084
app._notificationReceiver.OnReceiveNotification(context, notice);
7185
}
7286
}
7387

74-
public static void SetLocale(string localeKey) {
88+
public static void SetLocale(string localeKey)
89+
{
7590
var app = Current as App;
91+
7692
localeKey = localeKey.Replace("_", "-");
7793

7894
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(localeKey);
@@ -92,39 +108,51 @@ public static void SetLocale(string localeKey) {
92108
return;
93109
}
94110

95-
if (app._activeLocale != null) {
111+
if (app._activeLocale != null)
112+
{
96113
app.Resources.MergedDictionaries.Remove(app._activeLocale);
97114
}
98115

99116
app.Resources.MergedDictionaries.Add(targetLocale);
100117
app._activeLocale = targetLocale;
101118
}
102119

103-
public static void SetTheme(string theme) {
104-
if (theme.Equals("Light", StringComparison.OrdinalIgnoreCase)) {
120+
public static void SetTheme(string theme)
121+
{
122+
if (theme.Equals("Light", StringComparison.OrdinalIgnoreCase))
123+
{
105124
Current.RequestedThemeVariant = ThemeVariant.Light;
106-
} else if (theme.Equals("Dark", StringComparison.OrdinalIgnoreCase)) {
125+
}
126+
else if (theme.Equals("Dark", StringComparison.OrdinalIgnoreCase))
127+
{
107128
Current.RequestedThemeVariant = ThemeVariant.Dark;
108-
} else {
129+
}
130+
else
131+
{
109132
Current.RequestedThemeVariant = ThemeVariant.Default;
110133
}
111134
}
112135

113-
public static async void CopyText(string data) {
114-
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
115-
if (desktop.MainWindow.Clipboard is { } clipbord) {
136+
public static async void CopyText(string data)
137+
{
138+
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
139+
{
140+
if (desktop.MainWindow.Clipboard is { } clipbord)
141+
{
116142
await clipbord.SetTextAsync(data);
117143
}
118144
}
119145
}
120146

121-
public static string Text(string key, params object[] args) {
147+
public static string Text(string key, params object[] args)
148+
{
122149
var fmt = Current.FindResource($"Text.{key}") as string;
123150
if (string.IsNullOrWhiteSpace(fmt)) return $"Text.{key}";
124151
return string.Format(fmt, args);
125152
}
126153

127-
public static Avalonia.Controls.Shapes.Path CreateMenuIcon(string key) {
154+
public static Avalonia.Controls.Shapes.Path CreateMenuIcon(string key)
155+
{
128156
var icon = new Avalonia.Controls.Shapes.Path();
129157
icon.Width = 12;
130158
icon.Height = 12;
@@ -133,29 +161,36 @@ public static Avalonia.Controls.Shapes.Path CreateMenuIcon(string key) {
133161
return icon;
134162
}
135163

136-
public static TopLevel GetTopLevel() {
137-
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
164+
public static TopLevel GetTopLevel()
165+
{
166+
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
167+
{
138168
return desktop.MainWindow;
139169
}
140170
return null;
141171
}
142172

143-
public static void Quit() {
144-
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
173+
public static void Quit()
174+
{
175+
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
176+
{
145177
desktop.MainWindow.Close();
146178
desktop.Shutdown();
147179
}
148180
}
149181

150-
public override void Initialize() {
182+
public override void Initialize()
183+
{
151184
AvaloniaXamlLoader.Load(this);
152185

153186
SetLocale(ViewModels.Preference.Instance.Locale);
154187
SetTheme(ViewModels.Preference.Instance.Theme);
155188
}
156189

157-
public override void OnFrameworkInitializationCompleted() {
158-
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) {
190+
public override void OnFrameworkInitializationCompleted()
191+
{
192+
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
193+
{
159194
BindingPlugins.DataValidators.RemoveAt(0);
160195

161196
var launcher = new Views.Launcher();

src/Commands/Add.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
using System.Collections.Generic;
22
using System.Text;
33

4-
namespace SourceGit.Commands {
5-
public class Add : Command {
6-
public Add(string repo, List<Models.Change> changes = null) {
4+
namespace SourceGit.Commands
5+
{
6+
public class Add : Command
7+
{
8+
public Add(string repo, List<Models.Change> changes = null)
9+
{
710
WorkingDirectory = repo;
811
Context = repo;
912

10-
if (changes == null || changes.Count == 0) {
13+
if (changes == null || changes.Count == 0)
14+
{
1115
Args = "add .";
12-
} else {
16+
}
17+
else
18+
{
1319
var builder = new StringBuilder();
1420
builder.Append("add --");
15-
foreach (var c in changes) {
21+
foreach (var c in changes)
22+
{
1623
builder.Append(" \"");
1724
builder.Append(c.Path);
1825
builder.Append("\"");
@@ -21,4 +28,4 @@ public Add(string repo, List<Models.Change> changes = null) {
2128
}
2229
}
2330
}
24-
}
31+
}

src/Commands/Apply.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
namespace SourceGit.Commands {
2-
public class Apply : Command {
3-
public Apply(string repo, string file, bool ignoreWhitespace, string whitespaceMode, string extra) {
1+
namespace SourceGit.Commands
2+
{
3+
public class Apply : Command
4+
{
5+
public Apply(string repo, string file, bool ignoreWhitespace, string whitespaceMode, string extra)
6+
{
47
WorkingDirectory = repo;
58
Context = repo;
69
Args = "apply ";
@@ -10,4 +13,4 @@ public Apply(string repo, string file, bool ignoreWhitespace, string whitespaceM
1013
Args += $"\"{file}\"";
1114
}
1215
}
13-
}
16+
}

src/Commands/Archive.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
using System;
22

3-
namespace SourceGit.Commands {
4-
public class Archive : Command {
5-
public Archive(string repo, string revision, string saveTo, Action<string> outputHandler) {
3+
namespace SourceGit.Commands
4+
{
5+
public class Archive : Command
6+
{
7+
public Archive(string repo, string revision, string saveTo, Action<string> outputHandler)
8+
{
69
WorkingDirectory = repo;
710
Context = repo;
811
Args = $"archive --format=zip --verbose --output=\"{saveTo}\" {revision}";
912
TraitErrorAsOutput = true;
1013
_outputHandler = outputHandler;
1114
}
1215

13-
protected override void OnReadline(string line) {
16+
protected override void OnReadline(string line)
17+
{
1418
_outputHandler?.Invoke(line);
1519
}
1620

17-
private Action<string> _outputHandler;
21+
private readonly Action<string> _outputHandler;
1822
}
19-
}
23+
}

0 commit comments

Comments
 (0)