mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-31 09:04:59 +00:00
feature: supports to de-initialize a submodule (#1272)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
1fef7a7baa
commit
b0c0c46441
9 changed files with 139 additions and 13 deletions
|
@ -51,13 +51,15 @@ namespace SourceGit.Commands
|
|||
return Exec();
|
||||
}
|
||||
|
||||
public bool Delete(string relativePath)
|
||||
public bool Deinit(string module, bool force)
|
||||
{
|
||||
Args = $"submodule deinit -f \"{relativePath}\"";
|
||||
if (!Exec())
|
||||
return false;
|
||||
Args = force ? $"submodule deinit -f -- \"{module}\"" : $"submodule deinit -- \"{module}\"";
|
||||
return Exec();
|
||||
}
|
||||
|
||||
Args = $"rm -rf \"{relativePath}\"";
|
||||
public bool Delete(string module)
|
||||
{
|
||||
Args = $"rm -rf \"{module}\"";
|
||||
return Exec();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,6 +231,9 @@
|
|||
<x:String x:Key="Text.CreateTag.Type.Lightweight" xml:space="preserve">lightweight</x:String>
|
||||
<x:String x:Key="Text.CtrlClickTip" xml:space="preserve">Hold Ctrl to start directly</x:String>
|
||||
<x:String x:Key="Text.Cut" xml:space="preserve">Cut</x:String>
|
||||
<x:String x:Key="Text.DeinitSubmodule" xml:space="preserve">De-initialize Submodule</x:String>
|
||||
<x:String x:Key="Text.DeinitSubmodule.Force" xml:space="preserve">Force de-init event if it contains local changes.</x:String>
|
||||
<x:String x:Key="Text.DeinitSubmodule.Path" xml:space="preserve">Submodule:</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch" xml:space="preserve">Delete Branch</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.Branch" xml:space="preserve">Branch:</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.IsRemoteTip" xml:space="preserve">You are about to delete a remote branch!!!</x:String>
|
||||
|
@ -266,6 +269,7 @@
|
|||
<x:String x:Key="Text.Diff.ShowHiddenSymbols" xml:space="preserve">Show hidden symbols</x:String>
|
||||
<x:String x:Key="Text.Diff.SideBySide" xml:space="preserve">Side-By-Side Diff</x:String>
|
||||
<x:String x:Key="Text.Diff.Submodule" xml:space="preserve">SUBMODULE</x:String>
|
||||
<x:String x:Key="Text.Diff.Submodule.Deleted" xml:space="preserve">DELETED</x:String>
|
||||
<x:String x:Key="Text.Diff.Submodule.New" xml:space="preserve">NEW</x:String>
|
||||
<x:String x:Key="Text.Diff.SwapCommits" xml:space="preserve">Swap</x:String>
|
||||
<x:String x:Key="Text.Diff.SyntaxHighlight" xml:space="preserve">Syntax Highlighting</x:String>
|
||||
|
@ -708,6 +712,7 @@
|
|||
<x:String x:Key="Text.Submodule" xml:space="preserve">SUBMODULES</x:String>
|
||||
<x:String x:Key="Text.Submodule.Add" xml:space="preserve">Add Submodule</x:String>
|
||||
<x:String x:Key="Text.Submodule.CopyPath" xml:space="preserve">Copy Relative Path</x:String>
|
||||
<x:String x:Key="Text.Submodule.Deinit" xml:space="preserve">De-initialize Submodule</x:String>
|
||||
<x:String x:Key="Text.Submodule.FetchNested" xml:space="preserve">Fetch nested submodules</x:String>
|
||||
<x:String x:Key="Text.Submodule.Open" xml:space="preserve">Open Submodule Repository</x:String>
|
||||
<x:String x:Key="Text.Submodule.RelativePath" xml:space="preserve">Relative Path:</x:String>
|
||||
|
|
|
@ -235,6 +235,9 @@
|
|||
<x:String x:Key="Text.CreateTag.Type.Lightweight" xml:space="preserve">轻量标签</x:String>
|
||||
<x:String x:Key="Text.CtrlClickTip" xml:space="preserve">按住Ctrl键点击将以默认参数运行</x:String>
|
||||
<x:String x:Key="Text.Cut" xml:space="preserve">剪切</x:String>
|
||||
<x:String x:Key="Text.DeinitSubmodule" xml:space="preserve">取消初始化子模块</x:String>
|
||||
<x:String x:Key="Text.DeinitSubmodule.Force" xml:space="preserve">强制取消,即使包含本地变更</x:String>
|
||||
<x:String x:Key="Text.DeinitSubmodule.Path" xml:space="preserve">子模块 :</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch" xml:space="preserve">删除分支确认</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.Branch" xml:space="preserve">分支名 :</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.IsRemoteTip" xml:space="preserve">您正在删除远程上的分支,请务必小心!!!</x:String>
|
||||
|
@ -270,6 +273,7 @@
|
|||
<x:String x:Key="Text.Diff.ShowHiddenSymbols" xml:space="preserve">显示隐藏符号</x:String>
|
||||
<x:String x:Key="Text.Diff.SideBySide" xml:space="preserve">分列对比</x:String>
|
||||
<x:String x:Key="Text.Diff.Submodule" xml:space="preserve">子模块</x:String>
|
||||
<x:String x:Key="Text.Diff.Submodule.Deleted" xml:space="preserve">删除</x:String>
|
||||
<x:String x:Key="Text.Diff.Submodule.New" xml:space="preserve">新增</x:String>
|
||||
<x:String x:Key="Text.Diff.SwapCommits" xml:space="preserve">交换比对双方</x:String>
|
||||
<x:String x:Key="Text.Diff.SyntaxHighlight" xml:space="preserve">语法高亮</x:String>
|
||||
|
@ -712,6 +716,7 @@
|
|||
<x:String x:Key="Text.Submodule" xml:space="preserve">子模块</x:String>
|
||||
<x:String x:Key="Text.Submodule.Add" xml:space="preserve">添加子模块</x:String>
|
||||
<x:String x:Key="Text.Submodule.CopyPath" xml:space="preserve">复制路径</x:String>
|
||||
<x:String x:Key="Text.Submodule.Deinit" xml:space="preserve">取消初始化</x:String>
|
||||
<x:String x:Key="Text.Submodule.FetchNested" xml:space="preserve">拉取子孙模块</x:String>
|
||||
<x:String x:Key="Text.Submodule.Open" xml:space="preserve">打开仓库</x:String>
|
||||
<x:String x:Key="Text.Submodule.RelativePath" xml:space="preserve">相对仓库路径 :</x:String>
|
||||
|
|
|
@ -235,6 +235,9 @@
|
|||
<x:String x:Key="Text.CreateTag.Type.Lightweight" xml:space="preserve">輕量標籤</x:String>
|
||||
<x:String x:Key="Text.CtrlClickTip" xml:space="preserve">按住 Ctrl 鍵將直接以預設參數執行</x:String>
|
||||
<x:String x:Key="Text.Cut" xml:space="preserve">剪下</x:String>
|
||||
<x:String x:Key="Text.DeinitSubmodule" xml:space="preserve">取消初始化子模組</x:String>
|
||||
<x:String x:Key="Text.DeinitSubmodule.Force" xml:space="preserve">強制取消,即使它包含本地變更</x:String>
|
||||
<x:String x:Key="Text.DeinitSubmodule.Path" xml:space="preserve">子模組 :</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch" xml:space="preserve">刪除分支確認</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.Branch" xml:space="preserve">分支名稱:</x:String>
|
||||
<x:String x:Key="Text.DeleteBranch.IsRemoteTip" xml:space="preserve">您正在刪除遠端上的分支,請務必小心!</x:String>
|
||||
|
@ -270,6 +273,7 @@
|
|||
<x:String x:Key="Text.Diff.ShowHiddenSymbols" xml:space="preserve">顯示隱藏符號</x:String>
|
||||
<x:String x:Key="Text.Diff.SideBySide" xml:space="preserve">並排對比</x:String>
|
||||
<x:String x:Key="Text.Diff.Submodule" xml:space="preserve">子模組</x:String>
|
||||
<x:String x:Key="Text.Diff.Submodule.Deleted" xml:space="preserve">已刪除</x:String>
|
||||
<x:String x:Key="Text.Diff.Submodule.New" xml:space="preserve">新增</x:String>
|
||||
<x:String x:Key="Text.Diff.SwapCommits" xml:space="preserve">交換比對雙方</x:String>
|
||||
<x:String x:Key="Text.Diff.SyntaxHighlight" xml:space="preserve">語法上色</x:String>
|
||||
|
@ -712,6 +716,7 @@
|
|||
<x:String x:Key="Text.Submodule" xml:space="preserve">子模組</x:String>
|
||||
<x:String x:Key="Text.Submodule.Add" xml:space="preserve">新增子模組</x:String>
|
||||
<x:String x:Key="Text.Submodule.CopyPath" xml:space="preserve">複製路徑</x:String>
|
||||
<x:String x:Key="Text.Submodule.Deinit" xml:space="preserve">取消初始化</x:String>
|
||||
<x:String x:Key="Text.Submodule.FetchNested" xml:space="preserve">提取子模組</x:String>
|
||||
<x:String x:Key="Text.Submodule.Open" xml:space="preserve">開啟存放庫</x:String>
|
||||
<x:String x:Key="Text.Submodule.RelativePath" xml:space="preserve">相對存放庫路徑:</x:String>
|
||||
|
|
45
src/ViewModels/DeinitSubmodule.cs
Normal file
45
src/ViewModels/DeinitSubmodule.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class DeinitSubmodule : Popup
|
||||
{
|
||||
public string Submodule
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool Force
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public DeinitSubmodule(Repository repo, string submodule)
|
||||
{
|
||||
_repo = repo;
|
||||
Submodule = submodule;
|
||||
Force = false;
|
||||
}
|
||||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
_repo.SetWatcherEnabled(false);
|
||||
ProgressDescription = "De-initialize Submodule";
|
||||
|
||||
var log = _repo.CreateLog("De-initialize Submodule");
|
||||
Use(log);
|
||||
|
||||
return Task.Run(() =>
|
||||
{
|
||||
var succ = new Commands.Submodule(_repo.FullPath).Use(log).Deinit(Submodule, false);
|
||||
log.Complete();
|
||||
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||
return succ;
|
||||
});
|
||||
}
|
||||
|
||||
private Repository _repo;
|
||||
}
|
||||
}
|
|
@ -2432,12 +2432,14 @@ namespace SourceGit.ViewModels
|
|||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var copy = new MenuItem();
|
||||
copy.Header = App.Text("Submodule.CopyPath");
|
||||
copy.Icon = App.CreateMenuIcon("Icons.Copy");
|
||||
copy.Click += (_, ev) =>
|
||||
var deinit = new MenuItem();
|
||||
deinit.Header = App.Text("Submodule.Deinit");
|
||||
deinit.Icon = App.CreateMenuIcon("Icons.Undo");
|
||||
deinit.IsEnabled = submodule.Status != Models.SubmoduleStatus.NotInited;
|
||||
deinit.Click += (_, ev) =>
|
||||
{
|
||||
App.CopyText(submodule.Path);
|
||||
if (CanCreatePopup())
|
||||
ShowPopup(new DeinitSubmodule(this, submodule.Path));
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
|
@ -2451,10 +2453,22 @@ namespace SourceGit.ViewModels
|
|||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var copy = new MenuItem();
|
||||
copy.Header = App.Text("Submodule.CopyPath");
|
||||
copy.Icon = App.CreateMenuIcon("Icons.Copy");
|
||||
copy.Click += (_, ev) =>
|
||||
{
|
||||
App.CopyText(submodule.Path);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(open);
|
||||
menu.Items.Add(copy);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
menu.Items.Add(deinit);
|
||||
menu.Items.Add(rm);
|
||||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
menu.Items.Add(copy);
|
||||
return menu;
|
||||
}
|
||||
|
||||
|
|
28
src/Views/DeinitSubmodule.axaml
Normal file
28
src/Views/DeinitSubmodule.axaml
Normal file
|
@ -0,0 +1,28 @@
|
|||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:vm="using:SourceGit.ViewModels"
|
||||
xmlns:v="using:SourceGit.Views"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.DeinitSubmodule"
|
||||
x:DataType="vm:DeinitSubmodule">
|
||||
<StackPanel Orientation="Vertical" Margin="8,0">
|
||||
<TextBlock FontSize="18"
|
||||
Classes="bold"
|
||||
Text="{DynamicResource Text.DeinitSubmodule}"/>
|
||||
|
||||
<Grid Margin="0,16,8,0" RowDefinitions="32,Auto" ColumnDefinitions="120,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" Text="{DynamicResource Text.DeinitSubmodule.Path}"/>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal">
|
||||
<Path Width="14" Height="14" Margin="8,0" Data="{StaticResource Icons.Submodule}"/>
|
||||
<TextBlock Text="{Binding Submodule}"/>
|
||||
</StackPanel>
|
||||
|
||||
<CheckBox Grid.Row="1" Grid.Column="1"
|
||||
Content="{DynamicResource Text.DeinitSubmodule.Force}"
|
||||
IsChecked="{Binding Force, Mode=TwoWay}"
|
||||
ToolTip.Tip="--force"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
12
src/Views/DeinitSubmodule.axaml.cs
Normal file
12
src/Views/DeinitSubmodule.axaml.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using Avalonia.Controls;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class DeinitSubmodule : UserControl
|
||||
{
|
||||
public DeinitSubmodule()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -279,8 +279,18 @@
|
|||
|
||||
<Path Width="16" Height="16" Data="{StaticResource Icons.DoubleDown}" HorizontalAlignment="Center" IsVisible="{Binding Old, Converter={x:Static ObjectConverters.IsNotNull}}"/>
|
||||
|
||||
<Border Margin="0,8,0,0" BorderThickness="1" BorderBrush="Green" Background="{DynamicResource Brush.Window}">
|
||||
<v:CommitBaseInfo MaxHeight="256" Margin="0,0,0,4" Content="{Binding New.Commit}" FullMessage="{Binding New.FullMessage}"/>
|
||||
<Border Margin="0,8,0,0" BorderThickness="1" BorderBrush="Green" Background="{DynamicResource Brush.Window}" IsVisible="{Binding New, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<ContentControl Content="{Binding New}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="m:RevisionSubmodule">
|
||||
<v:CommitBaseInfo MaxHeight="256" Margin="0,0,0,4" Content="{Binding Commit}" FullMessage="{Binding FullMessage}"/>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
</Border>
|
||||
|
||||
<Border Margin="0,8,0,0" Height="16" HorizontalAlignment="Center" Background="Red" CornerRadius="8" IsVisible="{Binding New, Converter={x:Static ObjectConverters.IsNull}}">
|
||||
<TextBlock Classes="primary" Text="{DynamicResource Text.Diff.Submodule.Deleted}" Margin="8,0" FontSize="10"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue