Skip to content

Commit 987f4c0

Browse files
committed
code_review: PR #2200
- Use `string extra` parameter instead of adding a new `bool threeWayMerge` in `Commands.Apply`. - Add missing translations for Chinese Signed-off-by: leo <longshuang@msn.cn>
1 parent 71e34ec commit 987f4c0

File tree

7 files changed

+12
-13
lines changed

7 files changed

+12
-13
lines changed

src/Commands/Apply.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace SourceGit.Commands
44
{
55
public class Apply : Command
66
{
7-
public Apply(string repo, string file, bool ignoreWhitespace, string whitespaceMode, bool threeWayMerge, string extra)
7+
public Apply(string repo, string file, bool ignoreWhitespace, string whitespaceMode, string extra)
88
{
99
WorkingDirectory = repo;
1010
Context = repo;
@@ -17,9 +17,6 @@ public Apply(string repo, string file, bool ignoreWhitespace, string whitespaceM
1717
else
1818
builder.Append("--whitespace=").Append(whitespaceMode).Append(' ');
1919

20-
if (threeWayMerge)
21-
builder.Append("--3way ");
22-
2320
if (!string.IsNullOrEmpty(extra))
2421
builder.Append(extra).Append(' ');
2522

src/Resources/Locales/en_US.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
<x:String x:Key="Text.App.Hide" xml:space="preserve">Hide SourceGit</x:String>
2525
<x:String x:Key="Text.App.ShowAll" xml:space="preserve">Show All</x:String>
2626
<x:String x:Key="Text.Apply" xml:space="preserve">Patch</x:String>
27+
<x:String x:Key="Text.Apply.3Way" xml:space="preserve">3-Way Merge</x:String>
2728
<x:String x:Key="Text.Apply.File" xml:space="preserve">Patch File:</x:String>
2829
<x:String x:Key="Text.Apply.File.Placeholder" xml:space="preserve">Select .patch file to apply</x:String>
2930
<x:String x:Key="Text.Apply.IgnoreWS" xml:space="preserve">Ignore whitespace changes</x:String>
30-
<x:String x:Key="Text.Apply.3Way" xml:space="preserve">3-Way Merge</x:String>
3131
<x:String x:Key="Text.Apply.Title" xml:space="preserve">Apply Patch</x:String>
3232
<x:String x:Key="Text.Apply.WS" xml:space="preserve">Whitespace:</x:String>
3333
<x:String x:Key="Text.ApplyStash" xml:space="preserve">Apply Stash</x:String>

src/Resources/Locales/zh_CN.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<x:String x:Key="Text.App.Hide" xml:space="preserve">隐藏 SourceGit</x:String>
2929
<x:String x:Key="Text.App.ShowAll" xml:space="preserve">显示所有窗口</x:String>
3030
<x:String x:Key="Text.Apply" xml:space="preserve">应用补丁(apply)</x:String>
31+
<x:String x:Key="Text.Apply.3Way" xml:space="preserve">尝试三路合并</x:String>
3132
<x:String x:Key="Text.Apply.File" xml:space="preserve">补丁文件 :</x:String>
3233
<x:String x:Key="Text.Apply.File.Placeholder" xml:space="preserve">选择补丁文件</x:String>
3334
<x:String x:Key="Text.Apply.IgnoreWS" xml:space="preserve">忽略空白符号</x:String>

src/Resources/Locales/zh_TW.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<x:String x:Key="Text.App.Hide" xml:space="preserve">隱藏 SourceGit</x:String>
2929
<x:String x:Key="Text.App.ShowAll" xml:space="preserve">顯示所有</x:String>
3030
<x:String x:Key="Text.Apply" xml:space="preserve">套用修補檔 (apply patch)</x:String>
31+
<x:String x:Key="Text.Apply.3Way" xml:space="preserve">嘗試三路合併</x:String>
3132
<x:String x:Key="Text.Apply.File" xml:space="preserve">修補檔:</x:String>
3233
<x:String x:Key="Text.Apply.File.Placeholder" xml:space="preserve">選擇修補檔</x:String>
3334
<x:String x:Key="Text.Apply.IgnoreWS" xml:space="preserve">忽略空白符號</x:String>

src/ViewModels/Apply.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public Models.ApplyWhiteSpaceMode SelectedWhiteSpaceMode
2828

2929
public bool ThreeWayMerge
3030
{
31-
get => _threeWayMerge;
32-
set => SetProperty(ref _threeWayMerge, value);
31+
get;
32+
set;
3333
}
3434

3535
public Apply(Repository repo)
@@ -55,7 +55,8 @@ public override async Task<bool> Sure()
5555
var log = _repo.CreateLog("Apply Patch");
5656
Use(log);
5757

58-
var succ = await new Commands.Apply(_repo.FullPath, _patchFile, _ignoreWhiteSpace, SelectedWhiteSpaceMode.Arg, _threeWayMerge, null)
58+
var extra = ThreeWayMerge ? "--3way" : string.Empty;
59+
var succ = await new Commands.Apply(_repo.FullPath, _patchFile, _ignoreWhiteSpace, SelectedWhiteSpaceMode.Arg, extra)
5960
.Use(log)
6061
.ExecAsync();
6162

@@ -66,6 +67,5 @@ public override async Task<bool> Sure()
6667
private readonly Repository _repo = null;
6768
private string _patchFile = string.Empty;
6869
private bool _ignoreWhiteSpace = true;
69-
private bool _threeWayMerge = false;
7070
}
7171
}

src/ViewModels/StashesPage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public async Task ApplySelectedChanges(List<Models.Change> changes)
253253
return;
254254

255255
var log = _repo.CreateLog($"Apply changes from '{_selectedStash.Name}'");
256-
await new Commands.Apply(_repo.FullPath, saveTo, true, string.Empty, false, string.Empty)
256+
await new Commands.Apply(_repo.FullPath, saveTo, true, string.Empty, string.Empty)
257257
.Use(log)
258258
.ExecAsync();
259259

src/Views/TextDiffView.axaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ private async void OnStageChunk(object _1, RoutedEventArgs _2)
15081508
diff.GeneratePatchFromSelectionSingleSide(change, treeGuid, selection, false, chunk.IsOldSide, tmpFile);
15091509
}
15101510

1511-
await new Commands.Apply(repo.FullPath, tmpFile, true, "nowarn", false, "--cache --index").ExecAsync();
1511+
await new Commands.Apply(repo.FullPath, tmpFile, true, "nowarn", "--cache --index").ExecAsync();
15121512
File.Delete(tmpFile);
15131513

15141514
vm.BlockNavigation.UpdateByChunk(chunk);
@@ -1539,7 +1539,7 @@ private async void OnUnstageChunk(object _1, RoutedEventArgs _2)
15391539
else
15401540
diff.GeneratePatchFromSelectionSingleSide(change, treeGuid, selection, true, chunk.IsOldSide, tmpFile);
15411541

1542-
await new Commands.Apply(repo.FullPath, tmpFile, true, "nowarn", false, "--cache --index --reverse").ExecAsync();
1542+
await new Commands.Apply(repo.FullPath, tmpFile, true, "nowarn", "--cache --index --reverse").ExecAsync();
15431543
File.Delete(tmpFile);
15441544

15451545
vm.BlockNavigation.UpdateByChunk(chunk);
@@ -1577,7 +1577,7 @@ private async void OnDiscardChunk(object _1, RoutedEventArgs _2)
15771577
diff.GeneratePatchFromSelectionSingleSide(change, treeGuid, selection, true, chunk.IsOldSide, tmpFile);
15781578
}
15791579

1580-
await new Commands.Apply(repo.FullPath, tmpFile, true, "nowarn", false, "--reverse").ExecAsync();
1580+
await new Commands.Apply(repo.FullPath, tmpFile, true, "nowarn", "--reverse").ExecAsync();
15811581
File.Delete(tmpFile);
15821582

15831583
vm.BlockNavigation.UpdateByChunk(chunk);

0 commit comments

Comments
 (0)