diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 47ae6251..c8e1ea8e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2,9 +2,9 @@ name: Continuous Integration
on:
push:
branches:
- - master
+ - develop
pull_request:
- branches: [master]
+ branches: [develop]
workflow_dispatch:
jobs:
build:
diff --git a/README.md b/README.md
index 351fecb0..e84afc3b 100644
--- a/README.md
+++ b/README.md
@@ -37,6 +37,7 @@ You can download the latest stable from [Releases](https://github.com/sourcegit-
For **Windows** users:
* **MSYS Git is NOT supported**. Please use official [Git for Windows](https://git-scm.com/download/win) instead.
+* `Source.win-x64.zip` may be reported as virus by Windows Defender. I don't know why. I have manually tested the zip to be uploaded using Windows Defender before uploading and no virus was found. If you have installed .NET 8 SDK locally, I suggest you to compile it yourself. And if you have any idea about how to fix this, please open an issue.
For **macOS** users:
@@ -53,20 +54,20 @@ For **Linux** users:
* Maybe you need to set environment variable `AVALONIA_SCREEN_SCALE_FACTORS`. See https://github.com/AvaloniaUI/Avalonia/wiki/Configuring-X11-per-monitor-DPI.
* Modify `SourceGit.desktop.template` (replace SOURCEGIT_LOCAL_FOLDER with real path) and move it into `~/.local/share/applications`.
-## External Editors
+## External Tools
-This app supports open repository in external editors listed in the table below.
+This app supports open repository in external tools listed in the table below.
-| Editor | Windows | macOS | Linux | Environment Variable |
+| Tool | Windows | macOS | Linux | Environment Variable |
| --- | --- | --- | --- | --- |
| Visual Studio Code | YES | YES | YES | VSCODE_PATH |
| Visual Studio Code - Insiders | YES | YES | YES | VSCODE_INSIDERS_PATH |
| JetBrains Fleet | YES | YES | YES | FLEET_PATH |
| Sublime Text | YES | YES | YES | SUBLIME_TEXT_PATH |
-You can set the given environment variable for special editor if it can NOT be found by this app automatically.
+You can set the given environment variable for special tool if it can NOT be found by this app automatically.
-## Screen Shots
+## Screenshots
* Dark Theme
diff --git a/build/resources/App.plist b/build/resources/App.plist
index da322389..3327c5d8 100644
--- a/build/resources/App.plist
+++ b/build/resources/App.plist
@@ -9,7 +9,7 @@
CFBundleName
SourceGit
CFBundleVersion
- 8.7.0
+ 8.8.0
LSMinimumSystemVersion
10.12
CFBundleExecutable
@@ -19,8 +19,8 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 8.7
+ 8.8
NSHighResolutionCapable
-
\ No newline at end of file
+
diff --git a/src/Commands/Checkout.cs b/src/Commands/Checkout.cs
index dd1426fb..d65e9e73 100644
--- a/src/Commands/Checkout.cs
+++ b/src/Commands/Checkout.cs
@@ -28,17 +28,31 @@ namespace SourceGit.Commands
return Exec();
}
- public bool File(string file, bool useTheirs)
+ public bool UseTheirs(List files)
{
- if (useTheirs)
+ StringBuilder builder = new StringBuilder();
+ builder.Append("checkout --theirs --");
+ foreach (var f in files)
{
- Args = $"checkout --theirs -- \"{file}\"";
- }
- else
- {
- Args = $"checkout --ours -- \"{file}\"";
+ builder.Append(" \"");
+ builder.Append(f);
+ builder.Append("\"");
}
+ Args = builder.ToString();
+ return Exec();
+ }
+ public bool UseMine(List files)
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.Append("checkout --ours --");
+ foreach (var f in files)
+ {
+ builder.Append(" \"");
+ builder.Append(f);
+ builder.Append("\"");
+ }
+ Args = builder.ToString();
return Exec();
}
diff --git a/src/Commands/Diff.cs b/src/Commands/Diff.cs
index 090eba98..e92b2234 100644
--- a/src/Commands/Diff.cs
+++ b/src/Commands/Diff.cs
@@ -46,6 +46,18 @@ namespace SourceGit.Commands
protected override void OnReadline(string line)
{
+ if (line.StartsWith("old mode ", StringComparison.Ordinal))
+ {
+ _result.OldMode = line.Substring(9);
+ return;
+ }
+
+ if (line.StartsWith("new mode ", StringComparison.Ordinal))
+ {
+ _result.NewMode = line.Substring(9);
+ return;
+ }
+
if (_result.IsBinary)
return;
diff --git a/src/Commands/Fetch.cs b/src/Commands/Fetch.cs
index f195c011..8f84c346 100644
--- a/src/Commands/Fetch.cs
+++ b/src/Commands/Fetch.cs
@@ -24,7 +24,7 @@ namespace SourceGit.Commands
Args = "-c credential.helper=manager ";
}
- Args += "fetch --progress --verbose ";
+ Args += "fetch --force --progress --verbose ";
if (prune)
Args += "--prune ";
Args += remote;
diff --git a/src/Commands/QueryCommitChanges.cs b/src/Commands/QueryCommitChanges.cs
deleted file mode 100644
index e7481b89..00000000
--- a/src/Commands/QueryCommitChanges.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using System.Collections.Generic;
-using System.Text.RegularExpressions;
-
-namespace SourceGit.Commands
-{
- public partial class QueryCommitChanges : Command
- {
- [GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")]
- private static partial Regex REG_FORMAT();
-
- public QueryCommitChanges(string repo, string commitSHA)
- {
- WorkingDirectory = repo;
- Context = repo;
- Args = $"show --name-status {commitSHA}";
- }
-
- public List Result()
- {
- Exec();
- _changes.Sort((l, r) => l.Path.CompareTo(r.Path));
- return _changes;
- }
-
- protected override void OnReadline(string line)
- {
- var match = REG_FORMAT().Match(line);
- if (!match.Success)
- return;
-
- var change = new Models.Change() { Path = match.Groups[2].Value };
- var status = match.Groups[1].Value;
-
- switch (status[0])
- {
- case 'M':
- change.Set(Models.ChangeState.Modified);
- _changes.Add(change);
- break;
- case 'A':
- change.Set(Models.ChangeState.Added);
- _changes.Add(change);
- break;
- case 'D':
- change.Set(Models.ChangeState.Deleted);
- _changes.Add(change);
- break;
- case 'R':
- change.Set(Models.ChangeState.Renamed);
- _changes.Add(change);
- break;
- case 'C':
- change.Set(Models.ChangeState.Copied);
- _changes.Add(change);
- break;
- }
- }
-
- private readonly List _changes = new List();
- }
-}
diff --git a/src/Converters/ListConverters.cs b/src/Converters/ListConverters.cs
index 2adb37e1..dac55076 100644
--- a/src/Converters/ListConverters.cs
+++ b/src/Converters/ListConverters.cs
@@ -7,7 +7,7 @@ namespace SourceGit.Converters
public static class ListConverters
{
public static readonly FuncValueConverter ToCount =
- new FuncValueConverter(v => $" ({v.Count})");
+ new FuncValueConverter(v => v == null ? " (0)" : $" ({v.Count})");
public static readonly FuncValueConverter IsNotNullOrEmpty =
new FuncValueConverter(v => v != null && v.Count > 0);
diff --git a/src/Converters/PathConverters.cs b/src/Converters/PathConverters.cs
index fcd9f174..6f10b66d 100644
--- a/src/Converters/PathConverters.cs
+++ b/src/Converters/PathConverters.cs
@@ -11,13 +11,5 @@ namespace SourceGit.Converters
public static readonly FuncValueConverter PureDirectoryName =
new FuncValueConverter(fullpath => Path.GetDirectoryName(fullpath) ?? "");
-
- public static readonly FuncValueConverter TruncateIfTooLong =
- new FuncValueConverter(fullpath =>
- {
- if (fullpath.Length <= 50)
- return fullpath;
- return fullpath.Substring(0, 20) + ".../" + Path.GetFileName(fullpath);
- });
}
}
diff --git a/src/Models/DiffResult.cs b/src/Models/DiffResult.cs
index 8cceced8..70219dcf 100644
--- a/src/Models/DiffResult.cs
+++ b/src/Models/DiffResult.cs
@@ -576,11 +576,21 @@ namespace SourceGit.Models
{
}
+ public class FileModeDiff
+ {
+ public string Old { get; set; } = string.Empty;
+ public string New { get; set; } = string.Empty;
+ }
+
public class DiffResult
{
public bool IsBinary { get; set; } = false;
public bool IsLFS { get; set; } = false;
+ public string OldMode { get; set; } = string.Empty;
+ public string NewMode { get; set; } = string.Empty;
public TextDiff TextDiff { get; set; } = null;
public LFSDiff LFSDiff { get; set; } = null;
+
+ public string FileModeChange => string.IsNullOrEmpty(OldMode) ? string.Empty : $"{OldMode} → {NewMode}";
}
}
diff --git a/src/Models/ExternalMergeTools.cs b/src/Models/ExternalMergeTools.cs
deleted file mode 100644
index f07ef088..00000000
--- a/src/Models/ExternalMergeTools.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-
-namespace SourceGit.Models
-{
- public class ExternalMergeTools
- {
- public int Type { get; set; }
- public string Name { get; set; }
- public string Exec { get; set; }
- public string Cmd { get; set; }
- public string DiffCmd { get; set; }
-
- public static readonly List Supported;
-
- static ExternalMergeTools()
- {
- if (OperatingSystem.IsWindows())
- {
- Supported = new List() {
- new ExternalMergeTools(0, "Custom", "", "", ""),
- new ExternalMergeTools(1, "Visual Studio Code", "Code.exe", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(2, "Visual Studio Code - Insiders", "Code - Insiders.exe", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(3, "Visual Studio 2017/2019/2022", "vsDiffMerge.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" /m", "\"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(4, "Tortoise Merge", "TortoiseMerge.exe;TortoiseGitMerge.exe", "-base:\"$BASE\" -theirs:\"$REMOTE\" -mine:\"$LOCAL\" -merged:\"$MERGED\"", "-base:\"$LOCAL\" -theirs:\"$REMOTE\""),
- new ExternalMergeTools(5, "KDiff3", "kdiff3.exe", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(6, "Beyond Compare", "BComp.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(7, "WinMerge", "WinMergeU.exe", "-u -e \"$REMOTE\" \"$LOCAL\" \"$MERGED\"", "-u -e \"$LOCAL\" \"$REMOTE\""),
- };
- }
- else if (OperatingSystem.IsMacOS())
- {
- Supported = new List() {
- new ExternalMergeTools(0, "Custom", "", "", ""),
- new ExternalMergeTools(1, "FileMerge", "/usr/bin/opendiff", "\"$BASE\" \"$LOCAL\" \"$REMOTE\" -ancestor \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(2, "Visual Studio Code", "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(3, "Visual Studio Code - Insiders", "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(4, "KDiff3", "/Applications/kdiff3.app/Contents/MacOS/kdiff3", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(5, "Beyond Compare", "/Applications/Beyond Compare.app/Contents/MacOS/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
- };
- }
- else if (OperatingSystem.IsLinux())
- {
- Supported = new List() {
- new ExternalMergeTools(0, "Custom", "", "", ""),
- new ExternalMergeTools(1, "Visual Studio Code", "/usr/share/code/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(2, "Visual Studio Code - Insiders", "/usr/share/code-insiders/code-insiders", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(3, "KDiff3", "/usr/bin/kdiff3", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
- new ExternalMergeTools(4, "Beyond Compare", "/usr/bin/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
- };
- }
- else
- {
- Supported = new List() {
- new ExternalMergeTools(0, "Custom", "", "", ""),
- };
- }
- }
-
- public ExternalMergeTools(int type, string name, string exec, string cmd, string diffCmd)
- {
- Type = type;
- Name = name;
- Exec = exec;
- Cmd = cmd;
- DiffCmd = diffCmd;
- }
-
- public string[] GetPatterns()
- {
- if (OperatingSystem.IsWindows())
- {
- return Exec.Split(';');
- }
- else
- {
- var patterns = new List();
- var choices = Exec.Split(';', StringSplitOptions.RemoveEmptyEntries);
- foreach (var c in choices)
- {
- patterns.Add(Path.GetFileName(c));
- }
- return patterns.ToArray();
- }
- }
- }
-}
diff --git a/src/Models/ExternalMerger.cs b/src/Models/ExternalMerger.cs
new file mode 100644
index 00000000..773a7f94
--- /dev/null
+++ b/src/Models/ExternalMerger.cs
@@ -0,0 +1,103 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+using Avalonia.Media.Imaging;
+using Avalonia.Platform;
+
+namespace SourceGit.Models
+{
+ public class ExternalMerger
+ {
+ public int Type { get; set; }
+ public string Icon { get; set; }
+ public string Name { get; set; }
+ public string Exec { get; set; }
+ public string Cmd { get; set; }
+ public string DiffCmd { get; set; }
+
+ public Bitmap IconImage
+ {
+ get
+ {
+ var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalToolIcons/{Icon}.png", UriKind.RelativeOrAbsolute));
+ return new Bitmap(icon);
+ }
+ }
+
+ public static readonly List Supported;
+
+ static ExternalMerger()
+ {
+ if (OperatingSystem.IsWindows())
+ {
+ Supported = new List() {
+ new ExternalMerger(0, "custom_diff", "Custom", "", "", ""),
+ new ExternalMerger(1, "vscode", "Visual Studio Code", "Code.exe", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(2, "vscode_insiders", "Visual Studio Code - Insiders", "Code - Insiders.exe", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(3, "vs", "Visual Studio", "vsDiffMerge.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" /m", "\"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(4, "tortoise_merge", "Tortoise Merge", "TortoiseMerge.exe;TortoiseGitMerge.exe", "-base:\"$BASE\" -theirs:\"$REMOTE\" -mine:\"$LOCAL\" -merged:\"$MERGED\"", "-base:\"$LOCAL\" -theirs:\"$REMOTE\""),
+ new ExternalMerger(5, "kdiff3", "KDiff3", "kdiff3.exe", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(6, "beyond_compare", "Beyond Compare", "BComp.exe", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(7, "win_merge", "WinMerge", "WinMergeU.exe", "-u -e \"$REMOTE\" \"$LOCAL\" \"$MERGED\"", "-u -e \"$LOCAL\" \"$REMOTE\""),
+ };
+ }
+ else if (OperatingSystem.IsMacOS())
+ {
+ Supported = new List() {
+ new ExternalMerger(0, "custom_diff", "Custom", "", "", ""),
+ new ExternalMerger(1, "xcode", "FileMerge", "/usr/bin/opendiff", "\"$BASE\" \"$LOCAL\" \"$REMOTE\" -ancestor \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(2, "vscode", "Visual Studio Code", "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(3, "vscode_insiders", "Visual Studio Code - Insiders", "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(4, "kdiff3", "KDiff3", "/Applications/kdiff3.app/Contents/MacOS/kdiff3", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(5, "beyond_compare", "Beyond Compare", "/Applications/Beyond Compare.app/Contents/MacOS/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
+ };
+ }
+ else if (OperatingSystem.IsLinux())
+ {
+ Supported = new List() {
+ new ExternalMerger(0, "custom_diff", "Custom", "", "", ""),
+ new ExternalMerger(1, "vscode", "Visual Studio Code", "/usr/share/code/code", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(2, "vscode_insiders", "Visual Studio Code - Insiders", "/usr/share/code-insiders/code-insiders", "-n --wait \"$MERGED\"", "-n --wait --diff \"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(3, "kdiff3", "KDiff3", "/usr/bin/kdiff3", "\"$REMOTE\" -b \"$BASE\" \"$LOCAL\" -o \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(4, "beyond_compare", "Beyond Compare", "/usr/bin/bcomp", "\"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
+ new ExternalMerger(5, "meld", "Meld", "/usr/bin/meld", "\"$LOCAL\" \"$BASE\" \"$REMOTE\" -output \"$MERGED\"", "\"$LOCAL\" \"$REMOTE\""),
+ };
+ }
+ else
+ {
+ Supported = new List() {
+ new ExternalMerger(0, "custom_diff", "Custom", "", "", ""),
+ };
+ }
+ }
+
+ public ExternalMerger(int type, string icon, string name, string exec, string cmd, string diffCmd)
+ {
+ Type = type;
+ Icon = icon;
+ Name = name;
+ Exec = exec;
+ Cmd = cmd;
+ DiffCmd = diffCmd;
+ }
+
+ public string[] GetPatterns()
+ {
+ if (OperatingSystem.IsWindows())
+ {
+ return Exec.Split(';');
+ }
+ else
+ {
+ var patterns = new List();
+ var choices = Exec.Split(';', StringSplitOptions.RemoveEmptyEntries);
+ foreach (var c in choices)
+ {
+ patterns.Add(Path.GetFileName(c));
+ }
+ return patterns.ToArray();
+ }
+ }
+ }
+}
diff --git a/src/Models/ExternalEditor.cs b/src/Models/ExternalTool.cs
similarity index 62%
rename from src/Models/ExternalEditor.cs
rename to src/Models/ExternalTool.cs
index 094d0a5f..cb50df58 100644
--- a/src/Models/ExternalEditor.cs
+++ b/src/Models/ExternalTool.cs
@@ -3,15 +3,27 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
+using Avalonia.Media.Imaging;
+using Avalonia.Platform;
+
namespace SourceGit.Models
{
- public class ExternalEditor
+ public class ExternalTool
{
public string Name { get; set; } = string.Empty;
public string Icon { get; set; } = string.Empty;
public string Executable { get; set; } = string.Empty;
public string OpenCmdArgs { get; set; } = string.Empty;
+ public Bitmap IconImage
+ {
+ get
+ {
+ var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalToolIcons/{Icon}.png", UriKind.RelativeOrAbsolute));
+ return new Bitmap(icon);
+ }
+ }
+
public void Open(string repo)
{
Process.Start(new ProcessStartInfo()
@@ -24,35 +36,35 @@ namespace SourceGit.Models
}
}
- public class ExternalEditorFinder
+ public class ExternalToolsFinder
{
- public List Editors
+ public List Founded
{
get;
private set;
- } = new List();
+ } = new List();
public void VSCode(Func platform_finder)
{
- TryAdd("Visual Studio Code", "vscode.png", "\"{0}\"", "VSCODE_PATH", platform_finder);
+ TryAdd("Visual Studio Code", "vscode", "\"{0}\"", "VSCODE_PATH", platform_finder);
}
public void VSCodeInsiders(Func platform_finder)
{
- TryAdd("Visual Studio Code - Insiders", "vscode_insiders.png", "\"{0}\"", "VSCODE_INSIDERS_PATH", platform_finder);
+ TryAdd("Visual Studio Code - Insiders", "vscode_insiders", "\"{0}\"", "VSCODE_INSIDERS_PATH", platform_finder);
}
public void Fleet(Func platform_finder)
{
- TryAdd("JetBrains Fleet", "fleet.png", "\"{0}\"", "FLEET_PATH", platform_finder);
+ TryAdd("JetBrains Fleet", "fleet", "\"{0}\"", "FLEET_PATH", platform_finder);
}
public void SublimeText(Func platform_finder)
{
- TryAdd("Sublime Text", "sublime_text.png", "\"{0}\"", "SUBLIME_TEXT_PATH", platform_finder);
+ TryAdd("Sublime Text", "sublime_text", "\"{0}\"", "SUBLIME_TEXT_PATH", platform_finder);
}
- private void TryAdd(string name, string icon, string args, string env, Func finder)
+ public void TryAdd(string name, string icon, string args, string env, Func finder)
{
var path = Environment.GetEnvironmentVariable(env);
if (string.IsNullOrEmpty(path) || !File.Exists(path))
@@ -62,7 +74,7 @@ namespace SourceGit.Models
return;
}
- Editors.Add(new ExternalEditor
+ Founded.Add(new ExternalTool
{
Name = name,
Icon = icon,
diff --git a/src/Models/Shell.cs b/src/Models/Shell.cs
new file mode 100644
index 00000000..9960d136
--- /dev/null
+++ b/src/Models/Shell.cs
@@ -0,0 +1,10 @@
+namespace SourceGit.Models
+{
+ public enum Shell
+ {
+ Default = 0,
+ PowerShell,
+ CommandPrompt,
+ DefaultShellOfWindowsTerminal,
+ }
+}
diff --git a/src/Native/Linux.cs b/src/Native/Linux.cs
index 56d42306..172d598b 100644
--- a/src/Native/Linux.cs
+++ b/src/Native/Linux.cs
@@ -13,6 +13,29 @@ namespace SourceGit.Native
[SupportedOSPlatform("linux")]
internal class Linux : OS.IBackend
{
+ class Terminal
+ {
+ public string FilePath { get; set; } = string.Empty;
+ public string OpenArgFormat { get; set; } = string.Empty;
+
+ public Terminal(string exec, string fmt)
+ {
+ FilePath = exec;
+ OpenArgFormat = fmt;
+ }
+
+ public void Open(string dir)
+ {
+ Process.Start(FilePath, string.Format(OpenArgFormat, dir));
+ }
+ }
+
+ public Linux()
+ {
+ _xdgOpenPath = FindExecutable("xdg-open");
+ _terminal = FindTerminal();
+ }
+
public void SetupApp(AppBuilder builder)
{
builder.With(new FontManagerOptions()
@@ -26,50 +49,45 @@ namespace SourceGit.Native
public string FindGitExecutable()
{
- if (File.Exists("/usr/bin/git"))
- return "/usr/bin/git";
- return string.Empty;
+ return FindExecutable("git");
}
- public List FindExternalEditors()
+ public List FindExternalTools()
{
- var finder = new Models.ExternalEditorFinder();
- finder.VSCode(() => "/usr/share/code/code");
- finder.VSCodeInsiders(() => "/usr/share/code-insiders/code-insiders");
- finder.Fleet(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/JetBrains/Toolbox/apps/fleet/bin/Fleet");
- finder.SublimeText(() => File.Exists("/usr/bin/subl") ? "/usr/bin/subl" : "/usr/local/bin/subl");
- return finder.Editors;
+ var finder = new Models.ExternalToolsFinder();
+ finder.VSCode(() => FindExecutable("code"));
+ finder.VSCodeInsiders(() => FindExecutable("code-insiders"));
+ finder.Fleet(FindJetBrainFleet);
+ finder.SublimeText(() => FindExecutable("subl"));
+ return finder.Founded;
}
public void OpenBrowser(string url)
{
- if (!File.Exists("/usr/bin/xdg-open"))
- {
- App.RaiseException("", $"You should install xdg-open first!");
- return;
- }
-
- Process.Start("xdg-open", $"\"{url}\"");
+ if (string.IsNullOrEmpty(_xdgOpenPath))
+ App.RaiseException("", $"Can NOT find `xdg-open` command!!!");
+ else
+ Process.Start(_xdgOpenPath, $"\"{url}\"");
}
public void OpenInFileManager(string path, bool select)
{
- if (!File.Exists("/usr/bin/xdg-open"))
+ if (string.IsNullOrEmpty(_xdgOpenPath))
{
- App.RaiseException("", $"You should install xdg-open first!");
+ App.RaiseException("", $"Can NOT find `xdg-open` command!!!");
return;
}
if (Directory.Exists(path))
{
- Process.Start("xdg-open", $"\"{path}\"");
+ Process.Start(_xdgOpenPath, $"\"{path}\"");
}
else
{
var dir = Path.GetDirectoryName(path);
if (Directory.Exists(dir))
{
- Process.Start("xdg-open", $"\"{dir}\"");
+ Process.Start(_xdgOpenPath, $"\"{dir}\"");
}
}
}
@@ -77,42 +95,86 @@ namespace SourceGit.Native
public void OpenTerminal(string workdir)
{
var dir = string.IsNullOrEmpty(workdir) ? "~" : workdir;
- if (File.Exists("/usr/bin/gnome-terminal"))
- {
- Process.Start("/usr/bin/gnome-terminal", $"--working-directory=\"{dir}\"");
- }
- else if (File.Exists("/usr/bin/konsole"))
- {
- Process.Start("/usr/bin/konsole", $"--workdir \"{dir}\"");
- }
- else if (File.Exists("/usr/bin/xfce4-terminal"))
- {
- Process.Start("/usr/bin/xfce4-terminal", $"--working-directory=\"{dir}\"");
- }
+ if (_terminal == null)
+ App.RaiseException(dir, $"Only supports gnome-terminal/konsole/xfce4-terminal/deepin-terminal!");
else
- {
- App.RaiseException("", $"Only supports gnome-terminal/konsole/xfce4-terminal!");
- return;
- }
+ _terminal.Open(dir);
}
public void OpenWithDefaultEditor(string file)
{
- if (!File.Exists("/usr/bin/xdg-open"))
+ if (string.IsNullOrEmpty(_xdgOpenPath))
{
- App.RaiseException("", $"You should install xdg-open first!");
+ App.RaiseException("", $"Can NOT find `xdg-open` command!!!");
return;
}
- var proc = Process.Start("xdg-open", $"\"{file}\"");
+ var proc = Process.Start(_xdgOpenPath, $"\"{file}\"");
proc.WaitForExit();
if (proc.ExitCode != 0)
- {
App.RaiseException("", $"Failed to open \"{file}\"");
- }
proc.Close();
}
+
+ private string FindExecutable(string filename)
+ {
+ var pathVariable = Environment.GetEnvironmentVariable("PATH") ?? string.Empty;
+ var pathes = pathVariable.Split(Path.PathSeparator, StringSplitOptions.RemoveEmptyEntries);
+ foreach (var path in pathes)
+ {
+ var test = Path.Combine(path, filename);
+ if (File.Exists(test))
+ {
+ return test;
+ }
+ }
+
+ return string.Empty;
+ }
+
+ private Terminal FindTerminal()
+ {
+ var pathVariable = Environment.GetEnvironmentVariable("PATH") ?? string.Empty;
+ var pathes = pathVariable.Split(Path.PathSeparator, StringSplitOptions.RemoveEmptyEntries);
+ foreach (var path in pathes)
+ {
+ var test = Path.Combine(path, "gnome-terminal");
+ if (File.Exists(test))
+ {
+ return new Terminal(test, "--working-directory=\"{0}\"");
+ }
+
+ test = Path.Combine(path, "konsole");
+ if (File.Exists(test))
+ {
+ return new Terminal(test, "--workdir \"{0}\"");
+ }
+
+ test = Path.Combine(path, "xfce4-terminal");
+ if (File.Exists(test))
+ {
+ return new Terminal(test, "--working-directory=\"{0}\"");
+ }
+
+ test = Path.Combine(path, "deepin-terminal");
+ if (File.Exists(test))
+ {
+ return new Terminal(test, "--work-directory \"{0}\"");
+ }
+ }
+
+ return null;
+ }
+
+ private string FindJetBrainFleet()
+ {
+ var path = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}/JetBrains/Toolbox/apps/fleet/bin/Fleet";
+ return File.Exists(path) ? path : FindExecutable("fleet");
+ }
+
+ private string _xdgOpenPath = string.Empty;
+ private Terminal _terminal = null;
}
}
diff --git a/src/Native/MacOS.cs b/src/Native/MacOS.cs
index ac864986..28519e40 100644
--- a/src/Native/MacOS.cs
+++ b/src/Native/MacOS.cs
@@ -28,14 +28,14 @@ namespace SourceGit.Native
return string.Empty;
}
- public List FindExternalEditors()
+ public List FindExternalTools()
{
- var finder = new Models.ExternalEditorFinder();
+ var finder = new Models.ExternalToolsFinder();
finder.VSCode(() => "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code");
finder.VSCodeInsiders(() => "/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/bin/code");
finder.Fleet(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}/Applications/Fleet.app/Contents/MacOS/Fleet");
finder.SublimeText(() => "/Applications/Sublime Text.app/Contents/SharedSupport/bin");
- return finder.Editors;
+ return finder.Founded;
}
public void OpenBrowser(string url)
diff --git a/src/Native/OS.cs b/src/Native/OS.cs
index 61a33ed6..259b6a22 100644
--- a/src/Native/OS.cs
+++ b/src/Native/OS.cs
@@ -12,7 +12,7 @@ namespace SourceGit.Native
void SetupApp(AppBuilder builder);
string FindGitExecutable();
- List FindExternalEditors();
+ List FindExternalTools();
void OpenTerminal(string workdir);
void OpenInFileManager(string path, bool select);
@@ -21,7 +21,7 @@ namespace SourceGit.Native
}
public static string GitExecutable { get; set; } = string.Empty;
- public static List ExternalEditors { get; set; } = new List();
+ public static List ExternalTools { get; set; } = new List();
static OS()
{
@@ -42,7 +42,34 @@ namespace SourceGit.Native
throw new Exception("Platform unsupported!!!");
}
- ExternalEditors = _backend.FindExternalEditors();
+ ExternalTools = _backend.FindExternalTools();
+ }
+
+ public static Models.Shell GetShell()
+ {
+ if (OperatingSystem.IsWindows())
+ {
+ return (_backend as Windows).Shell;
+ }
+ else
+ {
+ return Models.Shell.Default;
+ }
+ }
+
+ public static bool SetShell(Models.Shell shell)
+ {
+ if (OperatingSystem.IsWindows())
+ {
+ var windows = (_backend as Windows);
+ if (windows.Shell != shell)
+ {
+ windows.Shell = shell;
+ return true;
+ }
+ }
+
+ return false;
}
public static void SetupApp(AppBuilder builder)
diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs
index 78fef704..04fe5e8b 100644
--- a/src/Native/Windows.cs
+++ b/src/Native/Windows.cs
@@ -54,6 +54,12 @@ namespace SourceGit.Native
[DllImport("shell32.dll", CharSet = CharSet.Unicode, SetLastError = false)]
private static extern int SHOpenFolderAndSelectItems(IntPtr pidlFolder, int cild, IntPtr apidl, int dwFlags);
+ public Models.Shell Shell
+ {
+ get;
+ set;
+ } = Models.Shell.Default;
+
public void SetupApp(AppBuilder builder)
{
builder.With(new FontManagerOptions()
@@ -67,23 +73,8 @@ namespace SourceGit.Native
v.dwOSVersionInfoSize = (uint)Marshal.SizeOf();
if (RtlGetVersion(ref v) == 0 && (v.dwMajorVersion < 10 || v.dwBuildNumber < 22000))
{
- Window.WindowStateProperty.Changed.AddClassHandler((w, e) =>
- {
- if (w.WindowState != WindowState.Maximized)
- {
- var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 };
- DwmExtendFrameIntoClientArea(w.TryGetPlatformHandle().Handle, ref margins);
- }
- });
-
- Window.LoadedEvent.AddClassHandler((w, e) =>
- {
- if (w.WindowState != WindowState.Maximized)
- {
- var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 };
- DwmExtendFrameIntoClientArea(w.TryGetPlatformHandle().Handle, ref margins);
- }
- });
+ Window.WindowStateProperty.Changed.AddClassHandler((w, e) => ExtendWindowFrame(w));
+ Window.LoadedEvent.AddClassHandler((w, e) => ExtendWindowFrame(w));
}
}
@@ -114,14 +105,14 @@ namespace SourceGit.Native
return null;
}
- public List FindExternalEditors()
+ public List FindExternalTools()
{
- var finder = new Models.ExternalEditorFinder();
+ var finder = new Models.ExternalToolsFinder();
finder.VSCode(FindVSCode);
finder.VSCodeInsiders(FindVSCodeInsiders);
finder.Fleet(() => $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\Programs\\Fleet\\Fleet.exe");
finder.SublimeText(FindSublimeText);
- return finder.Editors;
+ return finder.Founded;
}
public void OpenBrowser(string url)
@@ -133,19 +124,50 @@ namespace SourceGit.Native
public void OpenTerminal(string workdir)
{
- var binDir = Path.GetDirectoryName(OS.GitExecutable);
- var bash = Path.Combine(binDir, "bash.exe");
- if (!File.Exists(bash))
+ if (string.IsNullOrEmpty(workdir) || !Path.Exists(workdir))
{
- App.RaiseException(string.IsNullOrEmpty(workdir) ? "" : workdir, $"Can NOT found bash.exe under '{binDir}'");
- return;
+ workdir = ".";
}
var startInfo = new ProcessStartInfo();
- startInfo.UseShellExecute = true;
- startInfo.FileName = bash;
- if (!string.IsNullOrEmpty(workdir) && Path.Exists(workdir))
- startInfo.WorkingDirectory = workdir;
+ startInfo.WorkingDirectory = workdir;
+
+ switch (Shell)
+ {
+ case Models.Shell.Default:
+ var binDir = Path.GetDirectoryName(OS.GitExecutable);
+ var bash = Path.Combine(binDir, "bash.exe");
+ if (!File.Exists(bash))
+ {
+ App.RaiseException(workdir, $"Can NOT found bash.exe under '{binDir}'");
+ return;
+ }
+
+ startInfo.FileName = bash;
+ break;
+ case Models.Shell.PowerShell:
+ startInfo.FileName = ChoosePowerShell();
+ startInfo.Arguments = startInfo.FileName.EndsWith("pswd.exe") ? $"-WorkingDirectory \"{workdir}\" -Nologo" : "-Nologo";
+ break;
+ case Models.Shell.CommandPrompt:
+ startInfo.FileName = "cmd";
+ break;
+ case Models.Shell.DefaultShellOfWindowsTerminal:
+ var wt = FindWindowsTerminalApp();
+ if (!File.Exists(wt))
+ {
+ App.RaiseException(workdir, $"Can NOT found wt.exe on your system!");
+ return;
+ }
+
+ startInfo.FileName = FindWindowsTerminalApp();
+ startInfo.Arguments = $"-d \"{workdir}\"";
+ break;
+ default:
+ App.RaiseException(workdir, $"Bad shell configuration!");
+ return;
+ }
+
Process.Start(startInfo);
}
@@ -189,6 +211,62 @@ namespace SourceGit.Native
Process.Start(start);
}
+ private void ExtendWindowFrame(Window w)
+ {
+ var platformHandle = w.TryGetPlatformHandle();
+ if (platformHandle == null)
+ return;
+
+ var margins = new MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 };
+ DwmExtendFrameIntoClientArea(platformHandle.Handle, ref margins);
+ }
+
+ // There are two versions of PowerShell : pwsh.exe (preferred) and powershell.exe (system default)
+ private string ChoosePowerShell()
+ {
+ if (!string.IsNullOrEmpty(_powershellPath))
+ return _powershellPath;
+
+ var localMachine = Microsoft.Win32.RegistryKey.OpenBaseKey(
+ Microsoft.Win32.RegistryHive.LocalMachine,
+ Microsoft.Win32.RegistryView.Registry64);
+
+ var pwsh = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\pwsh.exe");
+ if (pwsh != null)
+ {
+ var path = pwsh.GetValue(null) as string;
+ if (File.Exists(path))
+ {
+ _powershellPath = path;
+ return _powershellPath;
+ }
+ }
+
+ var finder = new StringBuilder("powershell.exe", 512);
+ if (PathFindOnPath(finder, null))
+ {
+ _powershellPath = finder.ToString();
+ return _powershellPath;
+ }
+
+ return string.Empty;
+ }
+
+ private string FindWindowsTerminalApp()
+ {
+ if (!string.IsNullOrEmpty(_wtPath))
+ return _wtPath;
+
+ var finder = new StringBuilder("wt.exe", 512);
+ if (PathFindOnPath(finder, null))
+ {
+ _wtPath = finder.ToString();
+ return _wtPath;
+ }
+
+ return string.Empty;
+ }
+
#region EXTERNAL_EDITOR_FINDER
private string FindVSCode()
{
@@ -250,6 +328,7 @@ namespace SourceGit.Native
Microsoft.Win32.RegistryHive.LocalMachine,
Microsoft.Win32.RegistryView.Registry64);
+ // Sublime Text 4
var sublime = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sublime Text_is1");
if (sublime != null)
{
@@ -257,6 +336,7 @@ namespace SourceGit.Native
return Path.Combine(Path.GetDirectoryName(icon), "subl.exe");
}
+ // Sublime Text 3
var sublime3 = localMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sublime Text 3_is1");
if (sublime3 != null)
{
@@ -281,5 +361,8 @@ namespace SourceGit.Native
ILFree(pidl);
}
}
+
+ private string _powershellPath = string.Empty;
+ private string _wtPath = string.Empty;
}
}
diff --git a/src/Resources/ExternalToolIcons/beyond_compare.png b/src/Resources/ExternalToolIcons/beyond_compare.png
new file mode 100644
index 00000000..c7aaf18b
Binary files /dev/null and b/src/Resources/ExternalToolIcons/beyond_compare.png differ
diff --git a/src/Resources/ExternalToolIcons/custom_diff.png b/src/Resources/ExternalToolIcons/custom_diff.png
new file mode 100644
index 00000000..8d046a2f
Binary files /dev/null and b/src/Resources/ExternalToolIcons/custom_diff.png differ
diff --git a/src/Resources/ExternalToolIcons/fleet.png b/src/Resources/ExternalToolIcons/fleet.png
index aecbf9d4..5e9d84f6 100644
Binary files a/src/Resources/ExternalToolIcons/fleet.png and b/src/Resources/ExternalToolIcons/fleet.png differ
diff --git a/src/Resources/ExternalToolIcons/kdiff3.png b/src/Resources/ExternalToolIcons/kdiff3.png
new file mode 100644
index 00000000..1e2a0bbb
Binary files /dev/null and b/src/Resources/ExternalToolIcons/kdiff3.png differ
diff --git a/src/Resources/ExternalToolIcons/meld.png b/src/Resources/ExternalToolIcons/meld.png
new file mode 100644
index 00000000..b9885f15
Binary files /dev/null and b/src/Resources/ExternalToolIcons/meld.png differ
diff --git a/src/Resources/ExternalToolIcons/sublime_text.png b/src/Resources/ExternalToolIcons/sublime_text.png
index 7f2b54e5..89e4a286 100644
Binary files a/src/Resources/ExternalToolIcons/sublime_text.png and b/src/Resources/ExternalToolIcons/sublime_text.png differ
diff --git a/src/Resources/ExternalToolIcons/tortoise_merge.png b/src/Resources/ExternalToolIcons/tortoise_merge.png
new file mode 100644
index 00000000..eb5b1a8a
Binary files /dev/null and b/src/Resources/ExternalToolIcons/tortoise_merge.png differ
diff --git a/src/Resources/ExternalToolIcons/vs.png b/src/Resources/ExternalToolIcons/vs.png
new file mode 100644
index 00000000..d79fbcfd
Binary files /dev/null and b/src/Resources/ExternalToolIcons/vs.png differ
diff --git a/src/Resources/ExternalToolIcons/vscode.png b/src/Resources/ExternalToolIcons/vscode.png
index fe53b256..23b6af54 100644
Binary files a/src/Resources/ExternalToolIcons/vscode.png and b/src/Resources/ExternalToolIcons/vscode.png differ
diff --git a/src/Resources/ExternalToolIcons/vscode_insiders.png b/src/Resources/ExternalToolIcons/vscode_insiders.png
index e81fb485..38fe8a1e 100644
Binary files a/src/Resources/ExternalToolIcons/vscode_insiders.png and b/src/Resources/ExternalToolIcons/vscode_insiders.png differ
diff --git a/src/Resources/ExternalToolIcons/win_merge.png b/src/Resources/ExternalToolIcons/win_merge.png
new file mode 100644
index 00000000..8f9f53d4
Binary files /dev/null and b/src/Resources/ExternalToolIcons/win_merge.png differ
diff --git a/src/Resources/ExternalToolIcons/xcode.png b/src/Resources/ExternalToolIcons/xcode.png
new file mode 100644
index 00000000..faccf441
Binary files /dev/null and b/src/Resources/ExternalToolIcons/xcode.png differ
diff --git a/src/Resources/Icons.axaml b/src/Resources/Icons.axaml
index b2b5876f..5f036c97 100644
--- a/src/Resources/Icons.axaml
+++ b/src/Resources/Icons.axaml
@@ -11,7 +11,7 @@
M192 192m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM192 512m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM192 832m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0ZM864 160H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32zM864 480H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32zM864 800H352c-17.7 0-32 14.3-32 32s14.3 32 32 32h512c17.7 0 32-14.3 32-32s-14.3-32-32-32z
M512 945c-238 0-433-195-433-433S274 79 512 79c238 0 433 195 433 433S750 945 512 945M512 0C228 0 0 228 0 512s228 512 512 512 512-228 512-512-228-512-512-512zM752 477H364l128-128a38 38 0 000-55 38 38 0 00-55 0l-185 183a55 55 0 00-16 39c0 16 6 30 16 39l185 185a39 39 0 0028 12 34 34 0 0028-14 38 38 0 000-55l-128-128h386c22 0 41-18 41-39a39 39 0 00-39-39
M576 832C576 867 547 896 512 896 477 896 448 867 448 832 448 797 477 768 512 768 547 768 576 797 576 832ZM512 256C477 256 448 285 448 320L448 640C448 675 477 704 512 704 547 704 576 675 576 640L576 320C576 285 547 256 512 256ZM1024 896C1024 967 967 1024 896 1024L128 1024C57 1024 0 967 0 896 0 875 5 855 14 837L14 837 398 69 398 69C420 28 462 0 512 0 562 0 604 28 626 69L1008 835C1018 853 1024 874 1024 896ZM960 896C960 885 957 875 952 865L952 864 951 863 569 98C557 77 536 64 512 64 488 64 466 77 455 99L452 105 92 825 93 825 71 867C66 876 64 886 64 896 64 931 93 960 128 960L896 960C931 960 960 931 960 896Z
- M352 64h320L960 352v320L672 960h-320L64 672v-320L352 64zm161 363L344 256 260 341 429 512l-169 171L344 768 513 597 682 768l85-85L598 512l169-171L682 256 513 427z
+ M608 0q48 0 88 23t63 63 23 87v70h55q35 0 67 14t57 38 38 57 14 67V831q0 34-14 66t-38 57-57 38-67 13H426q-34 0-66-13t-57-38-38-57-14-66v-70h-56q-34 0-66-14t-57-38-38-57-13-67V174q0-47 23-87T109 23 196 0h412m175 244H426q-46 0-86 22T278 328t-26 85v348H608q47 0 86-22t63-62 25-85l1-348m-269 318q18 0 31 13t13 31-13 31-31 13-31-13-13-31 13-31 31-13m0-212q13 0 22 9t11 22v125q0 14-9 23t-22 10-23-7-11-22l-1-126q0-13 10-23t23-10z
m186 532 287 0 0 287c0 11 9 20 20 20s20-9 20-20l0-287 287 0c11 0 20-9 20-20s-9-20-20-20l-287 0 0-287c0-11-9-20-20-20s-20 9-20 20l0 287-287 0c-11 0-20 9-20 20s9 20 20 20z
M716.3 383.1c0 38.4-6.5 76-19.4 111.8l-10.7 29.7 229.6 229.5c44.5 44.6 44.5 117.1 0 161.6a113.6 113.6 0 01-80.8 33.5a113.6 113.6 0 01-80.8-33.5L529 694l-32 13a331.6 331.6 0 01-111.9 19.4A333.5 333.5 0 0150 383.1c0-39 6.8-77.2 20-113.6L285 482l194-195-214-210A331 331 0 01383.1 50A333.5 333.5 0 01716.3 383.1zM231.6 31.6l-22.9 9.9a22.2 22.2 0 00-5.9 4.2a19.5 19.5 0 000 27.5l215 215.2L288.4 417.8 77.8 207.1a26 26 0 00-17.2-7.1a22.8 22.8 0 00-21.5 15a400.5 400.5 0 00-7.5 16.6A381.6 381.6 0 000 384c0 211.7 172.2 384 384 384c44.3 0 87.6-7.5 129-22.3L743.1 975.8A163.5 163.5 0 00859.5 1024c43.9 0 85.3-17.1 116.4-48.2a164.8 164.8 0 000-233L745.5 513C760.5 471.5 768 428 768 384C768 172 596 0 384 0c-53 0-104 10.5-152.5 31.5z
M928 500a21 21 0 00-19-20L858 472a11 11 0 01-9-9c-1-6-2-13-3-19a11 11 0 015-12l46-25a21 21 0 0010-26l-8-22a21 21 0 00-24-13l-51 10a11 11 0 01-12-6c-3-6-6-11-10-17a11 11 0 011-13l34-39a21 21 0 001-28l-15-18a20 20 0 00-27-4l-45 27a11 11 0 01-13-1c-5-4-10-9-15-12a11 11 0 01-3-12l19-49a21 21 0 00-9-26l-20-12a21 21 0 00-27 6L650 193a9 9 0 01-11 3c-1-1-12-5-20-7a11 11 0 01-7-10l1-52a21 21 0 00-17-22l-23-4a21 21 0 00-24 14L532 164a11 11 0 01-11 7h-20a11 11 0 01-11-7l-17-49a21 21 0 00-24-15l-23 4a21 21 0 00-17 22l1 52a11 11 0 01-8 11c-5 2-15 6-19 7c-4 1-8 0-12-4l-33-40A21 21 0 00313 146l-20 12A21 21 0 00285 184l19 49a11 11 0 01-3 12c-5 4-10 8-15 12a11 11 0 01-13 1L228 231a21 21 0 00-27 4L186 253a21 21 0 001 28L221 320a11 11 0 011 13c-3 5-7 11-10 17a11 11 0 01-12 6l-51-10a21 21 0 00-24 13l-8 22a21 21 0 0010 26l46 25a11 11 0 015 12l0 3c-1 6-2 11-3 16a11 11 0 01-9 9l-51 8A21 21 0 0096 500v23A21 21 0 00114 544l51 8a11 11 0 019 9c1 6 2 13 3 19a11 11 0 01-5 12l-46 25a21 21 0 00-10 26l8 22a21 21 0 0024 13l51-10a11 11 0 0112 6c3 6 6 11 10 17a11 11 0 01-1 13l-34 39a21 21 0 00-1 28l15 18a20 20 0 0027 4l45-27a11 11 0 0113 1c5 4 10 9 15 12a11 11 0 013 12l-19 49a21 21 0 009 26l20 12a21 21 0 0027-6L374 832c3-3 7-5 10-4c7 3 12 5 20 7a11 11 0 018 10l-1 52a21 21 0 0017 22l23 4a21 21 0 0024-14l17-50a11 11 0 0111-7h20a11 11 0 0111 7l17 49a21 21 0 0020 15a19 19 0 004 0l23-4a21 21 0 0017-22l-1-52a11 11 0 018-10c8-3 13-5 18-7l1 0c6-2 9 0 11 3l34 41A21 21 0 00710 878l20-12a21 21 0 009-26l-18-49a11 11 0 013-12c5-4 10-8 15-12a11 11 0 0113-1l45 27a21 21 0 0027-4l15-18a21 21 0 00-1-28l-34-39a11 11 0 01-1-13c3-5 7-11 10-17a11 11 0 0112-6l51 10a21 21 0 0024-13l8-22a21 21 0 00-10-26l-46-25a11 11 0 01-5-12l0-3c1-6 2-11 3-16a11 11 0 019-9l51-8a21 21 0 0018-21v-23zm-565 188a32 32 0 01-51 5a270 270 0 011-363a32 32 0 0151 6l91 161a32 32 0 010 31zM512 782a270 270 0 01-57-6a32 32 0 01-20-47l92-160a32 32 0 0127-16h184a32 32 0 0130 41c-35 109-137 188-257 188zm15-328L436 294a32 32 0 0121-47a268 268 0 0155-6c120 0 222 79 257 188a32 32 0 01-30 41h-184a32 32 0 01-28-16z
@@ -88,4 +88,6 @@
M875 128h-725A107 107 0 0043 235v555A107 107 0 00149 896h725a107 107 0 00107-107v-555A107 107 0 00875 128zm-115 640h-183v-58l25-3c15 0 19-8 14-24l-22-61H419l-28 82 39 2V768h-166v-58l18-3c18-2 22-11 26-24l125-363-40-4V256h168l160 448 39 3zM506 340l-72 218h145l-71-218h-2z
M900 287c40 69 60 144 60 225s-20 156-60 225c-40 69-94 123-163 163-69 40-144 60-225 60s-156-20-225-60c-69-40-123-94-163-163C84 668 64 593 64 512s20-156 60-225 94-123 163-163c69-40 144-60 225-60s156 20 225 60 123 94 163 163zM762 512c0-9-3-16-9-22L578 315l-44-44c-6-6-13-9-22-9s-16 3-22 9l-44 44-176 176c-6 6-9 13-9 22s3 16 9 22l44 44c6 6 13 9 22 9s16-3 22-9l92-92v269c0 9 3 16 9 22 6 6 13 9 22 9h62c8 0 16-3 22-9 6-6 9-13 9-22V486l92 92c6 6 13 9 22 9 8 0 16-3 22-9l44-44c6-6 9-13 9-22z
M765 555C747 661 661 747 555 765L555 683 469 683 469 765C363 747 277 661 259 555L341 555 341 469 259 469C277 363 363 277 469 259L469 341 555 341 555 259C661 277 747 363 765 469L683 469 683 555 765 555M851 469C832 315 709 192 555 173L555 85 469 85 469 173C315 192 192 315 173 469L85 469 85 555 173 555C192 709 315 832 469 851L469 939 555 939 555 851C709 832 832 709 851 555L939 555 939 469 851 469M512 427C559 427 597 465 597 512 597 559 559 597 512 597 465 597 427 559 427 512 427 465 465 427 512 427L512 427Z
+ M973 358a51 51 0 0151 51v563a51 51 0 01-51 51H51a51 51 0 01-51-51V410a51 51 0 0151-51h256a51 51 0 110 102H102v461h819V461h-205a51 51 0 110-102h256zM51 102a51 51 0 110-102h256c141 0 256 115 256 256v388l66-66a51 51 0 1172 72l-154 154a51 51 0 01-72 0l-154-154a51 51 0 1172-72L461 644V256c0-85-69-154-154-154H51z
+ M976 0h-928A48 48 0 000 48v652a48 48 0 0048 48h416V928H200a48 48 0 000 96h624a48 48 0 000-96H560v-180h416a48 48 0 0048-48V48A48 48 0 00976 0zM928 652H96V96h832v556z
diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index 68e57b4c..9752f0d6 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -131,6 +131,7 @@
NEW
OLD
Copy
+ File Mode Changed
LFS OBJECT CHANGE
Next Difference
NO CHANGES OR ONLY EOL CHANGES
@@ -160,6 +161,7 @@
Discard...
Discard {0} files...
Discard Changes in Selected Line(s)
+ Open External Merge Tool
Save As Patch...
Stage...
Stage {0} files...
@@ -169,6 +171,8 @@
Unstage
Unstage {0} files
Unstage Changes in Selected Line(s)
+ Use Theirs (checkout --theirs)
+ Use Mine (checkout --ours)
File History
FILTER
Git-Flow
@@ -266,6 +270,7 @@
User Email
Global git user email
Install Path
+ Shell
User Name
Global git user name
Git version
@@ -275,7 +280,7 @@
Input path for installed gpg program
User Signing Key
User's gpg signing key
- MERGE
+ EXTERNAL MERGE TOOL
Diff Command
Merge Command
Install Path
@@ -430,7 +435,6 @@
INCLUDE UNTRACKED FILES
MESSAGE HISTORIES
NO RECENT INPUT MESSAGES
- OPEN MERGE
STAGED
UNSTAGE
UNSTAGE ALL
@@ -438,6 +442,5 @@
STAGE
STAGE ALL
VIEW ASSUME UNCHANGED
- USE MINE
- USE THEIRS
+ Right-click the selected file(s), and make your choice to resolve conflicts.
diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml
index 79cf9973..a6fdb67f 100644
--- a/src/Resources/Locales/zh_CN.axaml
+++ b/src/Resources/Locales/zh_CN.axaml
@@ -131,6 +131,7 @@
当前大小
原始大小
复制
+ 文件权限已变化
LFS对象变更
下一个差异
没有变更或仅有换行符差异
@@ -160,6 +161,7 @@
放弃更改...
放弃 {0} 个文件的更改...
放弃选中的更改
+ 使用外部合并工具打开
另存为补丁...
暂存(add)...
暂存(add){0} 个文件...
@@ -169,6 +171,8 @@
从暂存中移除
从暂存中移除 {0} 个文件
从暂存中移除选中的更改
+ 使用 THEIRS (checkout --theirs)
+ 使用 MINE (checkout --ours)
文件历史
过滤
GIT工作流
@@ -266,6 +270,7 @@
邮箱
默认GIT用户邮箱
安装路径
+ 终端Shell
用户名
默认GIT用户名
Git 版本
@@ -430,7 +435,6 @@
显示未跟踪文件
历史提交信息
没有提交信息记录
- 打开合并工具
已暂存
从暂存区移除选中
从暂存区移除所有
@@ -438,6 +442,5 @@
暂存选中
暂存所有
查看忽略变更文件
- 使用MINE
- 使用THEIRS
+ 请选中冲突文件,打开右键菜单,选择合适的解决方式
diff --git a/src/Resources/ShellIcons/cmd.png b/src/Resources/ShellIcons/cmd.png
new file mode 100644
index 00000000..efa27dd4
Binary files /dev/null and b/src/Resources/ShellIcons/cmd.png differ
diff --git a/src/Resources/ShellIcons/git-bash.png b/src/Resources/ShellIcons/git-bash.png
new file mode 100644
index 00000000..767e0a4e
Binary files /dev/null and b/src/Resources/ShellIcons/git-bash.png differ
diff --git a/src/Resources/ShellIcons/pwsh.png b/src/Resources/ShellIcons/pwsh.png
new file mode 100644
index 00000000..12edf757
Binary files /dev/null and b/src/Resources/ShellIcons/pwsh.png differ
diff --git a/src/Resources/ShellIcons/wt.png b/src/Resources/ShellIcons/wt.png
new file mode 100644
index 00000000..f2a874f4
Binary files /dev/null and b/src/Resources/ShellIcons/wt.png differ
diff --git a/src/SourceGit.csproj b/src/SourceGit.csproj
index 0a3ef8a6..ecad8b6c 100644
--- a/src/SourceGit.csproj
+++ b/src/SourceGit.csproj
@@ -5,7 +5,7 @@
true
App.manifest
App.ico
- 8.7
+ 8.8
false
true
true
@@ -22,8 +22,9 @@
-
+
+
diff --git a/src/ViewModels/CommitDetail.cs b/src/ViewModels/CommitDetail.cs
index fe719517..6fdcd93c 100644
--- a/src/ViewModels/CommitDetail.cs
+++ b/src/ViewModels/CommitDetail.cs
@@ -205,7 +205,7 @@ namespace SourceGit.ViewModels
var type = Preference.Instance.ExternalMergeToolType;
var exec = Preference.Instance.ExternalMergeToolPath;
- var tool = Models.ExternalMergeTools.Supported.Find(x => x.Type == type);
+ var tool = Models.ExternalMerger.Supported.Find(x => x.Type == type);
if (tool == null || !File.Exists(exec))
{
App.RaiseException(_repo, "Invalid merge tool in preference setting!");
@@ -355,7 +355,9 @@ namespace SourceGit.ViewModels
_cancelToken.Requested = true;
_cancelToken = new Commands.Command.CancelToken();
- var cmdChanges = new Commands.QueryCommitChanges(_repo, _commit.SHA) { Cancel = _cancelToken };
+
+ var parent = _commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : _commit.Parents[0];
+ var cmdChanges = new Commands.CompareRevisions(_repo, parent, _commit.SHA) { Cancel = _cancelToken };
var cmdRevisionFiles = new Commands.QueryRevisionObjects(_repo, _commit.SHA) { Cancel = _cancelToken };
Task.Run(() =>
diff --git a/src/ViewModels/DiffContext.cs b/src/ViewModels/DiffContext.cs
index 728c4f43..18c03936 100644
--- a/src/ViewModels/DiffContext.cs
+++ b/src/ViewModels/DiffContext.cs
@@ -27,19 +27,16 @@ namespace SourceGit.ViewModels
get => _option.IsUnstaged;
}
- public string FilePath
+ public string Title
{
- get => _option.Path;
+ get => _title;
+ private set => SetProperty(ref _title, value);
}
- public bool IsOrgFilePathVisible
+ public string FileModeChange
{
- get => !string.IsNullOrWhiteSpace(_option.OrgPath) && _option.OrgPath != "/dev/null";
- }
-
- public string OrgFilePath
- {
- get => _option.OrgPath;
+ get => _fileModeChange;
+ private set => SetProperty(ref _fileModeChange, value);
}
public bool IsLoading
@@ -77,10 +74,6 @@ namespace SourceGit.ViewModels
_content = previous._content;
}
- OnPropertyChanged(nameof(FilePath));
- OnPropertyChanged(nameof(IsOrgFilePathVisible));
- OnPropertyChanged(nameof(OrgFilePath));
-
Task.Run(() =>
{
var latest = new Commands.Diff(repo, option).Result();
@@ -140,6 +133,12 @@ namespace SourceGit.ViewModels
Dispatcher.UIThread.Post(() =>
{
+ if (string.IsNullOrEmpty(_option.OrgPath))
+ Title = _option.Path;
+ else
+ Title = $"{_option.OrgPath} → {_option.Path}";
+
+ FileModeChange = latest.FileModeChange;
Content = rs;
IsTextDiff = latest.TextDiff != null;
IsLoading = false;
@@ -152,7 +151,7 @@ namespace SourceGit.ViewModels
var type = Preference.Instance.ExternalMergeToolType;
var exec = Preference.Instance.ExternalMergeToolPath;
- var tool = Models.ExternalMergeTools.Supported.Find(x => x.Type == type);
+ var tool = Models.ExternalMerger.Supported.Find(x => x.Type == type);
if (tool == null || !File.Exists(exec))
{
App.RaiseException(_repo, "Invalid merge tool in preference setting!");
@@ -176,6 +175,8 @@ namespace SourceGit.ViewModels
private readonly string _repo = string.Empty;
private readonly Models.DiffOption _option = null;
+ private string _title = string.Empty;
+ private string _fileModeChange = string.Empty;
private bool _isLoading = true;
private bool _isTextDiff = false;
private object _content = null;
diff --git a/src/ViewModels/Histories.cs b/src/ViewModels/Histories.cs
index bf119eac..a4102543 100644
--- a/src/ViewModels/Histories.cs
+++ b/src/ViewModels/Histories.cs
@@ -129,6 +129,7 @@ namespace SourceGit.ViewModels
{
var commit = commits[0] as Models.Commit;
AutoSelectedCommit = commit;
+ NavigationId = _navigationId + 1;
if (_detailContext is CommitDetail detail)
{
diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs
index ee8f96a9..8d0520c8 100644
--- a/src/ViewModels/Preference.cs
+++ b/src/ViewModels/Preference.cs
@@ -200,6 +200,18 @@ namespace SourceGit.ViewModels
}
}
+ public Models.Shell GitShell
+ {
+ get => Native.OS.GetShell();
+ set
+ {
+ if (Native.OS.SetShell(value))
+ {
+ OnPropertyChanged(nameof(GitShell));
+ }
+ }
+ }
+
public string GitDefaultCloneDir
{
get => _gitDefaultCloneDir;
@@ -225,9 +237,9 @@ namespace SourceGit.ViewModels
set
{
var changed = SetProperty(ref _externalMergeToolType, value);
- if (changed && !OperatingSystem.IsWindows() && value > 0 && value < Models.ExternalMergeTools.Supported.Count)
+ if (changed && !OperatingSystem.IsWindows() && value > 0 && value < Models.ExternalMerger.Supported.Count)
{
- var tool = Models.ExternalMergeTools.Supported[value];
+ var tool = Models.ExternalMerger.Supported[value];
if (File.Exists(tool.Exec))
ExternalMergeToolPath = tool.Exec;
else
diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs
index 61f034ff..43665925 100644
--- a/src/ViewModels/Repository.cs
+++ b/src/ViewModels/Repository.cs
@@ -287,10 +287,10 @@ namespace SourceGit.ViewModels
Native.OS.OpenTerminal(_fullpath);
}
- public ContextMenu CreateContextMenuForExternalEditors()
+ public ContextMenu CreateContextMenuForExternalTools()
{
- var editors = Native.OS.ExternalEditors;
- if (editors.Count == 0)
+ var tools = Native.OS.ExternalTools;
+ if (tools.Count == 0)
{
App.RaiseException(_fullpath, "No available external editors found!");
return null;
@@ -300,16 +300,16 @@ namespace SourceGit.ViewModels
menu.Placement = PlacementMode.BottomEdgeAlignedLeft;
RenderOptions.SetBitmapInterpolationMode(menu, BitmapInterpolationMode.HighQuality);
- foreach (var editor in editors)
+ foreach (var tool in tools)
{
- var dupEditor = editor;
- var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalToolIcons/{dupEditor.Icon}", UriKind.RelativeOrAbsolute));
+ var dupTool = tool;
+
var item = new MenuItem();
- item.Header = App.Text("Repository.OpenIn", dupEditor.Name);
- item.Icon = new Image { Width = 16, Height = 16, Source = new Bitmap(icon) };
+ item.Header = App.Text("Repository.OpenIn", dupTool.Name);
+ item.Icon = new Image { Width = 16, Height = 16, Source = dupTool.IconImage };
item.Click += (o, e) =>
{
- dupEditor.Open(_fullpath);
+ dupTool.Open(_fullpath);
e.Handled = true;
};
diff --git a/src/ViewModels/RevisionCompare.cs b/src/ViewModels/RevisionCompare.cs
index 167f3a41..1ed85c9e 100644
--- a/src/ViewModels/RevisionCompare.cs
+++ b/src/ViewModels/RevisionCompare.cs
@@ -166,7 +166,7 @@ namespace SourceGit.ViewModels
var type = Preference.Instance.ExternalMergeToolType;
var exec = Preference.Instance.ExternalMergeToolPath;
- var tool = Models.ExternalMergeTools.Supported.Find(x => x.Type == type);
+ var tool = Models.ExternalMerger.Supported.Find(x => x.Type == type);
if (tool == null || !File.Exists(exec))
{
App.RaiseException(_repo, "Invalid merge tool in preference setting!");
diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs
index 6aa9d999..2a158242 100644
--- a/src/ViewModels/WorkingCopy.cs
+++ b/src/ViewModels/WorkingCopy.cs
@@ -386,34 +386,42 @@ namespace SourceGit.ViewModels
}
}
- public async void UseTheirs()
+ public async void UseTheirs(List changes)
{
- if (_detailContext is ConflictContext ctx)
+ var files = new List();
+ foreach (var change in changes)
{
- _repo.SetWatcherEnabled(false);
- var succ = await Task.Run(() => new Commands.Checkout(_repo.FullPath).File(ctx.Change.Path, true));
- if (succ)
- {
- await Task.Run(() => new Commands.Add(_repo.FullPath, [ctx.Change]).Exec());
- }
- _repo.MarkWorkingCopyDirtyManually();
- _repo.SetWatcherEnabled(true);
+ if (change.IsConflit)
+ files.Add(change.Path);
}
+
+ _repo.SetWatcherEnabled(false);
+ var succ = await Task.Run(() => new Commands.Checkout(_repo.FullPath).UseTheirs(files));
+ if (succ)
+ {
+ await Task.Run(() => new Commands.Add(_repo.FullPath, changes).Exec());
+ }
+ _repo.MarkWorkingCopyDirtyManually();
+ _repo.SetWatcherEnabled(true);
}
- public async void UseMine()
+ public async void UseMine(List changes)
{
- if (_detailContext is ConflictContext ctx)
+ var files = new List();
+ foreach (var change in changes)
{
- _repo.SetWatcherEnabled(false);
- var succ = await Task.Run(() => new Commands.Checkout(_repo.FullPath).File(ctx.Change.Path, false));
- if (succ)
- {
- await Task.Run(() => new Commands.Add(_repo.FullPath, [ctx.Change]).Exec());
- }
- _repo.MarkWorkingCopyDirtyManually();
- _repo.SetWatcherEnabled(true);
+ if (change.IsConflit)
+ files.Add(change.Path);
}
+
+ _repo.SetWatcherEnabled(false);
+ var succ = await Task.Run(() => new Commands.Checkout(_repo.FullPath).UseMine(files));
+ if (succ)
+ {
+ await Task.Run(() => new Commands.Add(_repo.FullPath, changes).Exec());
+ }
+ _repo.MarkWorkingCopyDirtyManually();
+ _repo.SetWatcherEnabled(true);
}
public async void UseExternalMergeTool()
@@ -423,7 +431,7 @@ namespace SourceGit.ViewModels
var type = Preference.Instance.ExternalMergeToolType;
var exec = Preference.Instance.ExternalMergeToolPath;
- var tool = Models.ExternalMergeTools.Supported.Find(x => x.Type == type);
+ var tool = Models.ExternalMerger.Supported.Find(x => x.Type == type);
if (tool == null)
{
App.RaiseException(_repo.FullPath, "Invalid merge tool in preference setting!");
@@ -499,6 +507,7 @@ namespace SourceGit.ViewModels
Native.OS.OpenInFileManager(path, true);
e.Handled = true;
};
+ menu.Items.Add(explore);
var openWith = new MenuItem();
openWith.Header = App.Text("OpenWith");
@@ -509,81 +518,129 @@ namespace SourceGit.ViewModels
Native.OS.OpenWithDefaultEditor(path);
e.Handled = true;
};
+ menu.Items.Add(openWith);
+ menu.Items.Add(new MenuItem() { Header = "-" });
- var stage = new MenuItem();
- stage.Header = App.Text("FileCM.Stage");
- stage.Icon = App.CreateMenuIcon("Icons.File.Add");
- stage.Click += (_, e) =>
+ if (change.IsConflit)
{
- StageChanges(changes);
- e.Handled = true;
- };
-
- var discard = new MenuItem();
- discard.Header = App.Text("FileCM.Discard");
- discard.Icon = App.CreateMenuIcon("Icons.Undo");
- discard.Click += (_, e) =>
- {
- Discard(changes, true);
- e.Handled = true;
- };
-
- var stash = new MenuItem();
- stash.Header = App.Text("FileCM.Stash");
- stash.Icon = App.CreateMenuIcon("Icons.Stashes");
- stash.Click += (_, e) =>
- {
- if (PopupHost.CanCreatePopup())
+ var useTheirs = new MenuItem();
+ useTheirs.Icon = App.CreateMenuIcon("Icons.Incoming");
+ useTheirs.Header = App.Text("FileCM.UseTheirs");
+ useTheirs.Click += (_, e) =>
{
- PopupHost.ShowPopup(new StashChanges(_repo, changes, false));
- }
- e.Handled = true;
- };
+ UseTheirs(changes);
+ e.Handled = true;
+ };
- var patch = new MenuItem();
- patch.Header = App.Text("FileCM.SaveAsPatch");
- patch.Icon = App.CreateMenuIcon("Icons.Diff");
- patch.Click += async (_, e) =>
- {
- var topLevel = App.GetTopLevel();
- if (topLevel == null)
- return;
-
- var options = new FilePickerSaveOptions();
- options.Title = App.Text("FileCM.SaveAsPatch");
- options.DefaultExtension = ".patch";
- options.FileTypeChoices = [new FilePickerFileType("Patch File") { Patterns = ["*.patch"] }];
-
- var storageFile = await topLevel.StorageProvider.SaveFilePickerAsync(options);
- if (storageFile != null)
+ var useMine = new MenuItem();
+ useMine.Icon = App.CreateMenuIcon("Icons.Local");
+ useMine.Header = App.Text("FileCM.UseMine");
+ useMine.Click += (_, e) =>
{
- var succ = await Task.Run(() => Commands.SaveChangesAsPatch.Exec(_repo.FullPath, changes, true, storageFile.Path.LocalPath));
- if (succ)
- App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess"));
- }
+ UseMine(changes);
+ e.Handled = true;
+ };
- e.Handled = true;
- };
+ var openMerger = new MenuItem();
+ openMerger.Icon = App.CreateMenuIcon("Icons.OpenWith");
+ openMerger.Header = App.Text("FileCM.OpenWithExternalMerger");
+ openMerger.Click += (_, e) =>
+ {
+ UseExternalMergeTool();
+ e.Handled = true;
+ };
- var history = new MenuItem();
- history.Header = App.Text("FileHistory");
- history.Icon = App.CreateMenuIcon("Icons.Histories");
- history.Click += (_, e) =>
+ menu.Items.Add(useTheirs);
+ menu.Items.Add(useMine);
+ menu.Items.Add(openMerger);
+ menu.Items.Add(new MenuItem() { Header = "-" });
+ }
+ else
{
- var window = new Views.FileHistories() { DataContext = new FileHistories(_repo.FullPath, change.Path) };
- window.Show();
- e.Handled = true;
- };
+ var stage = new MenuItem();
+ stage.Header = App.Text("FileCM.Stage");
+ stage.Icon = App.CreateMenuIcon("Icons.File.Add");
+ stage.Click += (_, e) =>
+ {
+ StageChanges(changes);
+ e.Handled = true;
+ };
- var assumeUnchanged = new MenuItem();
- assumeUnchanged.Header = App.Text("FileCM.AssumeUnchanged");
- assumeUnchanged.Icon = App.CreateMenuIcon("Icons.File.Ignore");
- assumeUnchanged.IsEnabled = change.WorkTree != Models.ChangeState.Untracked;
- assumeUnchanged.Click += (_, e) =>
- {
- new Commands.AssumeUnchanged(_repo.FullPath).Add(change.Path);
- e.Handled = true;
- };
+ var discard = new MenuItem();
+ discard.Header = App.Text("FileCM.Discard");
+ discard.Icon = App.CreateMenuIcon("Icons.Undo");
+ discard.Click += (_, e) =>
+ {
+ Discard(changes, true);
+ e.Handled = true;
+ };
+
+ var stash = new MenuItem();
+ stash.Header = App.Text("FileCM.Stash");
+ stash.Icon = App.CreateMenuIcon("Icons.Stashes");
+ stash.Click += (_, e) =>
+ {
+ if (PopupHost.CanCreatePopup())
+ {
+ PopupHost.ShowPopup(new StashChanges(_repo, changes, false));
+ }
+ e.Handled = true;
+ };
+
+ var patch = new MenuItem();
+ patch.Header = App.Text("FileCM.SaveAsPatch");
+ patch.Icon = App.CreateMenuIcon("Icons.Diff");
+ patch.Click += async (_, e) =>
+ {
+ var topLevel = App.GetTopLevel();
+ if (topLevel == null)
+ return;
+
+ var options = new FilePickerSaveOptions();
+ options.Title = App.Text("FileCM.SaveAsPatch");
+ options.DefaultExtension = ".patch";
+ options.FileTypeChoices = [new FilePickerFileType("Patch File") { Patterns = ["*.patch"] }];
+
+ var storageFile = await topLevel.StorageProvider.SaveFilePickerAsync(options);
+ if (storageFile != null)
+ {
+ var succ = await Task.Run(() => Commands.SaveChangesAsPatch.Exec(_repo.FullPath, changes, true, storageFile.Path.LocalPath));
+ if (succ)
+ App.SendNotification(_repo.FullPath, App.Text("SaveAsPatchSuccess"));
+ }
+
+ e.Handled = true;
+ };
+
+ var history = new MenuItem();
+ history.Header = App.Text("FileHistory");
+ history.Icon = App.CreateMenuIcon("Icons.Histories");
+ history.Click += (_, e) =>
+ {
+ var window = new Views.FileHistories() { DataContext = new FileHistories(_repo.FullPath, change.Path) };
+ window.Show();
+ e.Handled = true;
+ };
+
+ var assumeUnchanged = new MenuItem();
+ assumeUnchanged.Header = App.Text("FileCM.AssumeUnchanged");
+ assumeUnchanged.Icon = App.CreateMenuIcon("Icons.File.Ignore");
+ assumeUnchanged.IsEnabled = change.WorkTree != Models.ChangeState.Untracked;
+ assumeUnchanged.Click += (_, e) =>
+ {
+ new Commands.AssumeUnchanged(_repo.FullPath).Add(change.Path);
+ e.Handled = true;
+ };
+
+ menu.Items.Add(stage);
+ menu.Items.Add(discard);
+ menu.Items.Add(stash);
+ menu.Items.Add(patch);
+ menu.Items.Add(new MenuItem() { Header = "-" });
+ menu.Items.Add(history);
+ menu.Items.Add(assumeUnchanged);
+ menu.Items.Add(new MenuItem() { Header = "-" });
+ }
var copy = new MenuItem();
copy.Header = App.Text("CopyPath");
@@ -593,22 +650,55 @@ namespace SourceGit.ViewModels
App.CopyText(change.Path);
e.Handled = true;
};
-
- menu.Items.Add(explore);
- menu.Items.Add(openWith);
- menu.Items.Add(new MenuItem() { Header = "-" });
- menu.Items.Add(stage);
- menu.Items.Add(discard);
- menu.Items.Add(stash);
- menu.Items.Add(patch);
- menu.Items.Add(new MenuItem() { Header = "-" });
- menu.Items.Add(history);
- menu.Items.Add(assumeUnchanged);
- menu.Items.Add(new MenuItem() { Header = "-" });
menu.Items.Add(copy);
}
else
{
+ var hasConflicts = false;
+ var hasNoneConflicts = false;
+ foreach (var change in changes)
+ {
+ if (change.IsConflit)
+ {
+ hasConflicts = true;
+ }
+ else
+ {
+ hasNoneConflicts = true;
+ }
+ }
+
+ if (hasConflicts)
+ {
+ if (hasNoneConflicts)
+ {
+ App.RaiseException(_repo.FullPath, "You have selected both non-conflict changes with conflicts!");
+ return null;
+ }
+
+ var useTheirs = new MenuItem();
+ useTheirs.Icon = App.CreateMenuIcon("Icons.Incoming");
+ useTheirs.Header = App.Text("FileCM.UseTheirs");
+ useTheirs.Click += (_, e) =>
+ {
+ UseTheirs(changes);
+ e.Handled = true;
+ };
+
+ var useMine = new MenuItem();
+ useMine.Icon = App.CreateMenuIcon("Icons.Local");
+ useMine.Header = App.Text("FileCM.UseMine");
+ useMine.Click += (_, e) =>
+ {
+ UseMine(changes);
+ e.Handled = true;
+ };
+
+ menu.Items.Add(useTheirs);
+ menu.Items.Add(useMine);
+ return menu;
+ }
+
var stage = new MenuItem();
stage.Header = App.Text("FileCM.StageMulti", changes.Count);
stage.Icon = App.CreateMenuIcon("Icons.File.Add");
diff --git a/src/Views/Blame.axaml.cs b/src/Views/Blame.axaml.cs
index 1c23d82d..d8226487 100644
--- a/src/Views/Blame.axaml.cs
+++ b/src/Views/Blame.axaml.cs
@@ -227,6 +227,8 @@ namespace SourceGit.Views
TextArea.TextView.ContextRequested += OnTextViewContextRequested;
TextArea.TextView.VisualLinesChanged += OnTextViewVisualLinesChanged;
TextArea.TextView.Margin = new Thickness(4, 0);
+ TextArea.TextView.Options.EnableHyperlinks = false;
+ TextArea.TextView.Options.EnableEmailHyperlinks = false;
}
public void OnCommitSHAClicked(string sha)
diff --git a/src/Views/CommitBaseInfo.axaml b/src/Views/CommitBaseInfo.axaml
index 5c0771e7..40b1e036 100644
--- a/src/Views/CommitBaseInfo.axaml
+++ b/src/Views/CommitBaseInfo.axaml
@@ -99,7 +99,7 @@
-
+
diff --git a/src/Views/DiffView.axaml b/src/Views/DiffView.axaml
index 04fff7a9..5ba5a211 100644
--- a/src/Views/DiffView.axaml
+++ b/src/Views/DiffView.axaml
@@ -13,26 +13,33 @@
-
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
-
+
+
+
+
+
@@ -42,11 +49,11 @@
Background="Transparent"
Padding="9,6"
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=UseSideBySideDiff, Mode=TwoWay}"
- IsVisible="{Binding IsTextDiff}"
+ IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.SideBySide}">
-
+
@@ -127,18 +134,18 @@
-
+
-
+
-
-