Skip to content

Commit ee82067

Browse files
committed
Merge branch 'release/8.40'
2 parents f7ef61f + 12deb1d commit ee82067

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

+1279
-354
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
4848
## Translation Status
4949

50-
[![en_US](https://img.shields.io/badge/en__US-100%25-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-100.00%25-brightgreen)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-99.14%25-yellow)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-98.42%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-99.14%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-100.00%25-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-100.00%25-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-100.00%25-brightgreen)](TRANSLATION.md)
50+
[![en_US](https://img.shields.io/badge/en__US-100%25-brightgreen)](TRANSLATION.md) [![de__DE](https://img.shields.io/badge/de__DE-99.86%25-yellow)](TRANSLATION.md) [![es__ES](https://img.shields.io/badge/es__ES-98.01%25-yellow)](TRANSLATION.md) [![fr__FR](https://img.shields.io/badge/fr__FR-97.44%25-yellow)](TRANSLATION.md) [![pt__BR](https://img.shields.io/badge/pt__BR-99.29%25-yellow)](TRANSLATION.md) [![ru__RU](https://img.shields.io/badge/ru__RU-100.00%25-brightgreen)](TRANSLATION.md) [![zh__CN](https://img.shields.io/badge/zh__CN-100.00%25-brightgreen)](TRANSLATION.md) [![zh__TW](https://img.shields.io/badge/zh__TW-100.00%25-brightgreen)](TRANSLATION.md)
5151

5252
## How to Use
5353

@@ -101,6 +101,7 @@ For **Linux** users:
101101
* `xdg-open` must be installed to support open native file manager.
102102
* Make sure [git-credential-manager](https://github.com/git-ecosystem/git-credential-manager/releases) is installed on your linux.
103103
* Maybe you need to set environment variable `AVALONIA_SCREEN_SCALE_FACTORS`. See https://github.com/AvaloniaUI/Avalonia/wiki/Configuring-X11-per-monitor-DPI.
104+
* If you can NOT type accented characters, such as `ê`, `ó`, try to set the environment variable `AVALONIA_IM_MODULE` to `none`.
104105

105106
## OpenAI
106107

TRANSLATION.md

+25-11
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
1-
### de_DE.axaml: 100.00%
1+
### de_DE.axaml: 99.86%
22

33

44
<details>
55
<summary>Missing Keys</summary>
66

7-
7+
- Text.Repository.FilterCommits
88

99
</details>
1010

11-
### es_ES.axaml: 99.14%
11+
### es_ES.axaml: 98.01%
1212

1313

1414
<details>
1515
<summary>Missing Keys</summary>
1616

17+
- Text.CommitDetail.Info.Children
18+
- Text.Fetch.Force
1719
- Text.Preference.Appearance.FontSize
1820
- Text.Preference.Appearance.FontSize.Default
1921
- Text.Preference.Appearance.FontSize.Editor
22+
- Text.Preference.General.ShowChildren
23+
- Text.Repository.FilterCommits
2024
- Text.Repository.FilterCommits.Default
2125
- Text.Repository.FilterCommits.Exclude
2226
- Text.Repository.FilterCommits.Include
27+
- Text.Repository.HistoriesOrder
28+
- Text.Repository.HistoriesOrder.ByDate
29+
- Text.Repository.HistoriesOrder.Topo
30+
- Text.SHALinkCM.NavigateTo
2331

2432
</details>
2533

26-
### fr_FR.axaml: 98.42%
34+
### fr_FR.axaml: 97.44%
2735

2836

2937
<details>
@@ -32,29 +40,35 @@
3240
- Text.CherryPick.AppendSourceToMessage
3341
- Text.CherryPick.Mainline.Tips
3442
- Text.CommitCM.CherryPickMultiple
43+
- Text.Fetch.Force
3544
- Text.Preference.Appearance.FontSize
3645
- Text.Preference.Appearance.FontSize.Default
3746
- Text.Preference.Appearance.FontSize.Editor
47+
- Text.Preference.General.ShowChildren
3848
- Text.Repository.CustomActions
49+
- Text.Repository.FilterCommits
3950
- Text.Repository.FilterCommits.Default
4051
- Text.Repository.FilterCommits.Exclude
4152
- Text.Repository.FilterCommits.Include
53+
- Text.Repository.HistoriesOrder
54+
- Text.Repository.HistoriesOrder.ByDate
55+
- Text.Repository.HistoriesOrder.Topo
4256
- Text.ScanRepositories
57+
- Text.SHALinkCM.NavigateTo
4358

4459
</details>
4560

46-
### pt_BR.axaml: 99.14%
61+
### pt_BR.axaml: 99.29%
4762

4863

4964
<details>
5065
<summary>Missing Keys</summary>
5166

52-
- Text.Preference.Appearance.FontSize
53-
- Text.Preference.Appearance.FontSize.Default
54-
- Text.Preference.Appearance.FontSize.Editor
55-
- Text.Repository.FilterCommits.Default
56-
- Text.Repository.FilterCommits.Exclude
57-
- Text.Repository.FilterCommits.Include
67+
- Text.CommitDetail.Info.Children
68+
- Text.Fetch.Force
69+
- Text.Preference.General.ShowChildren
70+
- Text.Repository.FilterCommits
71+
- Text.SHALinkCM.NavigateTo
5872

5973
</details>
6074

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.39
1+
8.40

src/Commands/Fetch.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace SourceGit.Commands
44
{
55
public class Fetch : Command
66
{
7-
public Fetch(string repo, string remote, bool noTags, bool prune, Action<string> outputHandler)
7+
public Fetch(string repo, string remote, bool noTags, bool prune, bool force, Action<string> outputHandler)
88
{
99
_outputHandler = outputHandler;
1010
WorkingDirectory = repo;
@@ -18,6 +18,9 @@ public Fetch(string repo, string remote, bool noTags, bool prune, Action<string>
1818
else
1919
Args += "--tags ";
2020

21+
if (force)
22+
Args += "--force ";
23+
2124
if (prune)
2225
Args += "--prune ";
2326

src/Commands/FormatPatch.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public FormatPatch(string repo, string commit, string saveTo)
66
{
77
WorkingDirectory = repo;
88
Context = repo;
9-
Args = $"format-patch {commit} -1 -o \"{saveTo}\"";
9+
Args = $"format-patch {commit} -1 --output=\"{saveTo}\"";
1010
}
1111
}
1212
}

src/Commands/QueryCommitChildren.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System.Collections.Generic;
2+
3+
namespace SourceGit.Commands
4+
{
5+
public class QueryCommitChildren : Command
6+
{
7+
public QueryCommitChildren(string repo, string commit, int max, string filters)
8+
{
9+
WorkingDirectory = repo;
10+
Context = repo;
11+
_commit = commit;
12+
if (string.IsNullOrEmpty(filters))
13+
filters = "--branches --remotes --tags";
14+
Args = $"rev-list -{max} --parents {filters} ^{commit}";
15+
}
16+
17+
public IEnumerable<string> Result()
18+
{
19+
Exec();
20+
return _lines;
21+
}
22+
23+
protected override void OnReadline(string line)
24+
{
25+
if (line.Contains(_commit))
26+
_lines.Add(line.Substring(0, 40));
27+
}
28+
29+
private string _commit;
30+
private List<string> _lines = new List<string>();
31+
}
32+
}

src/Commands/QueryCommits.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ namespace SourceGit.Commands
66
{
77
public class QueryCommits : Command
88
{
9-
public QueryCommits(string repo, string limits, bool needFindHead = true)
9+
public QueryCommits(string repo, bool useTopoOrder, string limits, bool needFindHead = true)
1010
{
11+
var order = useTopoOrder ? "--topo-order" : "--date-order";
12+
1113
WorkingDirectory = repo;
1214
Context = repo;
13-
Args = "log --date-order --no-show-signature --decorate=full --pretty=format:%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s " + limits;
15+
Args = $"log {order} --no-show-signature --decorate=full --pretty=format:%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s {limits}";
1416
_findFirstMerged = needFindHead;
1517
}
1618

src/Models/CommitTemplate.cs

+3-56
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Text.RegularExpressions;
1+
using System.Collections.Generic;
52

63
using CommunityToolkit.Mvvm.ComponentModel;
74

85
namespace SourceGit.Models
96
{
107
public partial class CommitTemplate : ObservableObject
118
{
12-
[GeneratedRegex(@"\$\{files(\:\d+)?\}")]
13-
private static partial Regex REG_COMMIT_TEMPLATE_FILES();
14-
159
public string Name
1610
{
1711
get => _name;
@@ -26,55 +20,8 @@ public string Content
2620

2721
public string Apply(Branch branch, List<Change> changes)
2822
{
29-
var content = _content
30-
.Replace("${files_num}", $"{changes.Count}")
31-
.Replace("${branch_name}", branch.Name);
32-
33-
var matches = REG_COMMIT_TEMPLATE_FILES().Matches(content);
34-
if (matches.Count == 0)
35-
return content;
36-
37-
var builder = new StringBuilder();
38-
var last = 0;
39-
for (int i = 0; i < matches.Count; i++)
40-
{
41-
var match = matches[i];
42-
if (!match.Success)
43-
continue;
44-
45-
var start = match.Index;
46-
if (start != last)
47-
builder.Append(content.Substring(last, start - last));
48-
49-
var countStr = match.Groups[1].Value;
50-
var paths = new List<string>();
51-
var more = string.Empty;
52-
if (countStr is { Length: <= 1 })
53-
{
54-
foreach (var c in changes)
55-
paths.Add(c.Path);
56-
}
57-
else
58-
{
59-
var count = Math.Min(int.Parse(countStr.Substring(1)), changes.Count);
60-
for (int j = 0; j < count; j++)
61-
paths.Add(changes[j].Path);
62-
63-
if (count < changes.Count)
64-
more = $" and {changes.Count - count} other files";
65-
}
66-
67-
builder.Append(string.Join(", ", paths));
68-
if (!string.IsNullOrEmpty(more))
69-
builder.Append(more);
70-
71-
last = start + match.Length;
72-
}
73-
74-
if (last != content.Length - 1)
75-
builder.Append(content.Substring(last));
76-
77-
return builder.ToString();
23+
var te = new TemplateEngine();
24+
return te.Eval(_content, branch, changes);
7825
}
7926

8027
private string _name = string.Empty;

src/Models/OpenAI.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Your only goal is to retrieve a single commit message.
150150
public OpenAIChatResponse Chat(string prompt, string question, CancellationToken cancellation)
151151
{
152152
var chat = new OpenAIChatRequest() { Model = Model };
153-
chat.AddMessage("system", prompt);
153+
chat.AddMessage("user", prompt);
154154
chat.AddMessage("user", question);
155155

156156
var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(60) };
@@ -169,12 +169,15 @@ public OpenAIChatResponse Chat(string prompt, string question, CancellationToken
169169
task.Wait(cancellation);
170170

171171
var rsp = task.Result;
172-
if (!rsp.IsSuccessStatusCode)
173-
throw new Exception($"AI service returns error code {rsp.StatusCode}");
174-
175172
var reader = rsp.Content.ReadAsStringAsync(cancellation);
176173
reader.Wait(cancellation);
177174

175+
var body = reader.Result;
176+
if (!rsp.IsSuccessStatusCode)
177+
{
178+
throw new Exception($"AI service returns error code {rsp.StatusCode}. Body: {body ?? string.Empty}");
179+
}
180+
178181
return JsonSerializer.Deserialize(reader.Result, JsonCodeGen.Default.OpenAIChatResponse);
179182
}
180183
catch

src/Models/Remote.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
using System;
2+
using System.IO;
23
using System.Text.RegularExpressions;
34

45
namespace SourceGit.Models
56
{
67
public partial class Remote
78
{
8-
[GeneratedRegex(@"^http[s]?://([\w\-]+@)?[\w\.\-]+(\:[0-9]+)?/[\w\-/~%]+/[\w\-\.%]+(\.git)?$")]
9+
[GeneratedRegex(@"^https?://([-a-zA-Z0-9:%._\+~#=]+@)?[-a-zA-Z0-9:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}(:[0-9]{1,5})?\b(/[-a-zA-Z0-9()@:%_\+.~#?&=]*)*(\.git)?$")]
910
private static partial Regex REG_HTTPS();
1011
[GeneratedRegex(@"^[\w\-]+@[\w\.\-]+(\:[0-9]+)?:[\w\-/~%]+/[\w\-\.%]+(\.git)?$")]
1112
private static partial Regex REG_SSH1();
@@ -49,7 +50,7 @@ public static bool IsValidURL(string url)
4950
return true;
5051
}
5152

52-
return false;
53+
return url.EndsWith(".git", StringComparison.Ordinal) && Directory.Exists(url);
5354
}
5455

5556
public bool TryGetVisitURL(out string url)

src/Models/RepositorySettings.cs

+6
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,8 @@ public string BuildHistoriesFilter()
320320
{
321321
builder.Append("--exclude=");
322322
builder.Append(b);
323+
builder.Append(" --decorate-refs-exclude=refs/heads/");
324+
builder.Append(b);
323325
builder.Append(' ');
324326
}
325327
}
@@ -332,6 +334,8 @@ public string BuildHistoriesFilter()
332334
{
333335
builder.Append("--exclude=");
334336
builder.Append(r);
337+
builder.Append(" --decorate-refs-exclude=refs/remotes/");
338+
builder.Append(r);
335339
builder.Append(' ');
336340
}
337341
}
@@ -344,6 +348,8 @@ public string BuildHistoriesFilter()
344348
{
345349
builder.Append("--exclude=");
346350
builder.Append(t);
351+
builder.Append(" --decorate-refs-exclude=refs/tags/");
352+
builder.Append(t);
347353
builder.Append(' ');
348354
}
349355
}

0 commit comments

Comments
 (0)