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
4 changes: 3 additions & 1 deletion src/Commands/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace SourceGit.Commands
{
public class Fetch : Command
{
public Fetch(string repo, string remote, bool noTags, bool force)
public Fetch(string repo, string remote, bool noTags, bool force, bool prune)
{
_remote = remote;

Expand All @@ -17,6 +17,8 @@ public Fetch(string repo, string remote, bool noTags, bool force)
builder.Append(noTags ? "--no-tags " : "--tags ");
if (force)
builder.Append("--force ");
if (prune)
builder.Append("--prune ");
builder.Append(remote);

Args = builder.ToString();
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 @@ -386,6 +386,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 deleted branches</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 @@ -105,7 +105,7 @@ public override async Task<bool> Sure()
.Use(log)
.SetAsync($"remote.{_name}.sshkey", _useSSH ? SSHKey : null);

await new Commands.Fetch(_repo.FullPath, _name, false, false)
await new Commands.Fetch(_repo.FullPath, _name, false, false, false)
.Use(log)
.RunAsync();
}
Expand Down
16 changes: 14 additions & 2 deletions src/ViewModels/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public bool Force
set => _repo.Settings.EnableForceOnFetch = value;
}

public bool Prune
{
get => _prune;
set => SetProperty(ref _prune, value);
}

public Fetch(Repository repo, Models.Remote preferredRemote = null)
{
_repo = repo;
Expand All @@ -62,6 +68,10 @@ public Fetch(Repository repo, Models.Remote preferredRemote = null)
{
SelectedRemote = _repo.Remotes[0];
}

// Initialize prune from git config
var pruneConfig = new Commands.Config(_repo.FullPath).Get("fetch.prune");
_prune = pruneConfig == "true";
}

public override async Task<bool> Sure()
Expand All @@ -71,19 +81,20 @@ public override async Task<bool> Sure()
var navigateToUpstreamHEAD = _repo.SelectedView is Histories { AutoSelectedCommit: { IsCurrentHead: true } };
var notags = _repo.Settings.FetchWithoutTags;
var force = _repo.Settings.EnableForceOnFetch;
var prune = Prune;
var log = _repo.CreateLog("Fetch");
Use(log);

if (FetchAllRemotes)
{
foreach (var remote in _repo.Remotes)
await new Commands.Fetch(_repo.FullPath, remote.Name, notags, force)
await new Commands.Fetch(_repo.FullPath, remote.Name, notags, force, prune)
.Use(log)
.RunAsync();
}
else
{
await new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, force)
await new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, force, prune)
.Use(log)
.RunAsync();
}
Expand All @@ -106,5 +117,6 @@ public override async Task<bool> Sure()

private readonly Repository _repo = null;
private bool _fetchAllRemotes = false;
private bool _prune = false;
}
}
7 changes: 6 additions & 1 deletion src/Views/Fetch.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Text="{DynamicResource Text.Fetch.Title}"/>
</StackPanel>

<Grid Margin="0,16,0,0" RowDefinitions="32,32,Auto,32" ColumnDefinitions="120,*">
<Grid Margin="0,16,0,0" RowDefinitions="32,32,Auto,32,32" ColumnDefinitions="120,*">
<TextBlock Grid.Row="0" Grid.Column="0"
HorizontalAlignment="Right" VerticalAlignment="Center"
Margin="0,0,8,0"
Expand Down Expand Up @@ -60,6 +60,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>