Skip to content

Commit d60a33a

Browse files
committed
Merge branch 'release/v8.10'
2 parents 7e4e339 + 4c7ddf1 commit d60a33a

Some content is hidden

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

45 files changed

+480
-280
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,20 @@ Opensource Git GUI client.
2828

2929
> **Linux** only tested on **Ubuntu 22.04** on **X11**.
3030
31-
## How to use
31+
## How to Use
3232

3333
**To use this tool, you need to install Git(>=2.23.0) first.**
3434

3535
You can download the latest stable from [Releases](https://github.com/sourcegit-scm/sourcegit/releases/latest) or download workflow artifacts from [Github Actions](https://github.com/sourcegit-scm/sourcegit/actions) to try this app based on latest commits.
3636

37+
This software creates a folder `$"{System.Environment.SpecialFolder.ApplicationData}/SourceGit"`, which is platform-dependent, to store user settings, downloaded avatars and crash logs.
38+
39+
| OS | PATH |
40+
| --- | --- |
41+
| Windows | `C:\Users\USER_NAME\AppData\Roaming\SourceGit` |
42+
| Linux | `/home/USER_NAME/.config/SourceGit` |
43+
| macOS | `/Users/USER_NAME/.config/SourceGit` |
44+
3745
For **Windows** users:
3846

3947
* **MSYS Git is NOT supported**. Please use official [Git for Windows](https://git-scm.com/download/win) instead.
@@ -64,7 +72,8 @@ This app supports open repository in external tools listed in the table below.
6472
| JetBrains Fleet | YES | YES | YES | FLEET_PATH |
6573
| Sublime Text | YES | YES | YES | SUBLIME_TEXT_PATH |
6674

67-
You can set the given environment variable for special tool if it can NOT be found by this app automatically.
75+
> * You can set the given environment variable for special tool if it can NOT be found by this app automatically.
76+
> * Installing `JetBrains Toolbox` will help this app to find other JetBrains tools installed on your device.
6877
6978
## Screenshots
7079

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.9
1+
8.10

src/App.JsonCodeGen.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace SourceGit
44
{
55
[JsonSourceGenerationOptions(WriteIndented = true, IgnoreReadOnlyFields = true, IgnoreReadOnlyProperties = true)]
66
[JsonSerializable(typeof(Models.Version))]
7+
[JsonSerializable(typeof(Models.JetBrainsState))]
78
[JsonSerializable(typeof(ViewModels.Preference))]
89
internal partial class JsonCodeGen : JsonSerializerContext { }
910
}

src/App.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public static void Check4Update(bool manually = false)
164164
try
165165
{
166166
// Fetch lastest release information.
167-
var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(2) };
167+
var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(5) };
168168
var data = await client.GetStringAsync("https://sourcegit-scm.github.io/data/version.json");
169169

170170
// Parse json into Models.Version.

src/Commands/IsConflictResolved.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace SourceGit.Commands
2+
{
3+
public class IsConflictResolved : Command
4+
{
5+
public IsConflictResolved(string repo, Models.Change change)
6+
{
7+
var opt = new Models.DiffOption(change, true);
8+
9+
WorkingDirectory = repo;
10+
Context = repo;
11+
Args = $"diff -a --ignore-cr-at-eol --check {opt}";
12+
}
13+
14+
public bool Result()
15+
{
16+
var rs = ReadToEnd();
17+
return rs.IsSuccess;
18+
}
19+
}
20+
}

src/Models/DiffResult.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,11 @@ public void GeneratePatchFromSelectionSingleSide(Change change, string fileTreeG
388388
}
389389

390390
[GeneratedRegex(@"^@@ \-(\d+),?\d* \+(\d+),?\d* @@")]
391-
private static partial Regex indicatorRegex();
391+
private static partial Regex REG_INDICATOR();
392392

393393
private bool ProcessIndicatorForPatch(StringBuilder builder, TextDiffLine indicator, int idx, int start, int end, int ignoreRemoves, int ignoreAdds, bool revert, bool tailed)
394394
{
395-
var match = indicatorRegex().Match(indicator.Content);
395+
var match = REG_INDICATOR().Match(indicator.Content);
396396
var oldStart = int.Parse(match.Groups[1].Value);
397397
var newStart = int.Parse(match.Groups[2].Value) + ignoreRemoves - ignoreAdds;
398398
var oldCount = 0;
@@ -461,7 +461,7 @@ private bool ProcessIndicatorForPatch(StringBuilder builder, TextDiffLine indica
461461

462462
private bool ProcessIndicatorForPatchSingleSide(StringBuilder builder, TextDiffLine indicator, int idx, int start, int end, int ignoreRemoves, int ignoreAdds, bool revert, bool isOldSide, bool tailed)
463463
{
464-
var match = indicatorRegex().Match(indicator.Content);
464+
var match = REG_INDICATOR().Match(indicator.Content);
465465
var oldStart = int.Parse(match.Groups[1].Value);
466466
var newStart = int.Parse(match.Groups[2].Value) + ignoreRemoves - ignoreAdds;
467467
var oldCount = 0;

src/Models/ExternalTool.cs

Lines changed: 94 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.IO;
5+
using System.Text.Json;
6+
using System.Text.Json.Serialization;
57

68
using Avalonia.Media.Imaging;
79
using Avalonia.Platform;
@@ -19,8 +21,24 @@ public Bitmap IconImage
1921
{
2022
get
2123
{
22-
var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalToolIcons/{Icon}.png", UriKind.RelativeOrAbsolute));
23-
return new Bitmap(icon);
24+
if (_isFirstTimeGetIcon)
25+
{
26+
_isFirstTimeGetIcon = false;
27+
28+
if (!string.IsNullOrWhiteSpace(Icon))
29+
{
30+
try
31+
{
32+
var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalToolIcons/{Icon}.png", UriKind.RelativeOrAbsolute));
33+
_iconImage = new Bitmap(icon);
34+
}
35+
catch
36+
{
37+
}
38+
}
39+
}
40+
41+
return _iconImage;
2442
}
2543
}
2644

@@ -34,6 +52,41 @@ public void Open(string repo)
3452
UseShellExecute = false,
3553
});
3654
}
55+
56+
private bool _isFirstTimeGetIcon = true;
57+
private Bitmap _iconImage = null;
58+
}
59+
60+
public class JetBrainsState
61+
{
62+
[JsonPropertyName("version")]
63+
public int Version { get; set; } = 0;
64+
[JsonPropertyName("appVersion")]
65+
public string AppVersion { get; set; } = string.Empty;
66+
[JsonPropertyName("tools")]
67+
public List<JetBrainsTool> Tools { get; set; } = new List<JetBrainsTool>();
68+
}
69+
70+
public class JetBrainsTool
71+
{
72+
[JsonPropertyName("channelId")]
73+
public string ChannelId { get; set; }
74+
[JsonPropertyName("toolId")]
75+
public string ToolId { get; set; }
76+
[JsonPropertyName("productCode")]
77+
public string ProductCode { get; set; }
78+
[JsonPropertyName("tag")]
79+
public string Tag { get; set; }
80+
[JsonPropertyName("displayName")]
81+
public string DisplayName { get; set; }
82+
[JsonPropertyName("displayVersion")]
83+
public string DisplayVersion { get; set; }
84+
[JsonPropertyName("buildNumber")]
85+
public string BuildNumber { get; set; }
86+
[JsonPropertyName("installLocation")]
87+
public string InstallLocation { get; set; }
88+
[JsonPropertyName("launchCommand")]
89+
public string LaunchCommand { get; set; }
3790
}
3891

3992
public class ExternalToolsFinder
@@ -44,6 +97,25 @@ public List<ExternalTool> Founded
4497
private set;
4598
} = new List<ExternalTool>();
4699

100+
public void TryAdd(string name, string icon, string args, string env, Func<string> finder)
101+
{
102+
var path = Environment.GetEnvironmentVariable(env);
103+
if (string.IsNullOrEmpty(path) || !File.Exists(path))
104+
{
105+
path = finder();
106+
if (string.IsNullOrEmpty(path) || !File.Exists(path))
107+
return;
108+
}
109+
110+
Founded.Add(new ExternalTool
111+
{
112+
Name = name,
113+
Icon = icon,
114+
OpenCmdArgs = args,
115+
Executable = path
116+
});
117+
}
118+
47119
public void VSCode(Func<string> platform_finder)
48120
{
49121
TryAdd("Visual Studio Code", "vscode", "\"{0}\"", "VSCODE_PATH", platform_finder);
@@ -56,31 +128,36 @@ public void VSCodeInsiders(Func<string> platform_finder)
56128

57129
public void Fleet(Func<string> platform_finder)
58130
{
59-
TryAdd("JetBrains Fleet", "fleet", "\"{0}\"", "FLEET_PATH", platform_finder);
131+
TryAdd("Fleet", "fleet", "\"{0}\"", "FLEET_PATH", platform_finder);
60132
}
61133

62134
public void SublimeText(Func<string> platform_finder)
63135
{
64136
TryAdd("Sublime Text", "sublime_text", "\"{0}\"", "SUBLIME_TEXT_PATH", platform_finder);
65137
}
66138

67-
public void TryAdd(string name, string icon, string args, string env, Func<string> finder)
139+
public void FindJetBrainsFromToolbox(Func<string> platform_finder)
68140
{
69-
var path = Environment.GetEnvironmentVariable(env);
70-
if (string.IsNullOrEmpty(path) || !File.Exists(path))
141+
var exclude = new List<string> { "fleet", "dotmemory", "dottrace", "resharper-u", "androidstudio" };
142+
var supported_icons = new List<string> { "CL", "DB", "DL", "DS", "GO", "IC", "IU", "JB", "PC", "PS", "PY", "QA", "QD", "RD", "RM", "RR", "WRS", "WS" };
143+
var state = Path.Combine(platform_finder(), "state.json");
144+
if (File.Exists(state))
71145
{
72-
path = finder();
73-
if (string.IsNullOrEmpty(path) || !File.Exists(path))
74-
return;
75-
}
146+
var stateData = JsonSerializer.Deserialize(File.ReadAllText(state), JsonCodeGen.Default.JetBrainsState);
147+
foreach (var tool in stateData.Tools)
148+
{
149+
if (exclude.Contains(tool.ToolId.ToLowerInvariant()))
150+
continue;
76151

77-
Founded.Add(new ExternalTool
78-
{
79-
Name = name,
80-
Icon = icon,
81-
OpenCmdArgs = args,
82-
Executable = path,
83-
});
152+
Founded.Add(new ExternalTool
153+
{
154+
Name = $"{tool.DisplayName} {tool.DisplayVersion}",
155+
Icon = supported_icons.Contains(tool.ProductCode) ? $"JetBrains/{tool.ProductCode}" : $"JetBrains/JB",
156+
OpenCmdArgs = "\"{0}\"",
157+
Executable = Path.Combine(tool.InstallLocation, tool.LaunchCommand),
158+
});
159+
}
160+
}
84161
}
85162
}
86163
}

src/Native/Linux.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public string FindGitExecutable()
5757
var finder = new Models.ExternalToolsFinder();
5858
finder.VSCode(() => FindExecutable("code"));
5959
finder.VSCodeInsiders(() => FindExecutable("code-insiders"));
60-
finder.Fleet(FindJetBrainFleet);
60+
finder.Fleet(FindJetBrainsFleet);
61+
finder.FindJetBrainsFromToolbox(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/JetBrains/Toolbox");
6162
finder.SublimeText(() => FindExecutable("subl"));
6263
return finder.Founded;
6364
}
@@ -174,7 +175,7 @@ private Terminal FindTerminal()
174175
return null;
175176
}
176177

177-
private string FindJetBrainFleet()
178+
private string FindJetBrainsFleet()
178179
{
179180
var path = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/JetBrains/Toolbox/apps/fleet/bin/Fleet";
180181
return File.Exists(path) ? path : FindExecutable("fleet");

src/Native/MacOS.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public string FindGitExecutable()
3333
finder.VSCode(() => "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code");
3434
finder.VSCodeInsiders(() => "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code");
3535
finder.Fleet(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Applications/Fleet.app/Contents/MacOS/Fleet");
36+
finder.FindJetBrainsFromToolbox(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Library/Application Support/JetBrains/Toolbox");
3637
finder.SublimeText(() => "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl");
3738
return finder.Founded;
3839
}

src/Native/Windows.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public string FindGitExecutable()
111111
finder.VSCode(FindVSCode);
112112
finder.VSCodeInsiders(FindVSCodeInsiders);
113113
finder.Fleet(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\Programs\\Fleet\\Fleet.exe");
114+
finder.FindJetBrainsFromToolbox(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\JetBrains\\Toolbox");
114115
finder.SublimeText(FindSublimeText);
115116
return finder.Founded;
116117
}

0 commit comments

Comments
 (0)