mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
feature: supports toggle --force
option for git fetch
command (#721)
* Background auto fetch will always disable this option * This option is not add to pull operation Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
c1c743f2ff
commit
153a1f30b2
9 changed files with 26 additions and 7 deletions
|
@ -4,7 +4,7 @@ namespace SourceGit.Commands
|
||||||
{
|
{
|
||||||
public class Fetch : Command
|
public class Fetch : Command
|
||||||
{
|
{
|
||||||
public Fetch(string repo, string remote, bool noTags, bool prune, Action<string> outputHandler)
|
public Fetch(string repo, string remote, bool noTags, bool prune, bool force, Action<string> outputHandler)
|
||||||
{
|
{
|
||||||
_outputHandler = outputHandler;
|
_outputHandler = outputHandler;
|
||||||
WorkingDirectory = repo;
|
WorkingDirectory = repo;
|
||||||
|
@ -18,6 +18,9 @@ namespace SourceGit.Commands
|
||||||
else
|
else
|
||||||
Args += "--tags ";
|
Args += "--tags ";
|
||||||
|
|
||||||
|
if (force)
|
||||||
|
Args += "--force ";
|
||||||
|
|
||||||
if (prune)
|
if (prune)
|
||||||
Args += "--prune ";
|
Args += "--prune ";
|
||||||
|
|
||||||
|
|
|
@ -268,6 +268,7 @@
|
||||||
<x:String x:Key="Text.FastForwardWithoutCheck" xml:space="preserve">Fast-Forward (without checkout)</x:String>
|
<x:String x:Key="Text.FastForwardWithoutCheck" xml:space="preserve">Fast-Forward (without checkout)</x:String>
|
||||||
<x:String x:Key="Text.Fetch" xml:space="preserve">Fetch</x:String>
|
<x:String x:Key="Text.Fetch" xml:space="preserve">Fetch</x:String>
|
||||||
<x:String x:Key="Text.Fetch.AllRemotes" xml:space="preserve">Fetch all remotes</x:String>
|
<x:String x:Key="Text.Fetch.AllRemotes" xml:space="preserve">Fetch all remotes</x:String>
|
||||||
|
<x:String x:Key="Text.Fetch.Force" xml:space="preserve">Enable '--force' option</x:String>
|
||||||
<x:String x:Key="Text.Fetch.NoTags" xml:space="preserve">Fetch without tags</x:String>
|
<x:String x:Key="Text.Fetch.NoTags" xml:space="preserve">Fetch without tags</x:String>
|
||||||
<x:String x:Key="Text.Fetch.Remote" xml:space="preserve">Remote:</x:String>
|
<x:String x:Key="Text.Fetch.Remote" xml:space="preserve">Remote:</x:String>
|
||||||
<x:String x:Key="Text.Fetch.Title" xml:space="preserve">Fetch Remote Changes</x:String>
|
<x:String x:Key="Text.Fetch.Title" xml:space="preserve">Fetch Remote Changes</x:String>
|
||||||
|
|
|
@ -271,6 +271,7 @@
|
||||||
<x:String x:Key="Text.FastForwardWithoutCheck" xml:space="preserve">快进(fast-forward,无需checkout)</x:String>
|
<x:String x:Key="Text.FastForwardWithoutCheck" xml:space="preserve">快进(fast-forward,无需checkout)</x:String>
|
||||||
<x:String x:Key="Text.Fetch" xml:space="preserve">拉取(fetch)</x:String>
|
<x:String x:Key="Text.Fetch" xml:space="preserve">拉取(fetch)</x:String>
|
||||||
<x:String x:Key="Text.Fetch.AllRemotes" xml:space="preserve">拉取所有的远程仓库</x:String>
|
<x:String x:Key="Text.Fetch.AllRemotes" xml:space="preserve">拉取所有的远程仓库</x:String>
|
||||||
|
<x:String x:Key="Text.Fetch.Force" xml:space="preserve">启用 --force 选项</x:String>
|
||||||
<x:String x:Key="Text.Fetch.NoTags" xml:space="preserve">不拉取远程标签</x:String>
|
<x:String x:Key="Text.Fetch.NoTags" xml:space="preserve">不拉取远程标签</x:String>
|
||||||
<x:String x:Key="Text.Fetch.Remote" xml:space="preserve">远程仓库 :</x:String>
|
<x:String x:Key="Text.Fetch.Remote" xml:space="preserve">远程仓库 :</x:String>
|
||||||
<x:String x:Key="Text.Fetch.Title" xml:space="preserve">拉取远程仓库内容</x:String>
|
<x:String x:Key="Text.Fetch.Title" xml:space="preserve">拉取远程仓库内容</x:String>
|
||||||
|
|
|
@ -271,6 +271,7 @@
|
||||||
<x:String x:Key="Text.FastForwardWithoutCheck" xml:space="preserve">快進 (fast-forward,無需 checkout)</x:String>
|
<x:String x:Key="Text.FastForwardWithoutCheck" xml:space="preserve">快進 (fast-forward,無需 checkout)</x:String>
|
||||||
<x:String x:Key="Text.Fetch" xml:space="preserve">提取 (fetch)</x:String>
|
<x:String x:Key="Text.Fetch" xml:space="preserve">提取 (fetch)</x:String>
|
||||||
<x:String x:Key="Text.Fetch.AllRemotes" xml:space="preserve">提取所有的遠端存放庫</x:String>
|
<x:String x:Key="Text.Fetch.AllRemotes" xml:space="preserve">提取所有的遠端存放庫</x:String>
|
||||||
|
<x:String x:Key="Text.Fetch.Force" xml:space="preserve">啟用 [--force] 選項</x:String>
|
||||||
<x:String x:Key="Text.Fetch.NoTags" xml:space="preserve">不提取遠端標籤</x:String>
|
<x:String x:Key="Text.Fetch.NoTags" xml:space="preserve">不提取遠端標籤</x:String>
|
||||||
<x:String x:Key="Text.Fetch.Remote" xml:space="preserve">遠端存放庫:</x:String>
|
<x:String x:Key="Text.Fetch.Remote" xml:space="preserve">遠端存放庫:</x:String>
|
||||||
<x:String x:Key="Text.Fetch.Title" xml:space="preserve">提取遠端存放庫內容</x:String>
|
<x:String x:Key="Text.Fetch.Title" xml:space="preserve">提取遠端存放庫內容</x:String>
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
SetProgressDescription("Fetching from added remote ...");
|
SetProgressDescription("Fetching from added remote ...");
|
||||||
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null);
|
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null);
|
||||||
new Commands.Fetch(_repo.FullPath, _name, false, false, SetProgressDescription).Exec();
|
new Commands.Fetch(_repo.FullPath, _name, false, false, false, SetProgressDescription).Exec();
|
||||||
}
|
}
|
||||||
CallUIThread(() =>
|
CallUIThread(() =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,10 +28,17 @@ namespace SourceGit.ViewModels
|
||||||
set => _repo.Settings.FetchWithoutTags = value;
|
set => _repo.Settings.FetchWithoutTags = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Force
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
public Fetch(Repository repo, Models.Remote preferedRemote = null)
|
public Fetch(Repository repo, Models.Remote preferedRemote = null)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_fetchAllRemotes = preferedRemote == null;
|
_fetchAllRemotes = preferedRemote == null;
|
||||||
|
Force = false;
|
||||||
SelectedRemote = preferedRemote != null ? preferedRemote : _repo.Remotes[0];
|
SelectedRemote = preferedRemote != null ? preferedRemote : _repo.Remotes[0];
|
||||||
View = new Views.Fetch() { DataContext = this };
|
View = new Views.Fetch() { DataContext = this };
|
||||||
}
|
}
|
||||||
|
@ -42,6 +49,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
var notags = _repo.Settings.FetchWithoutTags;
|
var notags = _repo.Settings.FetchWithoutTags;
|
||||||
var prune = _repo.Settings.EnablePruneOnFetch;
|
var prune = _repo.Settings.EnablePruneOnFetch;
|
||||||
|
var force = Force;
|
||||||
return Task.Run(() =>
|
return Task.Run(() =>
|
||||||
{
|
{
|
||||||
if (FetchAllRemotes)
|
if (FetchAllRemotes)
|
||||||
|
@ -49,13 +57,13 @@ namespace SourceGit.ViewModels
|
||||||
foreach (var remote in _repo.Remotes)
|
foreach (var remote in _repo.Remotes)
|
||||||
{
|
{
|
||||||
SetProgressDescription($"Fetching remote: {remote.Name}");
|
SetProgressDescription($"Fetching remote: {remote.Name}");
|
||||||
new Commands.Fetch(_repo.FullPath, remote.Name, notags, prune, SetProgressDescription).Exec();
|
new Commands.Fetch(_repo.FullPath, remote.Name, notags, prune, force, SetProgressDescription).Exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetProgressDescription($"Fetching remote: {SelectedRemote.Name}");
|
SetProgressDescription($"Fetching remote: {SelectedRemote.Name}");
|
||||||
new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, prune, SetProgressDescription).Exec();
|
new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, prune, force, SetProgressDescription).Exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
CallUIThread(() =>
|
CallUIThread(() =>
|
||||||
|
|
|
@ -152,6 +152,7 @@ namespace SourceGit.ViewModels
|
||||||
_selectedRemote.Name,
|
_selectedRemote.Name,
|
||||||
NoTags,
|
NoTags,
|
||||||
_repo.Settings.EnablePruneOnFetch,
|
_repo.Settings.EnablePruneOnFetch,
|
||||||
|
false,
|
||||||
SetProgressDescription).Exec();
|
SetProgressDescription).Exec();
|
||||||
|
|
||||||
if (!rs)
|
if (!rs)
|
||||||
|
|
|
@ -2194,7 +2194,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
IsAutoFetching = true;
|
IsAutoFetching = true;
|
||||||
Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching)));
|
Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching)));
|
||||||
new Commands.Fetch(_fullpath, "--all", false, _settings.EnablePruneOnFetch, null) { RaiseError = false }.Exec();
|
new Commands.Fetch(_fullpath, "--all", false, _settings.EnablePruneOnFetch, false, null) { RaiseError = false }.Exec();
|
||||||
_lastFetchTime = DateTime.Now;
|
_lastFetchTime = DateTime.Now;
|
||||||
IsAutoFetching = false;
|
IsAutoFetching = false;
|
||||||
Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching)));
|
Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching)));
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<TextBlock FontSize="18"
|
<TextBlock FontSize="18"
|
||||||
Classes="bold"
|
Classes="bold"
|
||||||
Text="{DynamicResource Text.Fetch.Title}"/>
|
Text="{DynamicResource Text.Fetch.Title}"/>
|
||||||
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32" ColumnDefinitions="120,*">
|
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32" ColumnDefinitions="120,*">
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
|
@ -33,10 +33,14 @@
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
|
|
||||||
<CheckBox Grid.Row="1" Grid.Column="1"
|
<CheckBox Grid.Row="1" Grid.Column="1"
|
||||||
|
Content="{DynamicResource Text.Fetch.Force}"
|
||||||
|
IsChecked="{Binding Force, Mode=TwoWay}"/>
|
||||||
|
|
||||||
|
<CheckBox Grid.Row="2" Grid.Column="1"
|
||||||
Content="{DynamicResource Text.Fetch.AllRemotes}"
|
Content="{DynamicResource Text.Fetch.AllRemotes}"
|
||||||
IsChecked="{Binding FetchAllRemotes, Mode=TwoWay}"/>
|
IsChecked="{Binding FetchAllRemotes, Mode=TwoWay}"/>
|
||||||
|
|
||||||
<CheckBox Grid.Row="2" Grid.Column="1"
|
<CheckBox Grid.Row="3" Grid.Column="1"
|
||||||
Content="{DynamicResource Text.Fetch.NoTags}"
|
Content="{DynamicResource Text.Fetch.NoTags}"
|
||||||
IsChecked="{Binding NoTags, Mode=TwoWay}"/>
|
IsChecked="{Binding NoTags, Mode=TwoWay}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
Loading…
Reference in a new issue