feature: auto-fetch now is a global setting instead of per-repo setting (#2050)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2026-04-09 14:16:08 +08:00
parent 42734b90a2
commit bfdd73d2fd
6 changed files with 36 additions and 56 deletions

View File

@@ -30,18 +30,6 @@ namespace SourceGit.Models
set;
} = string.Empty;
public bool EnableAutoFetch
{
get;
set;
} = false;
public int AutoFetchInterval
{
get;
set;
} = 10;
public bool AskBeforeAutoUpdatingSubmodules
{
get;

View File

@@ -254,6 +254,18 @@ namespace SourceGit.ViewModels
}
}
public bool EnableAutoFetch
{
get;
set;
} = false;
public int AutoFetchInterval
{
get;
set;
} = 10;
public bool IgnoreWhitespaceChangesInDiff
{
get => _ignoreWhitespaceChangesInDiff;

View File

@@ -1887,7 +1887,7 @@ namespace SourceGit.ViewModels
try
{
if (_settings is not { EnableAutoFetch: true } || !CanCreatePopup())
if (Preferences.Instance.EnableAutoFetch || !CanCreatePopup())
{
_lastFetchTime = DateTime.Now;
return;
@@ -1898,7 +1898,7 @@ namespace SourceGit.ViewModels
return;
var now = DateTime.Now;
var desire = _lastFetchTime.AddMinutes(_settings.AutoFetchInterval);
var desire = _lastFetchTime.AddMinutes(Preferences.Instance.AutoFetchInterval);
if (desire > now)
return;

View File

@@ -101,26 +101,6 @@ namespace SourceGit.ViewModels
set => _repo.Settings.AskBeforeAutoUpdatingSubmodules = value;
}
public bool EnableAutoFetch
{
get => _repo.Settings.EnableAutoFetch;
set => _repo.Settings.EnableAutoFetch = value;
}
public int? AutoFetchInterval
{
get => _repo.Settings.AutoFetchInterval;
set
{
if (value is null || value < 1)
return;
var interval = (int)value;
if (_repo.Settings.AutoFetchInterval != interval)
_repo.Settings.AutoFetchInterval = interval;
}
}
public AvaloniaList<Models.CommitTemplate> CommitTemplates
{
get => _repo.Settings.CommitTemplates;

View File

@@ -309,7 +309,7 @@
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preferences.Git}"/>
</TabItem.Header>
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32,32,Auto" ColumnDefinitions="Auto,*">
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32,32,32,Auto,32" ColumnDefinitions="Auto,*">
<TextBlock Grid.Row="0" Grid.Column="0"
Text="{DynamicResource Text.Preferences.Git.Path}"
HorizontalAlignment="Right"
@@ -405,6 +405,26 @@
Content="{DynamicResource Text.Preferences.Git.UseLibsecret}"
IsChecked="{Binding UseLibsecretInsteadOfGCM, Mode=TwoWay}"
IsVisible="{OnPlatform False, Linux=True}"/>
<StackPanel Grid.Row="9" Grid.Column="1" Orientation="Horizontal">
<CheckBox x:Name="AutoFetchCheckBox"
Content="{DynamicResource Text.Configure.Git.AutoFetch}"
IsChecked="{Binding EnableAutoFetch, Mode=TwoWay}"/>
<NumericUpDown Minimum="1" Maximum="60" Increment="1"
Height="26" Width="110"
Margin="8,0,0,0" Padding="4"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
CornerRadius="3"
ParsingNumberStyle="Integer"
FormatString="0"
Value="{Binding AutoFetchInterval, Mode=TwoWay, FallbackValue=10}"
IsEnabled="{Binding #AutoFetchCheckBox.IsChecked}"/>
<TextBlock VerticalAlignment="Center"
Margin="5,0,0,0"
Text="{DynamicResource Text.Configure.Git.AutoFetchIntervalSuffix}" />
</StackPanel>
</Grid>
</TabItem>

View File

@@ -44,7 +44,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,32,32,32" ColumnDefinitions="Auto,*">
<Grid Margin="16,4,16,8" RowDefinitions="32,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"
@@ -179,26 +179,6 @@
<CheckBox Grid.Row="10" Grid.Column="1"
Content="{DynamicResource Text.Configure.Git.AskBeforeAutoUpdatingSubmodules}"
IsChecked="{Binding AskBeforeAutoUpdatingSubmodules, Mode=TwoWay}"/>
<StackPanel Grid.Row="11" Grid.Column="1" Orientation="Horizontal">
<CheckBox x:Name="AutoFetchCheckBox"
Content="{DynamicResource Text.Configure.Git.AutoFetch}"
IsChecked="{Binding EnableAutoFetch, Mode=TwoWay}"/>
<NumericUpDown Minimum="1" Maximum="60" Increment="1"
Height="26" Width="110"
Margin="8,0,0,0" Padding="4"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}"
CornerRadius="3"
ParsingNumberStyle="Integer"
FormatString="0"
Value="{Binding AutoFetchInterval, Mode=TwoWay, FallbackValue=10}"
IsEnabled="{Binding #AutoFetchCheckBox.IsChecked}"/>
<TextBlock VerticalAlignment="Center"
Margin="5,0,0,0"
Text="{DynamicResource Text.Configure.Git.AutoFetchIntervalSuffix}" />
</StackPanel>
</Grid>
</TabItem>