Skip to content

Commit a123586

Browse files
committed
Merge branch 'release/v8.22'
2 parents 791b5bd + 0cbb8fc commit a123586

Some content is hidden

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

80 files changed

+1668
-1211
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
build-windows:
1111
name: Build Windows x64
12-
runs-on: windows-latest
12+
runs-on: windows-2019
1313
steps:
1414
- name: Checkout sources
1515
uses: actions/checkout@v4
@@ -30,7 +30,7 @@ jobs:
3030
path: publish
3131
build-macos-intel:
3232
name: Build macOS (Intel)
33-
runs-on: macos-latest
33+
runs-on: macos-13
3434
steps:
3535
- name: Checkout sources
3636
uses: actions/checkout@v4
@@ -76,7 +76,7 @@ jobs:
7676
path: sourcegit.osx-arm64.tar
7777
build-linux:
7878
name: Build Linux
79-
runs-on: ubuntu-latest
79+
runs-on: ubuntu-20.04
8080
steps:
8181
- name: Checkout sources
8282
uses: actions/checkout@v4

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Opensource Git GUI client.
4141

4242
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.
4343

44-
This software creates a folder `$"{System.Environment.SpecialFolder.ApplicationData}/SourceGit"`, which is platform-dependent, to store user settings, downloaded avatars and crash logs.
44+
This software creates a folder `$"{System.Environment.SpecialFolder.ApplicationData}/SourceGit"`, which is platform-dependent, to store user settings, downloaded avatars and crash logs.
4545

4646
| OS | PATH |
4747
|---------|-------------------------------------------------|
@@ -52,8 +52,16 @@ This software creates a folder `$"{System.Environment.SpecialFolder.ApplicationD
5252
For **Windows** users:
5353

5454
* **MSYS Git is NOT supported**. Please use official [Git for Windows](https://git-scm.com/download/win) instead.
55-
* You can install the latest stable by `winget install SourceGit`.
56-
- Note: `winget` will install this software as a commandline tool. You need run `SourceGit` from console or `Win+R` at the first time. Then you can add it to the taskbar.
55+
* You can install the latest stable from `winget` with follow commands:
56+
```shell
57+
winget install SourceGit
58+
```
59+
> `winget` will install this software as a commandline tool. You need run `SourceGit` from console or `Win+R` at the first time. Then you can add it to the taskbar.
60+
* You can install the latest stable by `scoope` with follow commands:
61+
```shell
62+
scoop bucket add extras
63+
scoop install sourcegit
64+
```
5765
* Portable versions can be found in [Releases](https://github.com/sourcegit-scm/sourcegit/releases/latest)
5866

5967
For **macOS** users:
@@ -68,7 +76,7 @@ For **Linux** users:
6876

6977
* `xdg-open` must be installed to support open native file manager.
7078
* Make sure [git-credential-manager](https://github.com/git-ecosystem/git-credential-manager/releases) is installed on your linux.
71-
* Maybe you need to set environment variable `AVALONIA_SCREEN_SCALE_FACTORS`. See https://github.com/AvaloniaUI/Avalonia/wiki/Configuring-X11-per-monitor-DPI.
79+
* Maybe you need to set environment variable `AVALONIA_SCREEN_SCALE_FACTORS`. See https://github.com/AvaloniaUI/Avalonia/wiki/Configuring-X11-per-monitor-DPI.
7280

7381
## External Tools
7482

@@ -82,23 +90,23 @@ This app supports open repository in external tools listed in the table below.
8290
| JetBrains Fleet | YES | YES | YES | FLEET_PATH |
8391
| Sublime Text | YES | YES | YES | SUBLIME_TEXT_PATH |
8492

85-
* You can set the given environment variable for special tool if it can NOT be found by this app automatically.
93+
* You can set the given environment variable for special tool if it can NOT be found by this app automatically.
8694
* Installing `JetBrains Toolbox` will help this app to find other JetBrains tools installed on your device.
8795
* On macOS, you may need to use `launchctl setenv` to make sure the app can read these environment variables.
8896

8997
## Screenshots
9098

9199
* Dark Theme
92100

93-
![Theme Dark](./screenshots/theme_dark.png)
101+
![Theme Dark](./screenshots/theme_dark.png)
94102

95103
* Light Theme
96104

97-
![Theme Light](./screenshots/theme_light.png)
105+
![Theme Light](./screenshots/theme_light.png)
98106

99-
* Custom Themes
107+
* Custom
100108

101-
You can find custom themes from [sourcegit-theme](https://github.com/sourcegit-scm/sourcegit-theme.git)
109+
You can find custom themes from [sourcegit-theme](https://github.com/sourcegit-scm/sourcegit-theme.git)
102110

103111
## Contributing
104112

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.21
1+
8.22

src/App.axaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ public static void SetTheme(string theme, string themeOverridesFile)
188188
else
189189
Models.CommitGraph.SetDefaultPens(overrides.GraphPenThickness);
190190

191+
Models.Commit.OpacityForNotMerged = overrides.OpacityForNotMergedCommits;
192+
191193
app.Resources.MergedDictionaries.Add(resDic);
192194
app._themeOverrides = resDic;
193195
}

src/Commands/Diff.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ public partial class Diff : Command
1414

1515
public Diff(string repo, Models.DiffOption opt, int unified)
1616
{
17+
_result.TextDiff = new Models.TextDiff() {
18+
Repo = repo,
19+
Option = opt,
20+
};
21+
1722
WorkingDirectory = repo;
1823
Context = repo;
1924
Args = $"diff --ignore-cr-at-eol --unified={unified} {opt}";
@@ -214,7 +219,7 @@ private void ProcessInlineHighlights()
214219
}
215220
}
216221

217-
private readonly Models.DiffResult _result = new Models.DiffResult() { TextDiff = new Models.TextDiff() };
222+
private readonly Models.DiffResult _result = new Models.DiffResult();
218223
private readonly List<Models.TextDiffLine> _deleted = new List<Models.TextDiffLine>();
219224
private readonly List<Models.TextDiffLine> _added = new List<Models.TextDiffLine>();
220225
private int _oldLine = 0;

src/Commands/GC.cs

Lines changed: 1 addition & 1 deletion
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";
13+
Args = "gc --prune";
1414
}
1515

1616
protected override void OnReadline(string line)

src/Commands/QueryBranches.cs

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,8 @@ public QueryBranches(string repo)
2424
{
2525
Exec();
2626

27-
foreach (var b in _branches)
28-
{
29-
if (b.IsLocal && !string.IsNullOrEmpty(b.UpstreamTrackStatus))
30-
{
31-
if (b.UpstreamTrackStatus == "=")
32-
{
33-
b.UpstreamTrackStatus = string.Empty;
34-
}
35-
else
36-
{
37-
b.UpstreamTrackStatus = ParseTrackStatus(b.Name, b.Upstream);
38-
}
39-
}
40-
}
27+
foreach (var b in _needQueryTrackStatus)
28+
b.TrackStatus = new QueryTrackStatus(WorkingDirectory, b.Name, b.Upstream).Result();
4129

4230
return _branches;
4331
}
@@ -84,35 +72,16 @@ protected override void OnReadline(string line)
8472
branch.Head = parts[1];
8573
branch.IsCurrent = parts[2] == "*";
8674
branch.Upstream = parts[3];
87-
branch.UpstreamTrackStatus = parts[4];
88-
_branches.Add(branch);
89-
}
9075

91-
private string ParseTrackStatus(string local, string upstream)
92-
{
93-
var cmd = new Command();
94-
cmd.WorkingDirectory = WorkingDirectory;
95-
cmd.Context = Context;
96-
cmd.Args = $"rev-list --left-right --count {local}...{upstream}";
97-
98-
var rs = cmd.ReadToEnd();
99-
if (!rs.IsSuccess)
100-
return string.Empty;
101-
102-
var match = REG_AHEAD_BEHIND().Match(rs.StdOut);
103-
if (!match.Success)
104-
return string.Empty;
76+
if (branch.IsLocal && !parts[4].Equals("=", StringComparison.Ordinal))
77+
_needQueryTrackStatus.Add(branch);
78+
else
79+
branch.TrackStatus = new Models.BranchTrackStatus();
10580

106-
var ahead = int.Parse(match.Groups[1].Value);
107-
var behind = int.Parse(match.Groups[2].Value);
108-
var track = "";
109-
if (ahead > 0)
110-
track += $"{ahead}↑";
111-
if (behind > 0)
112-
track += $" {behind}↓";
113-
return track.Trim();
81+
_branches.Add(branch);
11482
}
11583

11684
private readonly List<Models.Branch> _branches = new List<Models.Branch>();
85+
private List<Models.Branch> _needQueryTrackStatus = new List<Models.Branch>();
11786
}
11887
}

src/Commands/QueryCommits.cs

Lines changed: 20 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,29 @@ public QueryCommits(string repo, string limits, bool needFindHead = true)
1414
_findFirstMerged = needFindHead;
1515
}
1616

17-
public QueryCommits(string repo, int maxCount, string messageFilter)
17+
public QueryCommits(string repo, int maxCount, string messageFilter, bool isFile)
1818
{
19-
var argsBuilder = new StringBuilder();
20-
var words = messageFilter.Split(new[] { ' ', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries);
21-
foreach (var word in words)
19+
string search;
20+
if (isFile)
2221
{
23-
var escaped = word.Trim().Replace("\"", "\\\"", StringComparison.Ordinal);
24-
argsBuilder.Append($"--grep=\"{escaped}\" ");
22+
search = $"-- \"{messageFilter}\"";
23+
}
24+
else
25+
{
26+
var argsBuilder = new StringBuilder();
27+
var words = messageFilter.Split(new[] { ' ', '\t', '\r' }, StringSplitOptions.RemoveEmptyEntries);
28+
foreach (var word in words)
29+
{
30+
var escaped = word.Trim().Replace("\"", "\\\"", StringComparison.Ordinal);
31+
argsBuilder.Append($"--grep=\"{escaped}\" ");
32+
}
33+
argsBuilder.Append("--all-match -i");
34+
search = argsBuilder.ToString();
2535
}
26-
argsBuilder.Append("--all-match");
2736

2837
WorkingDirectory = repo;
2938
Context = repo;
30-
Args = $"log -{maxCount} --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 " + argsBuilder.ToString();
39+
Args = $"log -{maxCount} --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 --branches --remotes " + search;
3140
_findFirstMerged = false;
3241
}
3342

@@ -53,7 +62,9 @@ public QueryCommits(string repo, int maxCount, string messageFilter)
5362
ParseParent(line);
5463
break;
5564
case 2:
56-
ParseDecorators(line);
65+
_current.ParseDecorators(line);
66+
if (_current.IsMerged && !_isHeadFounded)
67+
_isHeadFounded = true;
5768
break;
5869
case 3:
5970
_current.Author = Models.User.FindOrAdd(line);
@@ -104,74 +115,6 @@ private void ParseParent(string data)
104115
_current.Parents.Add(data.Substring(idx + 1));
105116
}
106117

107-
private void ParseDecorators(string data)
108-
{
109-
if (data.Length < 3)
110-
return;
111-
112-
var subs = data.Split(',', StringSplitOptions.RemoveEmptyEntries);
113-
foreach (var sub in subs)
114-
{
115-
var d = sub.Trim();
116-
if (d.EndsWith("/HEAD", StringComparison.Ordinal))
117-
continue;
118-
119-
if (d.StartsWith("tag: refs/tags/", StringComparison.Ordinal))
120-
{
121-
_current.Decorators.Add(new Models.Decorator()
122-
{
123-
Type = Models.DecoratorType.Tag,
124-
Name = d.Substring(15),
125-
});
126-
}
127-
else if (d.StartsWith("HEAD -> refs/heads/", StringComparison.Ordinal))
128-
{
129-
_current.IsMerged = true;
130-
_current.Decorators.Add(new Models.Decorator()
131-
{
132-
Type = Models.DecoratorType.CurrentBranchHead,
133-
Name = d.Substring(19),
134-
});
135-
}
136-
else if (d.Equals("HEAD"))
137-
{
138-
_current.IsMerged = true;
139-
_current.Decorators.Add(new Models.Decorator()
140-
{
141-
Type = Models.DecoratorType.CurrentCommitHead,
142-
Name = d,
143-
});
144-
}
145-
else if (d.StartsWith("refs/heads/", StringComparison.Ordinal))
146-
{
147-
_current.Decorators.Add(new Models.Decorator()
148-
{
149-
Type = Models.DecoratorType.LocalBranchHead,
150-
Name = d.Substring(11),
151-
});
152-
}
153-
else if (d.StartsWith("refs/remotes/", StringComparison.Ordinal))
154-
{
155-
_current.Decorators.Add(new Models.Decorator()
156-
{
157-
Type = Models.DecoratorType.RemoteBranchHead,
158-
Name = d.Substring(13),
159-
});
160-
}
161-
}
162-
163-
_current.Decorators.Sort((l, r) =>
164-
{
165-
if (l.Type != r.Type)
166-
return (int)l.Type - (int)r.Type;
167-
else
168-
return string.Compare(l.Name, r.Name, StringComparison.Ordinal);
169-
});
170-
171-
if (_current.IsMerged && !_isHeadFounded)
172-
_isHeadFounded = true;
173-
}
174-
175118
private void MarkFirstMerged()
176119
{
177120
Args = $"log --since=\"{_commits[^1].CommitterTimeStr}\" --format=\"%H\"";

0 commit comments

Comments
 (0)