Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Commands/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace SourceGit.Commands
{
public class Fetch : Command
{
public Fetch(string repo, string remote, bool noTags, bool force, Action<string> outputHandler)
public Fetch(string repo, string remote, bool noTags, bool force, bool prune, Action<string> outputHandler)
{
_outputHandler = outputHandler;
WorkingDirectory = repo;
Expand All @@ -21,6 +21,9 @@ public Fetch(string repo, string remote, bool noTags, bool force, Action<string>
if (force)
Args += "--force ";

if (prune)
Args += "--prune ";

Args += remote;
}

Expand Down
1 change: 1 addition & 0 deletions src/Resources/Locales/en_US.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@
<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">Force override local refs</x:String>
<x:String x:Key="Text.Fetch.NoTags" xml:space="preserve">Fetch without tags</x:String>
<x:String x:Key="Text.Fetch.Prune" xml:space="preserve">Prune outdated remote refs</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.FileCM.AssumeUnchanged" xml:space="preserve">Assume unchanged</x:String>
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/AddRemote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public override Task<bool> Sure()
{
SetProgressDescription("Fetching from added remote ...");
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(() =>
{
Expand Down
15 changes: 11 additions & 4 deletions src/ViewModels/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public bool NoTags
set => _repo.Settings.FetchWithoutTags = value;
}

public bool Prune
{
get;
set;
}

public bool Force
{
get => _repo.Settings.EnableForceOnFetch;
Expand All @@ -46,22 +52,23 @@ public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);

var notags = _repo.Settings.FetchWithoutTags;
var force = _repo.Settings.EnableForceOnFetch;
var notags = NoTags;
var force = Force;
var prune = Prune;
return Task.Run(() =>
{
if (FetchAllRemotes)
{
foreach (var remote in _repo.Remotes)
{
SetProgressDescription($"Fetching remote: {remote.Name}");
new Commands.Fetch(_repo.FullPath, remote.Name, notags, force, SetProgressDescription).Exec();
new Commands.Fetch(_repo.FullPath, remote.Name, notags, force, prune, SetProgressDescription).Exec();
}
}
else
{
SetProgressDescription($"Fetching remote: {SelectedRemote.Name}");
new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, force, SetProgressDescription).Exec();
new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, force, prune, SetProgressDescription).Exec();
}

CallUIThread(() =>
Expand Down
1 change: 1 addition & 0 deletions src/ViewModels/Pull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public override Task<bool> Sure()
_repo.FullPath,
_selectedRemote.Name,
NoTags,
false,
false,
SetProgressDescription).Exec();

Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2433,7 +2433,7 @@ private void AutoFetchImpl(object sender)

Dispatcher.UIThread.Invoke(() => IsAutoFetching = true);
foreach (var remote in remotes)
new Commands.Fetch(_fullpath, remote, false, false, null) { RaiseError = false }.Exec();
new Commands.Fetch(_fullpath, remote, false, false, false, null) { RaiseError = false }.Exec();
_lastFetchTime = DateTime.Now;
Dispatcher.UIThread.Invoke(() => IsAutoFetching = false);
}
Expand Down
7 changes: 6 additions & 1 deletion src/Views/Fetch.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<TextBlock FontSize="18"
Classes="bold"
Text="{DynamicResource Text.Fetch.Title}"/>
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32" ColumnDefinitions="120,*">
<Grid Margin="0,16,0,0" RowDefinitions="32,32,32,32,32" ColumnDefinitions="120,*">
<TextBlock Grid.Row="0" Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
Expand Down Expand Up @@ -46,6 +46,11 @@
Content="{DynamicResource Text.Fetch.NoTags}"
IsChecked="{Binding NoTags, Mode=TwoWay}"
ToolTip.Tip="--no-tags"/>

<CheckBox Grid.Row="4" Grid.Column="1"
Content="{DynamicResource Text.Fetch.Prune}"
IsChecked="{Binding Prune, Mode=TwoWay}"
ToolTip.Tip="--prune"/>
</Grid>
</StackPanel>
</UserControl>
Loading