Skip to content

Commit 0bb502c

Browse files
committed
Merge branch 'release/v8.35'
2 parents efc14fe + f633c52 commit 0bb502c

Some content is hidden

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

74 files changed

+1065
-368
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ For **macOS** users:
8181
* Make sure your mac trusts all software from anywhere. For more information, search `spctl --master-disable`.
8282
* Make sure [git-credential-manager](https://github.com/git-ecosystem/git-credential-manager/releases) is installed on your mac.
8383
* You may need to run `sudo xattr -cr /Applications/SourceGit.app` to make sure the software works.
84-
* You may need to start this app from commandline by using `open -a SourceGit` to introduce the `PATH` environment variable from your shell.
8584

8685
For **Linux** users:
8786

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.34
1+
8.35

screenshots/theme_dark.png

44.9 KB
Loading

screenshots/theme_light.png

-199 KB
Loading

src/Commands/Add.cs

+15-15
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ namespace SourceGit.Commands
55
{
66
public class Add : Command
77
{
8-
public Add(string repo, List<Models.Change> changes = null)
8+
public Add(string repo, bool includeUntracked)
9+
{
10+
WorkingDirectory = repo;
11+
Context = repo;
12+
Args = includeUntracked ? "add ." : "add -u .";
13+
}
14+
15+
public Add(string repo, List<Models.Change> changes)
916
{
1017
WorkingDirectory = repo;
1118
Context = repo;
1219

13-
if (changes == null || changes.Count == 0)
14-
{
15-
Args = "add .";
16-
}
17-
else
20+
var builder = new StringBuilder();
21+
builder.Append("add --");
22+
foreach (var c in changes)
1823
{
19-
var builder = new StringBuilder();
20-
builder.Append("add --");
21-
foreach (var c in changes)
22-
{
23-
builder.Append(" \"");
24-
builder.Append(c.Path);
25-
builder.Append("\"");
26-
}
27-
Args = builder.ToString();
24+
builder.Append(" \"");
25+
builder.Append(c.Path);
26+
builder.Append("\"");
2827
}
28+
Args = builder.ToString();
2929
}
3030
}
3131
}

src/Commands/CherryPick.cs

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
{
33
public class CherryPick : Command
44
{
5-
public CherryPick(string repo, string commits, bool noCommit)
5+
public CherryPick(string repo, string commits, bool noCommit, bool appendSourceToMessage, string extraParams)
66
{
7-
var mode = noCommit ? "-n" : "--ff";
87
WorkingDirectory = repo;
98
Context = repo;
10-
Args = $"cherry-pick {mode} {commits}";
9+
10+
Args = "cherry-pick ";
11+
if (noCommit)
12+
Args += "-n ";
13+
if (appendSourceToMessage)
14+
Args += "-x ";
15+
if (!string.IsNullOrEmpty(extraParams))
16+
Args += $"{extraParams} ";
17+
Args += commits;
1118
}
1219
}
1320
}

src/Commands/Command.cs

-9
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,6 @@ private ProcessStartInfo CreateGitStartInfo()
195195
if (OperatingSystem.IsLinux())
196196
start.Environment.Add("LANG", "en_US.UTF-8");
197197

198-
// Fix sometimes `LSEnvironment` not working on macOS
199-
if (OperatingSystem.IsMacOS())
200-
{
201-
if (start.Environment.TryGetValue("PATH", out var path))
202-
start.Environment.Add("PATH", $"/opt/homebrew/bin:/opt/homebrew/sbin:{path}");
203-
else
204-
start.Environment.Add("PATH", "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin");
205-
}
206-
207198
// Force using this app as git editor.
208199
switch (Editor)
209200
{

src/Commands/Diff.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public Diff(string repo, Models.DiffOption opt, int unified, bool ignoreWhitespa
2424
Context = repo;
2525

2626
if (ignoreWhitespace)
27-
Args = $"diff --ignore-cr-at-eol --ignore-all-space --unified={unified} {opt}";
27+
Args = $"diff --patch --ignore-cr-at-eol --ignore-all-space --unified={unified} {opt}";
2828
else
29-
Args = $"diff --ignore-cr-at-eol --unified={unified} {opt}";
29+
Args = $"diff --patch --ignore-cr-at-eol --unified={unified} {opt}";
3030
}
3131

3232
public Models.DiffResult Result()

src/Commands/GC.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public GC(string repo, Action<string> outputHandler)
1010
WorkingDirectory = repo;
1111
Context = repo;
1212
TraitErrorAsOutput = true;
13-
Args = "gc --prune";
13+
Args = "gc --prune=now";
1414
}
1515

1616
protected override void OnReadline(string line)

src/Commands/QueryBranches.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public QueryBranches(string repo)
1414
{
1515
WorkingDirectory = repo;
1616
Context = repo;
17-
Args = "branch -l --all -v --format=\"%(refname)$%(objectname)$%(HEAD)$%(upstream)$%(upstream:trackshort)\"";
17+
Args = "branch -l --all -v --format=\"%(refname)%00%(objectname)%00%(HEAD)%00%(upstream)%00%(upstream:trackshort)\"";
1818
}
1919

2020
public List<Models.Branch> Result()
@@ -37,7 +37,7 @@ public QueryBranches(string repo)
3737

3838
private Models.Branch ParseLine(string line)
3939
{
40-
var parts = line.Split('$');
40+
var parts = line.Split('\0');
4141
if (parts.Length != 5)
4242
return null;
4343

src/Commands/QueryTags.cs

+16-27
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ public class QueryTags : Command
77
{
88
public QueryTags(string repo)
99
{
10+
_boundary = $"----- BOUNDARY OF TAGS {Guid.NewGuid()} -----";
11+
1012
Context = repo;
1113
WorkingDirectory = repo;
12-
Args = "tag -l --sort=-creatordate --format=\"$%(refname)$%(objectname)$%(*objectname)\"";
14+
Args = $"tag -l --sort=-creatordate --format=\"{_boundary}%(refname)%00%(objectname)%00%(*objectname)%00%(contents:subject)%0a%0a%(contents:body)\"";
1315
}
1416

1517
public List<Models.Tag> Result()
@@ -19,38 +21,25 @@ public QueryTags(string repo)
1921
if (!rs.IsSuccess)
2022
return tags;
2123

22-
var lines = rs.StdOut.Split('\n', StringSplitOptions.RemoveEmptyEntries);
23-
foreach (var line in lines)
24+
var records = rs.StdOut.Split(_boundary, StringSplitOptions.RemoveEmptyEntries);
25+
foreach (var record in records)
2426
{
25-
var tag = ParseLine(line);
26-
if (tag != null)
27-
tags.Add(tag);
28-
}
27+
var subs = record.Split('\0', StringSplitOptions.None);
28+
if (subs.Length != 4)
29+
continue;
2930

30-
return tags;
31-
}
32-
33-
private Models.Tag ParseLine(string line)
34-
{
35-
var subs = line.Split('$', StringSplitOptions.RemoveEmptyEntries);
36-
if (subs.Length == 2)
37-
{
38-
return new Models.Tag()
31+
var message = subs[3].Trim();
32+
tags.Add(new Models.Tag()
3933
{
4034
Name = subs[0].Substring(10),
41-
SHA = subs[1],
42-
};
43-
}
44-
else if (subs.Length == 3)
45-
{
46-
return new Models.Tag()
47-
{
48-
Name = subs[0].Substring(10),
49-
SHA = subs[2],
50-
};
35+
SHA = string.IsNullOrEmpty(subs[2]) ? subs[1] : subs[2],
36+
Message = string.IsNullOrEmpty(message) ? null : message,
37+
});
5138
}
5239

53-
return null;
40+
return tags;
5441
}
42+
43+
private string _boundary = string.Empty;
5544
}
5645
}

src/Commands/Stash.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public bool Push(List<Models.Change> changes, string message, bool onlyStaged)
2525
{
2626
foreach (var c in changes)
2727
pathsBuilder.Append($"\"{c.Path}\" ");
28-
28+
2929
var paths = pathsBuilder.ToString();
3030
Args = $"stash push --staged -m \"{message}\" -- {paths}";
3131
}
@@ -51,11 +51,11 @@ public bool Push(List<Models.Change> changes, string message, bool onlyStaged)
5151
new Add(WorkingDirectory, needAdd).Exec();
5252
needAdd.Clear();
5353
}
54-
54+
5555
var paths = pathsBuilder.ToString();
5656
Args = $"stash push -m \"{message}\" -- {paths}";
5757
}
58-
58+
5959
return Exec();
6060
}
6161

src/Models/Commit.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,19 @@ public static double OpacityForNotMerged
3131
public List<Decorator> Decorators { get; set; } = new List<Decorator>();
3232
public bool HasDecorators => Decorators.Count > 0;
3333

34-
public bool IsMerged { get; set; } = false;
35-
public Thickness Margin { get; set; } = new Thickness(0);
36-
3734
public string AuthorTimeStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
3835
public string CommitterTimeStr => DateTime.UnixEpoch.AddSeconds(CommitterTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss");
3936
public string AuthorTimeShortStr => DateTime.UnixEpoch.AddSeconds(AuthorTime).ToLocalTime().ToString("yyyy/MM/dd");
4037

38+
public bool IsMerged { get; set; } = false;
4139
public bool IsCommitterVisible => !Author.Equals(Committer) || AuthorTime != CommitterTime;
4240
public bool IsCurrentHead => Decorators.Find(x => x.Type is DecoratorType.CurrentBranchHead or DecoratorType.CurrentCommitHead) != null;
4341

42+
public int Color { get; set; } = 0;
4443
public double Opacity => IsMerged ? 1 : OpacityForNotMerged;
4544
public FontWeight FontWeight => IsCurrentHead ? FontWeight.Bold : FontWeight.Regular;
45+
public Thickness Margin { get; set; } = new Thickness(0);
46+
public IBrush Brush => CommitGraph.Pens[Color].Brush;
4647

4748
public void ParseDecorators(string data)
4849
{

src/Models/CommitGraph.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public static CommitGraph Parse(List<Commit> commits, bool firstParentOnlyEnable
186186
// Margins & merge state (used by Views.Histories).
187187
commit.IsMerged = isMerged;
188188
commit.Margin = new Thickness(Math.Max(offsetX, maxOffsetOld) + halfWidth + 2, 0, 0, 0);
189+
commit.Color = dotColor;
189190
}
190191

191192
// Deal with curves haven't ended yet.
@@ -326,14 +327,15 @@ private void Add(double x, double y)
326327
private static readonly List<Color> s_defaultPenColors = [
327328
Colors.Orange,
328329
Colors.ForestGreen,
329-
Colors.Gold,
330-
Colors.Magenta,
331-
Colors.Red,
332330
Colors.Gray,
333331
Colors.Turquoise,
334332
Colors.Olive,
333+
Colors.Magenta,
334+
Colors.Red,
335335
Colors.Khaki,
336336
Colors.Lime,
337+
Colors.RoyalBlue,
338+
Colors.Teal,
337339
];
338340
}
339341
}

src/Models/CommitTemplate.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public string Apply(List<Change> changes)
5555
{
5656
var count = Math.Min(int.Parse(countStr.Substring(1)), changes.Count);
5757
for (int j = 0; j < count; j++)
58-
paths.Add(changes[i].Path);
58+
paths.Add(changes[j].Path);
5959

6060
if (count < changes.Count)
6161
more = $" and {changes.Count - count} other files";

src/Models/ConventionalCommitType.cs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Collections.Generic;
2+
3+
namespace SourceGit.Models
4+
{
5+
public class ConventionalCommitType
6+
{
7+
public string Type { get; set; } = string.Empty;
8+
public string Description { get; set; } = string.Empty;
9+
10+
public static readonly List<ConventionalCommitType> Supported = new List<ConventionalCommitType>()
11+
{
12+
new ConventionalCommitType("feat", "Adding a new feature"),
13+
new ConventionalCommitType("fix", "Fixing a bug"),
14+
new ConventionalCommitType("docs", "Updating documentation"),
15+
new ConventionalCommitType("style", "Elements or code styles without changing the code logic"),
16+
new ConventionalCommitType("test", "Adding or updating tests"),
17+
new ConventionalCommitType("chore", "Making changes to the build process or auxiliary tools and libraries"),
18+
new ConventionalCommitType("revert", "Undoing a previous commit"),
19+
new ConventionalCommitType("refactor", "Restructuring code without changing its external behavior")
20+
};
21+
22+
public ConventionalCommitType(string type, string description)
23+
{
24+
Type = type;
25+
Description = description;
26+
}
27+
}
28+
}

src/Models/Remote.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ namespace SourceGit.Models
55
{
66
public partial class Remote
77
{
8-
[GeneratedRegex(@"^http[s]?://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-/~]+/[\w\-\.]+(\.git)?$")]
8+
[GeneratedRegex(@"^http[s]?://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-/~%]+/[\w\-\.%]+(\.git)?$")]
99
private static partial Regex REG_HTTPS();
10-
[GeneratedRegex(@"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:[\w\-/~]+/[\w\-\.]+(\.git)?$")]
10+
[GeneratedRegex(@"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:[\w\-/~%]+/[\w\-\.%]+(\.git)?$")]
1111
private static partial Regex REG_SSH1();
1212
[GeneratedRegex(@"^ssh://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-/~]+/[\w\-\.]+(\.git)?$")]
1313
private static partial Regex REG_SSH2();

src/Models/RepositorySettings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public string DefaultRemote
99
get;
1010
set;
1111
} = string.Empty;
12-
12+
1313
public DealWithLocalChanges DealWithLocalChangesOnCheckoutBranch
1414
{
1515
get;

src/Models/Tag.cs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public class Tag
44
{
55
public string Name { get; set; }
66
public string SHA { get; set; }
7+
public string Message { get; set; }
78
public bool IsFiltered { get; set; }
89
}
910
}

src/Native/MacOS.cs

+26
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.IO;
55
using System.Runtime.Versioning;
6+
using System.Text;
67

78
using Avalonia;
89

@@ -17,6 +18,31 @@ public void SetupApp(AppBuilder builder)
1718
{
1819
DisableDefaultApplicationMenuItems = true,
1920
});
21+
22+
{
23+
var startInfo = new ProcessStartInfo();
24+
startInfo.FileName = "zsh";
25+
startInfo.Arguments = "--login -c \"echo $PATH\"";
26+
startInfo.UseShellExecute = false;
27+
startInfo.CreateNoWindow = true;
28+
startInfo.RedirectStandardOutput = true;
29+
startInfo.StandardOutputEncoding = Encoding.UTF8;
30+
31+
try
32+
{
33+
var proc = new Process() { StartInfo = startInfo };
34+
proc.Start();
35+
var pathData = proc.StandardOutput.ReadToEnd();
36+
proc.WaitForExit();
37+
if (proc.ExitCode == 0)
38+
Environment.SetEnvironmentVariable("PATH", pathData);
39+
proc.Close();
40+
}
41+
catch
42+
{
43+
// Ignore error.
44+
}
45+
}
2046
}
2147

2248
public string FindGitExecutable()

0 commit comments

Comments
 (0)