Skip to content

Commit 4612cec

Browse files
committed
code_review: PR (#288)
* add missing translations and it's no need to add `OnPull` suffix since it already has a prefix `Text.Pull.` * when enable fetching all branches of selected remote, use merge/rebase command instead of pull * re-arrange orders of options in pull popup panel * default enable `Fetch all branches`
1 parent 924a2ce commit 4612cec

File tree

6 files changed

+33
-13
lines changed

6 files changed

+33
-13
lines changed

src/Models/RepositorySettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public bool FetchAllBranchesOnPull
3838
{
3939
get;
4040
set;
41-
} = false;
41+
} = true;
4242

4343
public bool PushAllTags
4444
{

src/Resources/Locales/en_US.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@
403403
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">Prune worktree information in `$GIT_DIR/worktrees`</x:String>
404404
<x:String x:Key="Text.Pull" xml:space="preserve">Pull</x:String>
405405
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">Branch:</x:String>
406-
<x:String x:Key="Text.Pull.FetchAllBranchesOnPull" xml:space="preserve">Fetch all branches on pull</x:String>
406+
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">Fetch all branches</x:String>
407407
<x:String x:Key="Text.Pull.Into" xml:space="preserve">Into:</x:String>
408408
<x:String x:Key="Text.Pull.LocalChanges" xml:space="preserve">Local Changes:</x:String>
409409
<x:String x:Key="Text.Pull.LocalChanges.Discard" xml:space="preserve">Discard</x:String>

src/Resources/Locales/zh_CN.axaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@
406406
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">清理在`$GIT_DIR/worktrees`中的无效工作树信息</x:String>
407407
<x:String x:Key="Text.Pull" xml:space="preserve">拉回(pull)</x:String>
408408
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">拉取分支 :</x:String>
409+
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">拉取远程中的所有分支变更</x:String>
409410
<x:String x:Key="Text.Pull.Into" xml:space="preserve">本地分支 :</x:String>
410411
<x:String x:Key="Text.Pull.LocalChanges" xml:space="preserve">未提交更改 :</x:String>
411412
<x:String x:Key="Text.Pull.LocalChanges.Discard" 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
@@ -406,6 +406,7 @@
406406
<x:String x:Key="Text.PruneWorktrees.Tip" xml:space="preserve">清理在`$GIT_DIR/worktrees`中的無效工作樹資訊</x:String>
407407
<x:String x:Key="Text.Pull" xml:space="preserve">拉回(pull)</x:String>
408408
<x:String x:Key="Text.Pull.Branch" xml:space="preserve">拉取分支 :</x:String>
409+
<x:String x:Key="Text.Pull.FetchAllBranches" xml:space="preserve">拉取遠端中的所有分支變更</x:String>
409410
<x:String x:Key="Text.Pull.Into" xml:space="preserve">本地分支 :</x:String>
410411
<x:String x:Key="Text.Pull.LocalChanges" xml:space="preserve">未提交更改 :</x:String>
411412
<x:String x:Key="Text.Pull.LocalChanges.Discard" xml:space="preserve">丟棄更改</x:String>

src/ViewModels/Pull.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public bool UseRebase
5959
set => _repo.Settings.PreferRebaseInsteadOfMerge = value;
6060
}
6161

62-
public bool FetchAllBranchesOnPull
62+
public bool FetchAllBranches
6363
{
6464
get => _repo.Settings.FetchAllBranchesOnPull;
6565
set => _repo.Settings.FetchAllBranchesOnPull = value;
@@ -157,14 +157,32 @@ public override Task<bool> Sure()
157157
}
158158
}
159159

160-
if (FetchAllBranchesOnPull)
160+
var rs = false;
161+
if (FetchAllBranches)
161162
{
162163
SetProgressDescription($"Fetching remote: {_selectedRemote.Name}...");
163-
new Commands.Fetch(_repo.FullPath, _selectedRemote.Name, false, NoTags, SetProgressDescription).Exec();
164+
rs = new Commands.Fetch(_repo.FullPath, _selectedRemote.Name, false, NoTags, SetProgressDescription).Exec();
165+
if (!rs)
166+
return false;
167+
168+
// Use merge/rebase instead of pull as fetch is done manually.
169+
if (UseRebase)
170+
{
171+
SetProgressDescription($"Rebase {_current.Name} on {_selectedBranch.FriendlyName} ...");
172+
rs = new Commands.Rebase(_repo.FullPath, _selectedBranch.FriendlyName, false).Exec();
173+
}
174+
else
175+
{
176+
SetProgressDescription($"Merge {_selectedBranch.FriendlyName} into {_current.Name} ...");
177+
rs = new Commands.Merge(_repo.FullPath, _selectedBranch.FriendlyName, "", SetProgressDescription).Exec();
178+
}
179+
}
180+
else
181+
{
182+
SetProgressDescription($"Pull {_selectedRemote.Name}/{_selectedBranch.Name}...");
183+
rs = new Commands.Pull(_repo.FullPath, _selectedRemote.Name, _selectedBranch.Name, UseRebase, NoTags, SetProgressDescription).Exec();
164184
}
165185

166-
SetProgressDescription($"Pull {_selectedRemote.Name}/{_selectedBranch.Name}...");
167-
var rs = new Commands.Pull(_repo.FullPath, _selectedRemote.Name, _selectedBranch.Name, UseRebase, NoTags, SetProgressDescription).Exec();
168186
if (rs && needPopStash)
169187
{
170188
SetProgressDescription("Re-apply local changes...");

src/Views/Pull.axaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,18 @@
8383
Margin="8,0,0,0"
8484
IsChecked="{Binding PreAction, Mode=TwoWay, Converter={StaticResource EnumToBoolConverter}, ConverterParameter={x:Static m:DealWithLocalChanges.Discard}}"/>
8585
</StackPanel>
86-
86+
8787
<CheckBox Grid.Row="4" Grid.Column="1"
88-
Content="{DynamicResource Text.Pull.UseRebase}"
89-
IsChecked="{Binding UseRebase, Mode=TwoWay}"/>
88+
Content="{DynamicResource Text.Pull.FetchAllBranches}"
89+
IsChecked="{Binding FetchAllBranches, Mode=TwoWay}"/>
9090

9191
<CheckBox Grid.Row="5" Grid.Column="1"
9292
Content="{DynamicResource Text.Pull.NoTags}"
9393
IsChecked="{Binding NoTags, Mode=TwoWay}"/>
94-
94+
9595
<CheckBox Grid.Row="6" Grid.Column="1"
96-
Content="{DynamicResource Text.Pull.FetchAllBranchesOnPull}"
97-
IsChecked="{Binding FetchAllBranchesOnPull, Mode=TwoWay}"/>
96+
Content="{DynamicResource Text.Pull.UseRebase}"
97+
IsChecked="{Binding UseRebase, Mode=TwoWay}"/>
9898
</Grid>
9999
</StackPanel>
100100
</UserControl>

0 commit comments

Comments
 (0)