Skip to content

Commit 283c681

Browse files
committed
Merge branch 'release/v8.12'
2 parents 56780f9 + 146f33b commit 283c681

29 files changed

+314
-126
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ This app supports open repository in external tools listed in the table below.
9191
Thanks to all the people who contribute.
9292

9393
<a href="https://github.com/sourcegit-scm/sourcegit/graphs/contributors">
94-
<img src="https://contrib.rocks/image?repo=sourcegit-scm/sourcegit&t=2" />
94+
<img src="https://contrib.rocks/image?repo=sourcegit-scm/sourcegit&columns=10&t=3" />
9595
</a>

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.11
1+
8.12
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
exec /opt/sourcegit/sourcegit

src/App.axaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<Application xmlns="https://github.com/avaloniaui"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:s="using:SourceGit"
34
x:Class="SourceGit.App"
45
Name="SourceGit"
56
RequestedThemeVariant="Dark">
@@ -21,4 +22,16 @@
2122
<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
2223
<StyleInclude Source="/Resources/Styles.axaml"/>
2324
</Application.Styles>
25+
26+
<NativeMenu.Menu>
27+
<NativeMenu>
28+
<NativeMenuItem Header="{DynamicResource Text.About.Menu}" Command="{x:Static s:App.OpenAboutCommand}"/>
29+
<NativeMenuItem Header="{DynamicResource Text.Hotkeys.Menu}" Command="{x:Static s:App.OpenHotkeysCommand}"/>
30+
<NativeMenuItem Header="{DynamicResource Text.SelfUpdate}" Command="{x:Static s:App.CheckForUpdateCommand}"/>
31+
<NativeMenuItemSeparator/>
32+
<NativeMenuItem Header="{DynamicResource Text.Preference}" Command="{x:Static s:App.OpenPreferenceCommand}" Gesture="⌘+,"/>
33+
<NativeMenuItemSeparator/>
34+
<NativeMenuItem Header="{DynamicResource Text.Quit}" Command="{x:Static s:App.QuitCommand}"/>
35+
</NativeMenu>
36+
</NativeMenu.Menu>
2437
</Application>

src/App.axaml.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text;
66
using System.Text.Json;
77
using System.Threading.Tasks;
8+
using System.Windows.Input;
89

910
using Avalonia;
1011
using Avalonia.Controls;
@@ -18,9 +19,27 @@
1819

1920
namespace SourceGit
2021
{
21-
public partial class App : Application
22+
public class SimpleCommand : ICommand
2223
{
24+
public event EventHandler CanExecuteChanged
25+
{
26+
add { }
27+
remove { }
28+
}
29+
30+
public SimpleCommand(Action action)
31+
{
32+
_action = action;
33+
}
34+
35+
public bool CanExecute(object parameter) => _action != null;
36+
public void Execute(object parameter) => _action?.Invoke();
2337

38+
private Action _action = null;
39+
}
40+
41+
public partial class App : Application
42+
{
2443
[STAThread]
2544
public static void Main(string[] args)
2645
{
@@ -67,6 +86,31 @@ public static AppBuilder BuildAvaloniaApp()
6786
return builder;
6887
}
6988

89+
public static readonly SimpleCommand OpenPreferenceCommand = new SimpleCommand(() =>
90+
{
91+
var dialog = new Views.Preference();
92+
dialog.ShowDialog(GetTopLevel() as Window);
93+
});
94+
95+
public static readonly SimpleCommand OpenHotkeysCommand = new SimpleCommand(() =>
96+
{
97+
var dialog = new Views.Hotkeys();
98+
dialog.ShowDialog(GetTopLevel() as Window);
99+
});
100+
101+
public static readonly SimpleCommand OpenAboutCommand = new SimpleCommand(() =>
102+
{
103+
var dialog = new Views.About();
104+
dialog.ShowDialog(GetTopLevel() as Window);
105+
});
106+
107+
public static readonly SimpleCommand CheckForUpdateCommand = new SimpleCommand(() =>
108+
{
109+
Check4Update(true);
110+
});
111+
112+
public static readonly SimpleCommand QuitCommand = new SimpleCommand(Quit);
113+
70114
public static void RaiseException(string context, string message)
71115
{
72116
if (Current is App app && app._notificationReceiver != null)

src/Commands/Fetch.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,30 @@ protected override void OnReadline(string line)
6262

6363
public class AutoFetch
6464
{
65-
private const double INTERVAL = 10 * 60;
66-
6765
public static bool IsEnabled
6866
{
6967
get;
7068
set;
7169
} = false;
7270

71+
public static int Interval
72+
{
73+
get => _interval;
74+
set
75+
{
76+
if (value < 1)
77+
return;
78+
_interval = value;
79+
lock (_lock)
80+
{
81+
foreach (var job in _jobs)
82+
{
83+
job.Value.NextRunTimepoint = DateTime.Now.AddMinutes(Convert.ToDouble(_interval));
84+
}
85+
}
86+
}
87+
}
88+
7389
class Job
7490
{
7591
public Fetch Cmd = null;
@@ -104,7 +120,7 @@ static AutoFetch()
104120
foreach (var job in uptodate)
105121
{
106122
job.Cmd.Exec();
107-
job.NextRunTimepoint = DateTime.Now.AddSeconds(INTERVAL);
123+
job.NextRunTimepoint = DateTime.Now.AddMinutes(Convert.ToDouble(Interval));
108124
}
109125

110126
Thread.Sleep(2000);
@@ -117,7 +133,7 @@ public static void AddRepository(string repo)
117133
var job = new Job
118134
{
119135
Cmd = new Fetch(repo, "--all", true, null) { RaiseError = false },
120-
NextRunTimepoint = DateTime.Now.AddSeconds(INTERVAL),
136+
NextRunTimepoint = DateTime.Now.AddMinutes(Convert.ToDouble(Interval)),
121137
};
122138

123139
lock (_lock)
@@ -147,12 +163,13 @@ public static void MarkFetched(string repo)
147163
{
148164
if (_jobs.TryGetValue(repo, out var value))
149165
{
150-
value.NextRunTimepoint = DateTime.Now.AddSeconds(INTERVAL);
166+
value.NextRunTimepoint = DateTime.Now.AddMinutes(Convert.ToDouble(Interval));
151167
}
152168
}
153169
}
154170

155171
private static readonly Dictionary<string, Job> _jobs = new Dictionary<string, Job>();
156172
private static readonly object _lock = new object();
173+
private static int _interval = 10;
157174
}
158175
}

src/Models/User.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Concurrent;
22

33
namespace SourceGit.Models
44
{
@@ -36,11 +36,11 @@ public static User FindOrAdd(string data)
3636
var email = data.Substring(nameEndIdx + 1);
3737

3838
User user = new User() { Name = name, Email = email };
39-
_caches.Add(data, user);
39+
_caches.TryAdd(data, user);
4040
return user;
4141
}
4242
}
4343

44-
private static Dictionary<string, User> _caches = new Dictionary<string, User>();
44+
private static ConcurrentDictionary<string, User> _caches = new ConcurrentDictionary<string, User>();
4545
}
4646
}

src/Models/Watcher.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ private void OnRepositoryChanged(object o, FileSystemEventArgs e)
180180
}
181181
else if (name.Equals("HEAD", StringComparison.Ordinal) ||
182182
name.StartsWith("refs/heads/", StringComparison.Ordinal) ||
183-
name.StartsWith("refs/remotes/", StringComparison.Ordinal))
183+
name.StartsWith("refs/remotes/", StringComparison.Ordinal) ||
184+
(name.StartsWith("worktrees/", StringComparison.Ordinal) && name.EndsWith("/HEAD", StringComparison.Ordinal)))
184185
{
185186
_updateBranch = DateTime.Now.AddSeconds(.5).ToFileTime();
186187
}

src/Native/MacOS.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public void SetupApp(AppBuilder builder)
2222

2323
builder.With(new MacOSPlatformOptions()
2424
{
25-
DisableNativeMenus = true,
2625
DisableDefaultApplicationMenuItems = true,
2726
});
2827
}

src/Resources/Locales/en_US.axaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
22
<x:String x:Key="Text.About" xml:space="preserve">About</x:String>
3+
<x:String x:Key="Text.About.Menu" xml:space="preserve">About SourceGit</x:String>
34
<x:String x:Key="Text.About.BuildWith" xml:space="preserve">• Build with </x:String>
4-
<x:String x:Key="Text.About.Copyright" xml:space="preserve">Copyright © 2024 sourcegit-scm.</x:String>
5+
<x:String x:Key="Text.About.Copyright" xml:space="preserve">© 2024 sourcegit-scm</x:String>
56
<x:String x:Key="Text.About.Editor" xml:space="preserve">• TextEditor from </x:String>
67
<x:String x:Key="Text.About.Fonts" xml:space="preserve">• Monospace fonts come from </x:String>
78
<x:String x:Key="Text.About.SourceCode" xml:space="preserve">• Source code can be found at </x:String>
@@ -210,12 +211,14 @@
210211
<x:String x:Key="Text.Histories.SearchClear" xml:space="preserve">CLEAR</x:String>
211212
<x:String x:Key="Text.Histories.Selected" xml:space="preserve">SELECTED {0} COMMITS</x:String>
212213
<x:String x:Key="Text.Hotkeys" xml:space="preserve">HotKeys</x:String>
214+
<x:String x:Key="Text.Hotkeys.Menu" xml:space="preserve">About HotKeys</x:String>
213215
<x:String x:Key="Text.Hotkeys.Global" xml:space="preserve">GLOBAL</x:String>
214216
<x:String x:Key="Text.Hotkeys.Global.CancelPopup" xml:space="preserve">Cancel current popup</x:String>
215217
<x:String x:Key="Text.Hotkeys.Global.CloseTab" xml:space="preserve">Close current page</x:String>
216218
<x:String x:Key="Text.Hotkeys.Global.GotoPrevTab" xml:space="preserve">Go to previous page</x:String>
217219
<x:String x:Key="Text.Hotkeys.Global.GotoNextTab" xml:space="preserve">Go to next page</x:String>
218220
<x:String x:Key="Text.Hotkeys.Global.NewTab" xml:space="preserve">Create new page</x:String>
221+
<x:String x:Key="Text.Hotkeys.Global.OpenPreference" xml:space="preserve">Open preference dialog</x:String>
219222
<x:String x:Key="Text.Hotkeys.Repo" xml:space="preserve">REPOSITORY</x:String>
220223
<x:String x:Key="Text.Hotkeys.Repo.Refresh" xml:space="preserve">Force to reload this repository</x:String>
221224
<x:String x:Key="Text.Hotkeys.Repo.StageOrUnstageSelected" xml:space="preserve">Stage/Unstage selected changes</x:String>
@@ -272,6 +275,8 @@
272275
<x:String x:Key="Text.Preference.General.UseFixedTabWidth" xml:space="preserve">Use fixed tab width in titlebar</x:String>
273276
<x:String x:Key="Text.Preference.Git" xml:space="preserve">GIT</x:String>
274277
<x:String x:Key="Text.Preference.Git.AutoFetch" xml:space="preserve">Fetch remotes automatically</x:String>
278+
<x:String x:Key="Text.Preference.Git.AutoFetchInterval" xml:space="preserve">Auto Fetch Interval</x:String>
279+
<x:String x:Key="Text.Preference.Git.AutoFetchIntervalSuffix" xml:space="preserve">Minute(s)</x:String>
275280
<x:String x:Key="Text.Preference.Git.CRLF" xml:space="preserve">Enable Auto CRLF</x:String>
276281
<x:String x:Key="Text.Preference.Git.DefaultCloneDir" xml:space="preserve">Default Clone Dir</x:String>
277282
<x:String x:Key="Text.Preference.Git.Email" xml:space="preserve">User Email</x:String>
@@ -310,6 +315,7 @@
310315
<x:String x:Key="Text.PushTag" xml:space="preserve">Push Tag To Remote</x:String>
311316
<x:String x:Key="Text.PushTag.Remote" xml:space="preserve">Remote :</x:String>
312317
<x:String x:Key="Text.PushTag.Tag" xml:space="preserve">Tag :</x:String>
318+
<x:String x:Key="Text.Quit" xml:space="preserve">Quit</x:String>
313319
<x:String x:Key="Text.Rebase" xml:space="preserve">Rebase Current Branch</x:String>
314320
<x:String x:Key="Text.Rebase.AutoStash" xml:space="preserve">Stash &amp; reapply local changes</x:String>
315321
<x:String x:Key="Text.Rebase.On" xml:space="preserve">On :</x:String>

0 commit comments

Comments
 (0)