mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 13:20:30 +08:00
feature: add a repository configuration - Ask before auto-updating submodules (default false) (#2045)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -161,6 +161,12 @@ namespace SourceGit.Models
|
||||
set;
|
||||
} = false;
|
||||
|
||||
public bool AskBeforeAutoUpdatingSubmodules
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = false;
|
||||
|
||||
public int ChangesAfterStashing
|
||||
{
|
||||
get;
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
<x:String x:Key="Text.Checkout.LocalChanges.StashAndReapply" xml:space="preserve">Stash & Reapply</x:String>
|
||||
<x:String x:Key="Text.Checkout.Target" xml:space="preserve">Branch:</x:String>
|
||||
<x:String x:Key="Text.Checkout.WarnLostCommits" xml:space="preserve">Your current HEAD contains commit(s) not connected to any branches/tags! Do you want to continue?</x:String>
|
||||
<x:String x:Key="Text.Checkout.WarnUpdatingSubmodules" xml:space="preserve">The following submodules need to be updated:{0}Do you want to update them?</x:String>
|
||||
<x:String x:Key="Text.Checkout.WithFastForward" xml:space="preserve">Checkout & Fast-Forward</x:String>
|
||||
<x:String x:Key="Text.Checkout.WithFastForward.Upstream" xml:space="preserve">Fast-Forward to:</x:String>
|
||||
<x:String x:Key="Text.CherryPick" xml:space="preserve">Cherry Pick</x:String>
|
||||
@@ -224,6 +225,7 @@
|
||||
<x:String x:Key="Text.Configure.Email" xml:space="preserve">Email Address</x:String>
|
||||
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">Email address</x:String>
|
||||
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">Ask before auto-updating submodules</x:String>
|
||||
<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.ConventionalTypesOverride" xml:space="preserve">Conventional Commit Types</x:String>
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
<x:String x:Key="Text.Checkout.LocalChanges.StashAndReapply" xml:space="preserve">贮藏并自动恢复</x:String>
|
||||
<x:String x:Key="Text.Checkout.Target" xml:space="preserve">目标分支 :</x:String>
|
||||
<x:String x:Key="Text.Checkout.WarnLostCommits" xml:space="preserve">您当前游离的HEAD包含未被任何分支及标签引用的提交!是否继续?</x:String>
|
||||
<x:String x:Key="Text.Checkout.WarnUpdatingSubmodules" xml:space="preserve">以下子模块需要更新:{0}是否立即更新?</x:String>
|
||||
<x:String x:Key="Text.Checkout.WithFastForward" xml:space="preserve">检出分支并快进</x:String>
|
||||
<x:String x:Key="Text.Checkout.WithFastForward.Upstream" xml:space="preserve">上游分支 :</x:String>
|
||||
<x:String x:Key="Text.CherryPick" xml:space="preserve">挑选提交</x:String>
|
||||
@@ -228,6 +229,7 @@
|
||||
<x:String x:Key="Text.Configure.Email" xml:space="preserve">电子邮箱</x:String>
|
||||
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">邮箱地址</x:String>
|
||||
<x:String x:Key="Text.Configure.Git" xml:space="preserve">GIT配置</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">在自动更新子模块前询问用户</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">启用定时自动拉取远程更新</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">分钟</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.ConventionalTypesOverride" xml:space="preserve">自定义规范化提交类型</x:String>
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
<x:String x:Key="Text.Checkout.LocalChanges.StashAndReapply" xml:space="preserve">擱置變更並自動復原</x:String>
|
||||
<x:String x:Key="Text.Checkout.Target" xml:space="preserve">目標分支:</x:String>
|
||||
<x:String x:Key="Text.Checkout.WarnLostCommits" xml:space="preserve">您目前的分離的 HEAD 包含與任何分支/標籤無關的提交! 您要繼續嗎?</x:String>
|
||||
<x:String x:Key="Text.Checkout.WarnUpdatingSubmodules" xml:space="preserve">以下子模組需要更新:{0}您想立即更新它們嗎?</x:String>
|
||||
<x:String x:Key="Text.Checkout.WithFastForward" xml:space="preserve">簽出分支並快轉</x:String>
|
||||
<x:String x:Key="Text.Checkout.WithFastForward.Upstream" xml:space="preserve">上游分支: </x:String>
|
||||
<x:String x:Key="Text.CherryPick" xml:space="preserve">揀選提交</x:String>
|
||||
@@ -228,6 +229,7 @@
|
||||
<x:String x:Key="Text.Configure.Email" xml:space="preserve">電子郵件</x:String>
|
||||
<x:String x:Key="Text.Configure.Email.Placeholder" xml:space="preserve">電子郵件地址</x:String>
|
||||
<x:String x:Key="Text.Configure.Git" xml:space="preserve">Git 設定</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AskBeforeAutoUpdatingSubmodules" xml:space="preserve">在自動更新子模組之前詢問用戶</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AutoFetch" xml:space="preserve">啟用定時自動提取 (fetch) 遠端更新</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.AutoFetchIntervalSuffix" xml:space="preserve">分鐘</x:String>
|
||||
<x:String x:Key="Text.Configure.Git.ConventionalTypesOverride" xml:space="preserve">自訂約定式提交類型</x:String>
|
||||
|
||||
@@ -69,11 +69,7 @@ namespace SourceGit.ViewModels
|
||||
|
||||
if (succ)
|
||||
{
|
||||
var submodules = await new Commands.QueryUpdatableSubmodules(_repo.FullPath, false).GetResultAsync();
|
||||
if (submodules.Count > 0)
|
||||
await new Commands.Submodule(_repo.FullPath)
|
||||
.Use(log)
|
||||
.UpdateAsync(submodules);
|
||||
await _repo.TryAutoUpdateSubmodules(log);
|
||||
|
||||
if (needPopStash)
|
||||
await new Commands.Stash(_repo.FullPath)
|
||||
|
||||
@@ -74,11 +74,7 @@ namespace SourceGit.ViewModels
|
||||
|
||||
if (succ)
|
||||
{
|
||||
var submodules = await new Commands.QueryUpdatableSubmodules(_repo.FullPath, false).GetResultAsync();
|
||||
if (submodules.Count > 0)
|
||||
await new Commands.Submodule(_repo.FullPath)
|
||||
.Use(log)
|
||||
.UpdateAsync(submodules);
|
||||
await _repo.TryAutoUpdateSubmodules(log);
|
||||
|
||||
if (needPopStash)
|
||||
await new Commands.Stash(_repo.FullPath)
|
||||
|
||||
@@ -69,11 +69,7 @@ namespace SourceGit.ViewModels
|
||||
|
||||
if (succ)
|
||||
{
|
||||
var submodules = await new Commands.QueryUpdatableSubmodules(_repo.FullPath, false).GetResultAsync();
|
||||
if (submodules.Count > 0)
|
||||
await new Commands.Submodule(_repo.FullPath)
|
||||
.Use(log)
|
||||
.UpdateAsync(submodules);
|
||||
await _repo.TryAutoUpdateSubmodules(log);
|
||||
|
||||
if (needPop)
|
||||
await new Commands.Stash(_repo.FullPath)
|
||||
|
||||
@@ -153,11 +153,7 @@ namespace SourceGit.ViewModels
|
||||
|
||||
if (succ)
|
||||
{
|
||||
var submodules = await new Commands.QueryUpdatableSubmodules(_repo.FullPath, false).GetResultAsync();
|
||||
if (submodules.Count > 0)
|
||||
await new Commands.Submodule(_repo.FullPath)
|
||||
.Use(log)
|
||||
.UpdateAsync(submodules);
|
||||
await _repo.TryAutoUpdateSubmodules(log);
|
||||
|
||||
if (needPopStash)
|
||||
await new Commands.Stash(_repo.FullPath)
|
||||
|
||||
@@ -91,11 +91,7 @@ namespace SourceGit.ViewModels
|
||||
_repo.SetCommitMessage(msg);
|
||||
}
|
||||
|
||||
var submodules = await new Commands.QueryUpdatableSubmodules(_repo.FullPath, false).GetResultAsync();
|
||||
if (submodules.Count > 0)
|
||||
await new Commands.Submodule(_repo.FullPath)
|
||||
.Use(log)
|
||||
.UpdateAsync(submodules);
|
||||
await _repo.TryAutoUpdateSubmodules(log);
|
||||
}
|
||||
|
||||
log.Complete();
|
||||
|
||||
@@ -135,9 +135,7 @@ namespace SourceGit.ViewModels
|
||||
UseRebase).Use(log).RunAsync();
|
||||
if (rs)
|
||||
{
|
||||
var submodules = await new Commands.QueryUpdatableSubmodules(_repo.FullPath, false).GetResultAsync();
|
||||
if (submodules.Count > 0)
|
||||
await new Commands.Submodule(_repo.FullPath).Use(log).UpdateAsync(submodules);
|
||||
await _repo.TryAutoUpdateSubmodules(log);
|
||||
|
||||
if (needPopStash)
|
||||
await new Commands.Stash(_repo.FullPath).Use(log).PopAsync("stash@{0}");
|
||||
|
||||
@@ -1491,6 +1491,34 @@ namespace SourceGit.ViewModels
|
||||
ShowPopup(new UpdateSubmodules(this, null));
|
||||
}
|
||||
|
||||
public async Task TryAutoUpdateSubmodules(Models.ICommandLog log)
|
||||
{
|
||||
var submodules = await new Commands.QueryUpdatableSubmodules(FullPath, false).GetResultAsync();
|
||||
if (submodules.Count == 0)
|
||||
return;
|
||||
|
||||
do
|
||||
{
|
||||
if (_settings.AskBeforeAutoUpdatingSubmodules)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
builder.Append("\n\n");
|
||||
foreach (var s in submodules)
|
||||
builder.Append("- ").Append(s).Append('\n');
|
||||
builder.Append("\n");
|
||||
|
||||
var msg = App.Text("Checkout.WarnUpdatingSubmodules", builder.ToString());
|
||||
var shouldContinue = await App.AskConfirmAsync(msg);
|
||||
if (!shouldContinue)
|
||||
break;
|
||||
}
|
||||
|
||||
await new Commands.Submodule(FullPath)
|
||||
.Use(log)
|
||||
.UpdateAsync(submodules);
|
||||
} while (false);
|
||||
}
|
||||
|
||||
public void OpenSubmodule(string submodule)
|
||||
{
|
||||
var selfPage = GetOwnerPage();
|
||||
|
||||
@@ -95,6 +95,12 @@ namespace SourceGit.ViewModels
|
||||
set;
|
||||
}
|
||||
|
||||
public bool AskBeforeAutoUpdatingSubmodules
|
||||
{
|
||||
get => _repo.Settings.AskBeforeAutoUpdatingSubmodules;
|
||||
set => _repo.Settings.AskBeforeAutoUpdatingSubmodules = value;
|
||||
}
|
||||
|
||||
public bool EnableAutoFetch
|
||||
{
|
||||
get => _repo.Settings.EnableAutoFetch;
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace SourceGit.ViewModels
|
||||
.Use(log)
|
||||
.ExecAsync();
|
||||
|
||||
await _repo.TryAutoUpdateSubmodules(log);
|
||||
|
||||
log.Complete();
|
||||
return succ;
|
||||
}
|
||||
|
||||
@@ -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" ColumnDefinitions="Auto,*">
|
||||
<Grid Margin="16,4,16,8" RowDefinitions="32,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"
|
||||
@@ -174,7 +174,11 @@
|
||||
Content="{DynamicResource Text.Preferences.Git.EnablePruneOnFetch}"
|
||||
IsChecked="{Binding EnablePruneOnFetch, Mode=TwoWay}"/>
|
||||
|
||||
<StackPanel Grid.Row="10" Grid.Column="1" Orientation="Horizontal">
|
||||
<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}"/>
|
||||
|
||||
Reference in New Issue
Block a user