mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
feature: add an option in repository configuration to enable --prune
on fetch (#590)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
a4befd010a
commit
3cbffa6ff9
12 changed files with 50 additions and 11 deletions
|
@ -4,7 +4,7 @@ namespace SourceGit.Commands
|
|||
{
|
||||
public class Fetch : Command
|
||||
{
|
||||
public Fetch(string repo, string remote, bool noTags, Action<string> outputHandler)
|
||||
public Fetch(string repo, string remote, bool noTags, bool prune, Action<string> outputHandler)
|
||||
{
|
||||
_outputHandler = outputHandler;
|
||||
WorkingDirectory = repo;
|
||||
|
@ -18,6 +18,9 @@ namespace SourceGit.Commands
|
|||
else
|
||||
Args += "--force ";
|
||||
|
||||
if (prune)
|
||||
Args += "--prune ";
|
||||
|
||||
Args += remote;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace SourceGit.Commands
|
|||
{
|
||||
public class Pull : Command
|
||||
{
|
||||
public Pull(string repo, string remote, string branch, bool useRebase, bool noTags, Action<string> outputHandler)
|
||||
public Pull(string repo, string remote, string branch, bool useRebase, bool noTags, bool prune, Action<string> outputHandler)
|
||||
{
|
||||
_outputHandler = outputHandler;
|
||||
WorkingDirectory = repo;
|
||||
|
@ -17,6 +17,8 @@ namespace SourceGit.Commands
|
|||
Args += "--rebase ";
|
||||
if (noTags)
|
||||
Args += "--no-tags ";
|
||||
if (prune)
|
||||
Args += "--prune ";
|
||||
|
||||
Args += $"{remote} {branch}";
|
||||
}
|
||||
|
|
|
@ -16,6 +16,12 @@ namespace SourceGit.Models
|
|||
set;
|
||||
} = DealWithLocalChanges.DoNothing;
|
||||
|
||||
public bool EnablePruneOnFetch
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = false;
|
||||
|
||||
public bool FetchWithoutTags
|
||||
{
|
||||
get;
|
||||
|
|
|
@ -145,6 +145,7 @@
|
|||
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">Fetch remotes automatically</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">Minute(s)</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.DefaultRemote" xml:space="preserve">Default Remote</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.EnablePruneOnFetch" xml:space="preserve">Enable --prune on fetch</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.EnableSignOff" xml:space="preserve">Enable --signoff for commit</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE TRACKER</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGithub" xml:space="preserve">Add Sample Github Rule</x:String>
|
||||
|
|
|
@ -149,6 +149,7 @@
|
|||
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">分钟</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.DefaultRemote" xml:space="preserve">默认远程</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.EnableSignOff" xml:space="preserve">提交信息追加署名 (--signoff)</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.EnablePruneOnFetch" xml:space="preserve">拉取更新时启用修剪(--prune)</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">ISSUE追踪</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGithub" xml:space="preserve">新增匹配Github Issue规则</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleJira" xml:space="preserve">新增匹配Jira规则</x:String>
|
||||
|
|
|
@ -149,6 +149,7 @@
|
|||
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">分鐘</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.DefaultRemote" xml:space="preserve">預設遠端存放庫</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.EnableSignOff" xml:space="preserve">提交訊息追加署名 (--signoff)</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.EnablePruneOnFetch" xml:space="preserve">提取變更时啟用修剪(--prune)</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker" xml:space="preserve">Issue 追蹤</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleGithub" xml:space="preserve">新增符合 GitHub Issue 規則</x:String>
|
||||
<x:String x:Key="Text.Configure.IssueTracker.AddSampleJira" xml:space="preserve">新增符合 Jira 規則</x:String>
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
SetProgressDescription("Fetching from added remote ...");
|
||||
new Commands.Config(_repo.FullPath).Set($"remote.{_name}.sshkey", _useSSH ? SSHKey : null);
|
||||
new Commands.Fetch(_repo.FullPath, _name, false, SetProgressDescription).Exec();
|
||||
new Commands.Fetch(_repo.FullPath, _name, false, false, SetProgressDescription).Exec();
|
||||
}
|
||||
CallUIThread(() =>
|
||||
{
|
||||
|
|
|
@ -40,6 +40,8 @@ namespace SourceGit.ViewModels
|
|||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
|
||||
var notags = _repo.Settings.FetchWithoutTags;
|
||||
var prune = _repo.Settings.EnablePruneOnFetch;
|
||||
return Task.Run(() =>
|
||||
{
|
||||
if (FetchAllRemotes)
|
||||
|
@ -47,13 +49,13 @@ namespace SourceGit.ViewModels
|
|||
foreach (var remote in _repo.Remotes)
|
||||
{
|
||||
SetProgressDescription($"Fetching remote: {remote.Name}");
|
||||
new Commands.Fetch(_repo.FullPath, remote.Name, NoTags, SetProgressDescription).Exec();
|
||||
new Commands.Fetch(_repo.FullPath, remote.Name, notags, prune, SetProgressDescription).Exec();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetProgressDescription($"Fetching remote: {SelectedRemote.Name}");
|
||||
new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, NoTags, SetProgressDescription).Exec();
|
||||
new Commands.Fetch(_repo.FullPath, SelectedRemote.Name, notags, prune, SetProgressDescription).Exec();
|
||||
}
|
||||
|
||||
CallUIThread(() =>
|
||||
|
|
|
@ -147,7 +147,13 @@ namespace SourceGit.ViewModels
|
|||
if (FetchAllBranches)
|
||||
{
|
||||
SetProgressDescription($"Fetching remote: {_selectedRemote.Name}...");
|
||||
rs = new Commands.Fetch(_repo.FullPath, _selectedRemote.Name, NoTags, SetProgressDescription).Exec();
|
||||
rs = new Commands.Fetch(
|
||||
_repo.FullPath,
|
||||
_selectedRemote.Name,
|
||||
NoTags,
|
||||
_repo.Settings.EnablePruneOnFetch,
|
||||
SetProgressDescription).Exec();
|
||||
|
||||
if (!rs)
|
||||
{
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
|
@ -171,7 +177,14 @@ namespace SourceGit.ViewModels
|
|||
else
|
||||
{
|
||||
SetProgressDescription($"Pull {_selectedRemote.Name}/{_selectedBranch.Name}...");
|
||||
rs = new Commands.Pull(_repo.FullPath, _selectedRemote.Name, _selectedBranch.Name, UseRebase, NoTags, SetProgressDescription).Exec();
|
||||
rs = new Commands.Pull(
|
||||
_repo.FullPath,
|
||||
_selectedRemote.Name,
|
||||
_selectedBranch.Name,
|
||||
UseRebase,
|
||||
NoTags,
|
||||
_repo.Settings.EnablePruneOnFetch,
|
||||
SetProgressDescription).Exec();
|
||||
}
|
||||
|
||||
if (rs && needPopStash)
|
||||
|
|
|
@ -2137,7 +2137,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
IsAutoFetching = true;
|
||||
Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching)));
|
||||
new Commands.Fetch(_fullpath, "--all", false, null) { RaiseError = false }.Exec();
|
||||
new Commands.Fetch(_fullpath, "--all", false, _settings.EnablePruneOnFetch, null) { RaiseError = false }.Exec();
|
||||
_lastFetchTime = DateTime.Now;
|
||||
IsAutoFetching = false;
|
||||
Dispatcher.UIThread.Invoke(() => OnPropertyChanged(nameof(IsAutoFetching)));
|
||||
|
|
|
@ -67,6 +67,12 @@ namespace SourceGit.ViewModels
|
|||
set => _repo.Settings.EnableSignOffForCommit = value;
|
||||
}
|
||||
|
||||
public bool EnablePruneOnFetch
|
||||
{
|
||||
get => _repo.Settings.EnablePruneOnFetch;
|
||||
set => _repo.Settings.EnablePruneOnFetch = value;
|
||||
}
|
||||
|
||||
public bool EnableAutoFetch
|
||||
{
|
||||
get => _repo.Settings.EnableAutoFetch;
|
||||
|
@ -134,7 +140,7 @@ namespace SourceGit.ViewModels
|
|||
AvailableOpenAIServices.Add(service.Name);
|
||||
|
||||
if (AvailableOpenAIServices.IndexOf(PreferedOpenAIService) == -1)
|
||||
PreferedOpenAIService = "---";
|
||||
PreferedOpenAIService = "---";
|
||||
|
||||
_cached = new Commands.Config(repo.FullPath).ListAll();
|
||||
if (_cached.TryGetValue("user.name", out var name))
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Configure.Git}"/>
|
||||
</TabItem.Header>
|
||||
|
||||
<Grid Margin="16,4,16,8" RowDefinitions="32,32,32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||
<Grid Margin="16,4,16,8" RowDefinitions="32,32,32,32,32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
|
@ -130,7 +130,11 @@
|
|||
Content="{DynamicResource Text.Preference.GPG.TagEnabled}"
|
||||
IsChecked="{Binding GPGTagSigningEnabled, Mode=TwoWay}"/>
|
||||
|
||||
<StackPanel Grid.Row="8" Grid.Column="1" Orientation="Horizontal">
|
||||
<CheckBox Grid.Row="8" Grid.Column="1"
|
||||
Content="{DynamicResource Text.Configure.Git.EnablePruneOnFetch}"
|
||||
IsChecked="{Binding EnablePruneOnFetch, Mode=TwoWay}"/>
|
||||
|
||||
<StackPanel Grid.Row="9" Grid.Column="1" Orientation="Horizontal">
|
||||
<CheckBox x:Name="AutoFetchCheckBox"
|
||||
Content="{DynamicResource Text.Configure.Git.AutoFetch}"
|
||||
IsChecked="{Binding EnableAutoFetch, Mode=TwoWay}"/>
|
||||
|
|
Loading…
Reference in a new issue