mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-22 20:37:19 -08:00
feature<SubTree>: supports git subtree
feature
This commit is contained in:
parent
6b602e70c5
commit
130b5a66ab
22 changed files with 784 additions and 10 deletions
39
src/Commands/SubTree.cs
Normal file
39
src/Commands/SubTree.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
|
||||
namespace SourceGit.Commands {
|
||||
/// <summary>
|
||||
/// 子树相关操作
|
||||
/// </summary>
|
||||
public class SubTree : Command {
|
||||
private Action<string> handler = null;
|
||||
|
||||
public SubTree(string repo) {
|
||||
Cwd = repo;
|
||||
TraitErrorAsOutput = true;
|
||||
}
|
||||
|
||||
public override void OnReadline(string line) {
|
||||
handler?.Invoke(line);
|
||||
}
|
||||
|
||||
public bool Add(string prefix, string source, string revision, bool squash, Action<string> onProgress) {
|
||||
handler = onProgress;
|
||||
Args = $"subtree add --prefix=\"{prefix}\" {source} {revision}";
|
||||
if (squash) Args += " --squash";
|
||||
return Exec();
|
||||
}
|
||||
|
||||
public void Pull(string prefix, string source, string branch, bool squash, Action<string> onProgress) {
|
||||
handler = onProgress;
|
||||
Args = $"subtree pull --prefix=\"{prefix}\" {source} {branch}";
|
||||
if (squash) Args += " --squash";
|
||||
Exec();
|
||||
}
|
||||
|
||||
public void Push(string prefix, string source, string branch, Action<string> onProgress) {
|
||||
handler = onProgress;
|
||||
Args = $"subtree push --prefix=\"{prefix}\" {source} {branch}";
|
||||
Exec();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ namespace SourceGit.Models {
|
|||
public string GitDir { get; set; } = "";
|
||||
public string GroupId { get; set; } = "";
|
||||
public int Bookmark { get; set; } = 0;
|
||||
public List<SubTree> SubTrees { get; set; } = new List<SubTree>();
|
||||
public List<string> Filters { get; set; } = new List<string>();
|
||||
public List<string> CommitMessages { get; set; } = new List<string>();
|
||||
#endregion
|
||||
|
|
10
src/Models/SubTree.cs
Normal file
10
src/Models/SubTree.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
namespace SourceGit.Models {
|
||||
/// <summary>
|
||||
/// 子树
|
||||
/// </summary>
|
||||
public class SubTree {
|
||||
public string Prefix { get; set; }
|
||||
public string Remote { get; set; }
|
||||
public string Branch { get; set; } = "master";
|
||||
}
|
||||
}
|
|
@ -38,6 +38,10 @@ namespace SourceGit.Models {
|
|||
/// 子模块变更
|
||||
/// </summary>
|
||||
public event Action SubmoduleChanged;
|
||||
/// <summary>
|
||||
/// 树更新
|
||||
/// </summary>
|
||||
public event Action SubTreeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 打开仓库事件
|
||||
|
@ -119,6 +123,13 @@ namespace SourceGit.Models {
|
|||
WorkingCopyChanged?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通知更新子树列表
|
||||
/// </summary>
|
||||
public void RefreshSubTrees() {
|
||||
SubTreeChanged?.Invoke();
|
||||
}
|
||||
|
||||
private void Start(string repo, string gitDir) {
|
||||
wcWatcher = new FileSystemWatcher();
|
||||
wcWatcher.Path = repo;
|
||||
|
@ -163,6 +174,7 @@ namespace SourceGit.Models {
|
|||
TagChanged = null;
|
||||
StashChanged = null;
|
||||
SubmoduleChanged = null;
|
||||
SubTreeChanged = null;
|
||||
}
|
||||
|
||||
private void OnRepositoryChanged(object o, FileSystemEventArgs e) {
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Geometry x:Key="Icon.Git">M1004.8 466.4 557.7 19.3c-25.7-25.8-67.5-25.8-93.3 0L360.6 123.2l78.2 78.2c12.5-6 26.6-9.4 41.4-9.4c53 0 96 43 96 96c0 14.8-3.4 28.9-9.4 41.4l128 128c12.5-6 26.6-9.4 41.4-9.4c53 0 96 43 96 96s-43 96-96 96s-96-43-96-96c0-14.8 3.4-28.9 9.4-41.4L521.5 374.6a88.8 88.8 0 01-9.4 3.9v267c37.3 13.2 64 48.7 64 90.5c0 53-43 96-96 96s-96-43-96-96c0-41.8 26.7-77.3 64-90.5V378.5c-37.3-13.2-64-48.7-64-90.5c0-14.8 3.4-28.9 9.4-41.4l-78.2-78.2L19.4 464.3c-25.8 25.8-25.8 67.5 0 93.3l447.1 447.1c25.7 25.8 67.5 25.8 93.3 0l445-445c25.8-25.8 25.8-67.6 0-93.3z</Geometry>
|
||||
<Geometry x:Key="Icon.Submodule">M557.7 545.3 789.9 402.7c24-15 31.3-46.5 16.4-70.5c-14.8-23.8-46-31.2-70-16.7L506.5 456.6 277.1 315.4c-24.1-14.8-55.6-7.3-70.5 16.8c-14.8 24.1-7.3 55.6 16.8 70.5l231.8 142.6V819.1c0 28.3 22.9 51.2 51.2 51.2c28.3 0 51.2-22.9 51.2-51.2V545.3h.1zM506.5 0l443.4 256v511.9L506.5 1023.9 63.1 767.9v-511.9L506.5 0z</Geometry>
|
||||
<Geometry x:Key="Icon.SubTree">M491 256h469c13 0 21-9 21-21v-171c0-13-9-21-21-21h-469c-13 0-21 9-21 21V128H256V64c0-13-9-21-21-21h-171c-13 0-21 9-21 21v171c0 13 9 21 21 21H128v597h341v64c0 13 9 21 21 21h469c13 0 21-9 21-21v-171c0-13-9-21-21-21h-469c-13 0-21 9-21 21V811H171v-299h299v64c0 13 9 21 21 21h469c13 0 21-9 21-21v-171c0-13-9-21-21-21h-469c-13 0-21 9-21 21V469H171V256h64c13 0 21-9 21-21V171h213v64c0 13 9 21 21 21z</Geometry>
|
||||
<Geometry x:Key="Icon.LFS">M170 470l0 84 86 0 0-84-86 0zM86 598l0-172 852 0 0 172-852 0zM256 298l0-84-86 0 0 84 86 0zM86 170l852 0 0 172-852 0 0-172zM170 726l0 84 86 0 0-84-86 0zM86 854l0-172 852 0 0 172-852 0z</Geometry>
|
||||
<Geometry x:Key="Icon.NewPage">M853.3 960H170.7V64h469.3l213.3 213.3zM821.3 298.7H618.7V96z</Geometry>
|
||||
<Geometry x:Key="Icon.Bookmark">M192 0l0 1024 320-320 320 320 0-1024z</Geometry>
|
||||
<Geometry x:Key="Icon.Detail">M888.8 0H135.2c-32.3 0-58.9 26.1-58.9 58.9v906.2c0 32.3 26.1 58.9 58.9 58.9h753.2c32.3 0 58.9-26.1 58.9-58.9v-906.2c.5-32.8-26.1-58.9-58.4-58.9zm-164.9 176.6c30.7 0 55.8 25.1 55.8 55.8s-25.1 55.8-55.8 55.8s-55.8-25.1-55.8-55.8s24.6-55.8 55.8-55.8zm-212 0c30.7 0 55.8 25.1 55.8 55.8S542.7 288.3 512 288.3s-55.8-25.1-55.8-55.8S481.3 176.6 512 176.6zm-212 0c30.7 0 55.8 25.1 55.8 55.8s-25.1 55.8-55.8 55.8s-55.8-25.1-55.8-55.8s25.1-55.8 55.8-55.8zm208.9 606.2H285.2c-24.6 0-44-20-44-44c0-24.6 20-44 44-44h223.7c24.6 0 44 20 44 44c0 24.1-19.5 44-44 44zm229.9-212H285.2c-24.6 0-44-20-44-44c0-24.6 20-44 44-44h453.1c24.6 0 44 20 44 44c.5 24.1-19.5 44-43.5 44z</Geometry>
|
||||
<Geometry x:Key="Icon.NewTab">M490.7 85.3l42.7 0 0 853.3-42.7 0 0-853.3zM85.3 490.7l853.3 0 0 42.7-853.3 0 0-42.7z</Geometry>
|
||||
<Geometry x:Key="Icon.Copy">M682.7 42.7H85.3v682.7h85.3V128h512V42.7zM256 213.3l4.5 768H896V213.3H256zm554.7 682.7H341.3V298.7h469.3v597.3z</Geometry>
|
||||
|
||||
<Geometry x:Key="Icon.TreeAddNode">M204 291c45-11 77-49 77-96c0-53-43-98-98-98c-53 0-98 45-98 98c0 47 34 87 77 96v91c0 13 9 21 21 21h236c2 38 32 68 70 68h372c41 0 73-32 73-73v-38c0-41-32-73-73-73h-370c-38 0-70 30-70 68H204V291zm258 74h2c0-15 13-30 30-30h372c15 0 30 13 30 30v38c0 15-13 30-30 30h-375c-15 0-30-13-30-30v-38zM183 250c-30 0-55-26-55-55s26-55 55-55s55 26 55 55s-26 55-55 55zM679 495c-134 0-244 109-244 244s109 244 244 244c134 0 244-109 244-244s-109-244-244-244zm159 268h-134v134h-50V764H521v-50h134v-134h50v134h134V764zM244 766H185c-13 0-23-11-23-23s11-23 23-23h59c13 0 23 11 23 23s-11 23-23 23zM368 766h-42c-9 0-17-8-17-17v-13c0-9 8-17 17-17h42c9 0 17 8 17 17v13c0 9-8 17-17 17zM183 766c-12 0-21-9-21-21V320c0-12 9-21 21-21c12 0 21 9 21 21v425c0 12-10 21-21 21z</Geometry>
|
||||
|
||||
<Geometry x:Key="Icon.Minimize">M256 811h512v85H256z</Geometry>
|
||||
<Geometry x:Key="Icon.Maximize">M922 205v614H154V205h768zm-51 51H205v512h666V256z</Geometry>
|
||||
<Geometry x:Key="Icon.Close">M899 203 821 125 512 434 203 125 125 203 434 512 125 821 203 899 512 590 821 899 899 821 590 512z</Geometry>
|
||||
|
|
|
@ -128,6 +128,8 @@
|
|||
<sys:String x:Key="Text.Dashboard.Submodules">SUBMODULES</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Submodules.Add">ADD SUBMODULE</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Submodules.Update">UPDATE SUBMODULE</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.SubTrees">SUBTREES</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.SubTrees.Add">ADD/LINK SUBTREE</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Resolve">RESOLVE</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Continue">CONTINUE</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Abort">ABORT</sys:String>
|
||||
|
@ -425,7 +427,33 @@
|
|||
|
||||
<sys:String x:Key="Text.Restart.Title">NOTICE</sys:String>
|
||||
<sys:String x:Key="Text.Restart.Content">Restart required to apply changes in preference. Restart now?</sys:String>
|
||||
|
||||
|
||||
<sys:String x:Key="Text.AddSubTree">Add/Link SubTree</sys:String>
|
||||
<sys:String x:Key="Text.AddSubTree.Source">Source URL :</sys:String>
|
||||
<sys:String x:Key="Text.AddSubTree.Branch">Branch/Commit :</sys:String>
|
||||
<sys:String x:Key="Text.AddSubTree.Prefix">Local Relative Path :</sys:String>
|
||||
<sys:String x:Key="Text.AddSubTree.Squash">Squash commits?</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.EditSubTree">Edit SubTree</sys:String>
|
||||
<sys:String x:Key="Text.EditSubTree.Source">Source URL :</sys:String>
|
||||
<sys:String x:Key="Text.EditSubTree.Prefix">Local Relative Path :</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.UnlinkSubTree">Unlink SubTree</sys:String>
|
||||
<sys:String x:Key="Text.UnlinkSubTree.Prefix">Local Relative Path :</sys:String>
|
||||
<sys:String x:Key="Text.UnlinkSubTree.Tips">This will only remove links.</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Pull">Pull Changes Of SubTree</sys:String>
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Push">Push Changes Of SubTree</sys:String>
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Prefix">Local Relative Path :</sys:String>
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Source">Remote :</sys:String>
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Branch">Branch :</sys:String>
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Squash">Squash commits?</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.SubTree.Edit">Edit ...</sys:String>
|
||||
<sys:String x:Key="Text.SubTree.Unlink">Unlink ...</sys:String>
|
||||
<sys:String x:Key="Text.SubTree.Pull">Pull ...</sys:String>
|
||||
<sys:String x:Key="Text.SubTree.Push">Push ...</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.NotConfigured">Git has NOT been configured.\nPlease to go [Preference] and configure it first.</sys:String>
|
||||
<sys:String x:Key="Text.PathNotFound">Path[{0}] not exists!</sys:String>
|
||||
<sys:String x:Key="Text.MissingBash">Can NOT locate bash.exe. Make sure bash.exe exists under the same folder with git.exe</sys:String>
|
||||
|
@ -448,6 +476,7 @@
|
|||
<sys:String x:Key="Text.DuplicatedTagName">Duplicated tag name!</sys:String>
|
||||
<sys:String x:Key="Text.EmptyCommitMessage">Commit subject can NOT be empty</sys:String>
|
||||
<sys:String x:Key="Text.BadPatchFile">Invalid path for patch file</sys:String>
|
||||
<sys:String x:Key="Text.BadSubmodulePath">Invalid path for submodules</sys:String>
|
||||
<sys:String x:Key="Text.BadRelativePath">Invalid relative path</sys:String>
|
||||
<sys:String x:Key="Text.BadArchiveFile">Invalid path for archive file</sys:String>
|
||||
<sys:String x:Key="Text.Required">This field is required</sys:String>
|
||||
</ResourceDictionary>
|
|
@ -128,6 +128,8 @@
|
|||
<sys:String x:Key="Text.Dashboard.Submodules">子模块列表</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Submodules.Add">添加子模块</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Submodules.Update">更新子模块</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.SubTrees">子树列表</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.SubTrees.Add">添加子树</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Resolve">解决冲突</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Continue">下一步</sys:String>
|
||||
<sys:String x:Key="Text.Dashboard.Abort">终止冲突解决</sys:String>
|
||||
|
@ -426,6 +428,32 @@
|
|||
<sys:String x:Key="Text.Restart.Title">系统提示</sys:String>
|
||||
<sys:String x:Key="Text.Restart.Content">本次配置变更需要在重启后生效,是否立即重启?</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.AddSubTree">添加子树</sys:String>
|
||||
<sys:String x:Key="Text.AddSubTree.Source">远程地址:</sys:String>
|
||||
<sys:String x:Key="Text.AddSubTree.Branch">分支或提交ID:</sys:String>
|
||||
<sys:String x:Key="Text.AddSubTree.Prefix">本地相对路径:</sys:String>
|
||||
<sys:String x:Key="Text.AddSubTree.Squash">合并提交为单一提交</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.EditSubTree">编辑子树信息</sys:String>
|
||||
<sys:String x:Key="Text.EditSubTree.Source">远程地址:</sys:String>
|
||||
<sys:String x:Key="Text.EditSubTree.Prefix">本地相对路径:</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.UnlinkSubTree">删除子树</sys:String>
|
||||
<sys:String x:Key="Text.UnlinkSubTree.Prefix">本地相对路径:</sys:String>
|
||||
<sys:String x:Key="Text.UnlinkSubTree.Tips">本操作仅将子树信息删除,相关文件及提交不会更改</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Pull">拉取子树更新</sys:String>
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Push">推送子树更新到远程</sys:String>
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Prefix">本地相对路径:</sys:String>
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Source">远程地址:</sys:String>
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Branch">远程分支:</sys:String>
|
||||
<sys:String x:Key="Text.SubTreePullOrPush.Squash">合并提交为单一提交</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.SubTree.Edit">编辑子树 ...</sys:String>
|
||||
<sys:String x:Key="Text.SubTree.Unlink">删除子树 ...</sys:String>
|
||||
<sys:String x:Key="Text.SubTree.Pull">拉取子树更新</sys:String>
|
||||
<sys:String x:Key="Text.SubTree.Push">推送子树变更</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.NotConfigured">GIT尚未配置。请打开【偏好设置】配置GIT路径。</sys:String>
|
||||
<sys:String x:Key="Text.PathNotFound">路径({0})不存在或不可读取!</sys:String>
|
||||
<sys:String x:Key="Text.MissingBash">无法找到bash.exe,请确保其在git.exe同目录中!</sys:String>
|
||||
|
@ -448,6 +476,7 @@
|
|||
<sys:String x:Key="Text.DuplicatedTagName">标签名已存在!</sys:String>
|
||||
<sys:String x:Key="Text.EmptyCommitMessage">提交信息未填写!</sys:String>
|
||||
<sys:String x:Key="Text.BadPatchFile">补丁文件不存在或不可访问!</sys:String>
|
||||
<sys:String x:Key="Text.BadSubmodulePath">非法的子模块路径!</sys:String>
|
||||
<sys:String x:Key="Text.BadRelativePath">非法的子路径!</sys:String>
|
||||
<sys:String x:Key="Text.BadArchiveFile">非法的存档文件路径!</sys:String>
|
||||
<sys:String x:Key="Text.Required">内容未填写!</sys:String>
|
||||
</ResourceDictionary>
|
86
src/Views/Popups/AddSubTree.xaml
Normal file
86
src/Views/Popups/AddSubTree.xaml
Normal file
|
@ -0,0 +1,86 @@
|
|||
<controls:PopupWidget
|
||||
x:Class="SourceGit.Views.Popups.AddSubTree"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
xmlns:validations="clr-namespace:SourceGit.Views.Validations"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.AddSubTree.Source}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="0" Grid.Column="1"
|
||||
x:Name="txtSource"
|
||||
Height="24">
|
||||
<controls:TextEdit.Text>
|
||||
<Binding ElementName="me" Path="Source" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
|
||||
<Binding.ValidationRules>
|
||||
<validations:GitURL/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</controls:TextEdit.Text>
|
||||
</controls:TextEdit>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.AddSubTree.Branch}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="1" Grid.Column="1"
|
||||
x:Name="txtRef"
|
||||
Height="24">
|
||||
<controls:TextEdit.Text>
|
||||
<Binding ElementName="me" Path="Ref" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
|
||||
<Binding.ValidationRules>
|
||||
<validations:Required/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</controls:TextEdit.Text>
|
||||
</controls:TextEdit>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="2" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.AddSubTree.Prefix}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="2" Grid.Column="1"
|
||||
x:Name="txtPrefix"
|
||||
Height="24">
|
||||
<controls:TextEdit.Text>
|
||||
<Binding ElementName="me" Path="Prefix" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
|
||||
<Binding.ValidationRules>
|
||||
<validations:RelativePath/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</controls:TextEdit.Text>
|
||||
</controls:TextEdit>
|
||||
|
||||
<CheckBox
|
||||
Grid.Row="3" Grid.Column="1"
|
||||
Margin="0,4,0,0"
|
||||
x:Name="chkSquash"
|
||||
IsChecked="True"
|
||||
Content="{StaticResource Text.AddSubTree.Squash}"/>
|
||||
</Grid>
|
||||
</controls:PopupWidget>
|
57
src/Views/Popups/AddSubTree.xaml.cs
Normal file
57
src/Views/Popups/AddSubTree.xaml.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.Views.Popups {
|
||||
|
||||
/// <summary>
|
||||
/// 添加子树面板
|
||||
/// </summary>
|
||||
public partial class AddSubTree : Controls.PopupWidget {
|
||||
private Models.Repository repo = null;
|
||||
|
||||
public string Source { get; set; }
|
||||
public string Ref { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
|
||||
public AddSubTree(Models.Repository repo) {
|
||||
this.repo = repo;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override string GetTitle() {
|
||||
return App.Text("AddSubTree");
|
||||
}
|
||||
|
||||
public override Task<bool> Start() {
|
||||
txtSource.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||
if (Validation.GetHasError(txtSource)) return null;
|
||||
|
||||
txtPrefix.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||
if (Validation.GetHasError(txtPrefix)) return null;
|
||||
|
||||
txtRef.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||
if (Validation.GetHasError(txtRef)) return null;
|
||||
|
||||
var squash = chkSquash.IsChecked == true;
|
||||
if (repo.SubTrees.FindIndex(x => x.Prefix == Prefix) >= 0) {
|
||||
Models.Exception.Raise($"Subtree add failed. Prefix({Prefix}) already exists!");
|
||||
return null;
|
||||
}
|
||||
|
||||
return Task.Run(() => {
|
||||
Models.Watcher.SetEnabled(repo.Path, false);
|
||||
var succ = new Commands.SubTree(repo.Path).Add(Prefix, Source, Ref, squash, UpdateProgress);
|
||||
if (succ) {
|
||||
repo.SubTrees.Add(new Models.SubTree() {
|
||||
Prefix = Prefix,
|
||||
Remote = Source,
|
||||
});
|
||||
Models.Preference.Save();
|
||||
Models.Watcher.Get(repo.Path)?.RefreshSubTrees();
|
||||
}
|
||||
Models.Watcher.SetEnabled(repo.Path, true);
|
||||
return succ;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,7 +53,7 @@
|
|||
<controls:TextEdit.Text>
|
||||
<Binding ElementName="me" Path="Path" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
|
||||
<Binding.ValidationRules>
|
||||
<validations:SubmodulePath/>
|
||||
<validations:RelativePath/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</controls:TextEdit.Text>
|
||||
|
|
54
src/Views/Popups/EditSubTree.xaml
Normal file
54
src/Views/Popups/EditSubTree.xaml
Normal file
|
@ -0,0 +1,54 @@
|
|||
<controls:PopupWidget
|
||||
x:Class="SourceGit.Views.Popups.EditSubTree"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
xmlns:validations="clr-namespace:SourceGit.Views.Validations"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.EditSubTree.Prefix}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<StackPanel
|
||||
Grid.Row="0" Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icon.SubTree}"/>
|
||||
<TextBlock x:Name="txtPrefix" Margin="8,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.EditSubTree.Source}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="1" Grid.Column="1"
|
||||
x:Name="txtSource"
|
||||
Height="24">
|
||||
<controls:TextEdit.Text>
|
||||
<Binding ElementName="me" Path="Source" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
|
||||
<Binding.ValidationRules>
|
||||
<validations:GitURL/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</controls:TextEdit.Text>
|
||||
</controls:TextEdit>
|
||||
</Grid>
|
||||
</controls:PopupWidget>
|
34
src/Views/Popups/EditSubTree.xaml.cs
Normal file
34
src/Views/Popups/EditSubTree.xaml.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.Views.Popups {
|
||||
/// <summary>
|
||||
/// 编辑子树
|
||||
/// </summary>
|
||||
public partial class EditSubTree : Controls.PopupWidget {
|
||||
private Models.Repository repo;
|
||||
private Models.SubTree subtree;
|
||||
|
||||
public string Source {
|
||||
get { return subtree.Remote; }
|
||||
set { subtree.Remote = value; }
|
||||
}
|
||||
|
||||
public EditSubTree(Models.Repository repo, string prefix) {
|
||||
this.repo = repo;
|
||||
this.subtree = repo.SubTrees.Find(x => x.Prefix == prefix);
|
||||
InitializeComponent();
|
||||
txtPrefix.Text = prefix;
|
||||
}
|
||||
|
||||
public override string GetTitle() {
|
||||
return App.Text("EditSubTree");
|
||||
}
|
||||
|
||||
public override Task<bool> Start() {
|
||||
txtSource.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||
if (Validation.GetHasError(txtSource)) return null;
|
||||
return Task.Run(() => true);
|
||||
}
|
||||
}
|
||||
}
|
76
src/Views/Popups/SubTreePull.xaml
Normal file
76
src/Views/Popups/SubTreePull.xaml
Normal file
|
@ -0,0 +1,76 @@
|
|||
<controls:PopupWidget
|
||||
x:Class="SourceGit.Views.Popups.SubTreePull"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
xmlns:validations="clr-namespace:SourceGit.Views.Validations"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.SubTreePullOrPush.Prefix}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<StackPanel
|
||||
Grid.Row="0" Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icon.SubTree}"/>
|
||||
<TextBlock x:Name="txtPrefix" Margin="8,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.SubTreePullOrPush.Source}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<StackPanel
|
||||
Grid.Row="1" Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icon.Remote}"/>
|
||||
<TextBlock x:Name="txtSource" Margin="8,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="2" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.SubTreePullOrPush.Branch}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="2" Grid.Column="1"
|
||||
x:Name="txtBranch"
|
||||
Height="24">
|
||||
<controls:TextEdit.Text>
|
||||
<Binding ElementName="me" Path="Branch" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
|
||||
<Binding.ValidationRules>
|
||||
<validations:Required/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</controls:TextEdit.Text>
|
||||
</controls:TextEdit>
|
||||
|
||||
<CheckBox
|
||||
Grid.Row="3" Grid.Column="1"
|
||||
Margin="0,4,0,0"
|
||||
x:Name="chkSquash"
|
||||
IsChecked="True"
|
||||
Content="{StaticResource Text.SubTreePullOrPush.Squash}"/>
|
||||
</Grid>
|
||||
</controls:PopupWidget>
|
43
src/Views/Popups/SubTreePull.xaml.cs
Normal file
43
src/Views/Popups/SubTreePull.xaml.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.Views.Popups {
|
||||
/// <summary>
|
||||
/// 拉取
|
||||
/// </summary>
|
||||
public partial class SubTreePull : Controls.PopupWidget {
|
||||
private string repo;
|
||||
private Models.SubTree subtree;
|
||||
|
||||
public string Branch {
|
||||
get { return subtree.Branch; }
|
||||
set { subtree.Branch = value; }
|
||||
}
|
||||
|
||||
public SubTreePull(string repo, Models.SubTree subtree) {
|
||||
this.repo = repo;
|
||||
this.subtree = subtree;
|
||||
InitializeComponent();
|
||||
txtPrefix.Text = subtree.Prefix;
|
||||
txtSource.Text = subtree.Remote;
|
||||
}
|
||||
|
||||
public override string GetTitle() {
|
||||
return App.Text("SubTreePullOrPush.Pull");
|
||||
}
|
||||
|
||||
public override Task<bool> Start() {
|
||||
txtBranch.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||
if (Validation.GetHasError(txtBranch)) return null;
|
||||
|
||||
var squash = chkSquash.IsChecked == true;
|
||||
|
||||
return Task.Run(() => {
|
||||
Models.Watcher.SetEnabled(repo, false);
|
||||
new Commands.SubTree(repo).Pull(subtree.Prefix, subtree.Remote, Branch, squash, UpdateProgress);
|
||||
Models.Watcher.SetEnabled(repo, true);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
68
src/Views/Popups/SubTreePush.xaml
Normal file
68
src/Views/Popups/SubTreePush.xaml
Normal file
|
@ -0,0 +1,68 @@
|
|||
<controls:PopupWidget
|
||||
x:Class="SourceGit.Views.Popups.SubTreePush"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
xmlns:validations="clr-namespace:SourceGit.Views.Validations"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.SubTreePullOrPush.Prefix}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<StackPanel
|
||||
Grid.Row="0" Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icon.SubTree}"/>
|
||||
<TextBlock x:Name="txtPrefix" Margin="8,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.SubTreePullOrPush.Source}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<StackPanel
|
||||
Grid.Row="1" Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icon.Remote}"/>
|
||||
<TextBlock x:Name="txtSource" Margin="8,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="2" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.SubTreePullOrPush.Branch}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<controls:TextEdit
|
||||
Grid.Row="2" Grid.Column="1"
|
||||
x:Name="txtBranch"
|
||||
Height="24">
|
||||
<controls:TextEdit.Text>
|
||||
<Binding ElementName="me" Path="Branch" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
|
||||
<Binding.ValidationRules>
|
||||
<validations:Required/>
|
||||
</Binding.ValidationRules>
|
||||
</Binding>
|
||||
</controls:TextEdit.Text>
|
||||
</controls:TextEdit>
|
||||
</Grid>
|
||||
</controls:PopupWidget>
|
41
src/Views/Popups/SubTreePush.xaml.cs
Normal file
41
src/Views/Popups/SubTreePush.xaml.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.Views.Popups {
|
||||
/// <summary>
|
||||
/// 推送
|
||||
/// </summary>
|
||||
public partial class SubTreePush : Controls.PopupWidget {
|
||||
private string repo;
|
||||
private Models.SubTree subtree;
|
||||
|
||||
public string Branch {
|
||||
get { return subtree.Branch; }
|
||||
set { subtree.Branch = value; }
|
||||
}
|
||||
|
||||
public SubTreePush(string repo, Models.SubTree subtree) {
|
||||
this.repo = repo;
|
||||
this.subtree = subtree;
|
||||
InitializeComponent();
|
||||
txtPrefix.Text = subtree.Prefix;
|
||||
txtSource.Text = subtree.Remote;
|
||||
}
|
||||
|
||||
public override string GetTitle() {
|
||||
return App.Text("SubTreePullOrPush.Push");
|
||||
}
|
||||
|
||||
public override Task<bool> Start() {
|
||||
txtBranch.GetBindingExpression(TextBox.TextProperty).UpdateSource();
|
||||
if (Validation.GetHasError(txtBranch)) return null;
|
||||
|
||||
return Task.Run(() => {
|
||||
Models.Watcher.SetEnabled(repo, false);
|
||||
new Commands.SubTree(repo).Push(subtree.Prefix, subtree.Remote, Branch, UpdateProgress);
|
||||
Models.Watcher.SetEnabled(repo, true);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
40
src/Views/Popups/UnlinkSubTree.xaml
Normal file
40
src/Views/Popups/UnlinkSubTree.xaml
Normal file
|
@ -0,0 +1,40 @@
|
|||
<controls:PopupWidget
|
||||
x:Class="SourceGit.Views.Popups.UnlinkSubTree"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="0" Grid.Column="0"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.UnlinkSubTree.Prefix}"
|
||||
HorizontalAlignment="Right"/>
|
||||
<StackPanel
|
||||
Grid.Row="0" Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
VerticalAlignment="Center">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icon.SubTree}"/>
|
||||
<TextBlock x:Name="txtPrefix" Margin="8,0,0,0"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="1" Grid.Column="1"
|
||||
Margin="0,0,8,0"
|
||||
Text="{StaticResource Text.UnlinkSubTree.Tips}"
|
||||
HorizontalAlignment="Left"/>
|
||||
</Grid>
|
||||
</controls:PopupWidget>
|
34
src/Views/Popups/UnlinkSubTree.xaml.cs
Normal file
34
src/Views/Popups/UnlinkSubTree.xaml.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace SourceGit.Views.Popups {
|
||||
/// <summary>
|
||||
/// 删除子树
|
||||
/// </summary>
|
||||
public partial class UnlinkSubTree : Controls.PopupWidget {
|
||||
private Models.Repository repo;
|
||||
private string prefix;
|
||||
|
||||
public UnlinkSubTree(Models.Repository repo, string prefix) {
|
||||
this.repo = repo;
|
||||
this.prefix = prefix;
|
||||
InitializeComponent();
|
||||
txtPrefix.Text = prefix;
|
||||
}
|
||||
|
||||
public override string GetTitle() {
|
||||
return App.Text("UnlinkSubTree");
|
||||
}
|
||||
|
||||
public override Task<bool> Start() {
|
||||
return Task.Run(() => {
|
||||
var idx = repo.SubTrees.FindIndex(x => x.Prefix == prefix);
|
||||
if (idx >= 0) {
|
||||
repo.SubTrees.RemoveAt(idx);
|
||||
Models.Preference.Save();
|
||||
Models.Watcher.Get(repo.Path)?.RefreshSubTrees();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +1,16 @@
|
|||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.Views.Validations {
|
||||
public class SubmodulePath : ValidationRule {
|
||||
public class RelativePath : ValidationRule {
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
|
||||
var path = value as string;
|
||||
if (string.IsNullOrEmpty(path)) return ValidationResult.ValidResult;
|
||||
|
||||
var regex = new Regex(@"^[\w\-\._/]+$");
|
||||
var succ = regex.IsMatch(path.Trim());
|
||||
return !succ ? new ValidationResult(false, App.Text("BadSubmodulePath")) : ValidationResult.ValidResult;
|
||||
return !succ ? new ValidationResult(false, App.Text("BadRelativePath")) : ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
}
|
13
src/Views/Validations/Required.cs
Normal file
13
src/Views/Validations/Required.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using System.Globalization;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.Views.Validations {
|
||||
public class Required : ValidationRule {
|
||||
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
|
||||
var path = value as string;
|
||||
return string.IsNullOrEmpty(path) ?
|
||||
new ValidationResult(false, App.Text("Required")) :
|
||||
ValidationResult.ValidResult;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -110,6 +110,8 @@
|
|||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="24"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="24"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.Resources>
|
||||
|
@ -326,7 +328,7 @@
|
|||
Grid.Row="7"
|
||||
x:Name="tagList"
|
||||
RowHeight="24"
|
||||
Height="200"
|
||||
MaxHeight="200"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Visibility="{Binding ElementName=tglTags, Path=IsChecked, Converter={StaticResource BoolToCollapsed}}"
|
||||
|
@ -386,7 +388,7 @@
|
|||
Grid.Row="9"
|
||||
x:Name="submoduleList"
|
||||
RowHeight="24"
|
||||
Height="100"
|
||||
MaxHeight="100"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Visibility="{Binding ElementName=tglSubmodules, Path=IsChecked, Converter={StaticResource BoolToCollapsed}}"
|
||||
|
@ -411,6 +413,52 @@
|
|||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<!-- SUBTREES -->
|
||||
<ToggleButton
|
||||
Grid.Row="10"
|
||||
x:Name="tglSubTrees"
|
||||
Style="{StaticResource Style.ToggleButton.Expender}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Margin="8,0,0,0" Text="{StaticResource Text.Dashboard.SubTrees}" FontWeight="DemiBold" Foreground="{StaticResource Brush.FG2}"/>
|
||||
<TextBlock Grid.Column="1" x:Name="txtSubTreeCount" FontWeight="DemiBold" Margin="4,0,0,0" Foreground="{StaticResource Brush.FG2}"/>
|
||||
<controls:IconButton Grid.Column="2" Click="OpenAddSubTree" Width="14" Height="14" Margin="0,0,4,0" Icon="{StaticResource Icon.TreeAddNode}" ToolTip="{StaticResource Text.Dashboard.SubTrees.Add}"/>
|
||||
</Grid>
|
||||
</ToggleButton>
|
||||
<DataGrid
|
||||
Grid.Row="11"
|
||||
x:Name="subTreeList"
|
||||
RowHeight="24"
|
||||
MaxHeight="100"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
Visibility="{Binding ElementName=tglSubTrees, Path=IsChecked, Converter={StaticResource BoolToCollapsed}}"
|
||||
SelectionMode="Single"
|
||||
SelectionUnit="FullRow"
|
||||
ContextMenuOpening="OnSubTreeContextMenuOpening">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Width="*">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Path Grid.Column="0" Width="10" Height="10" Margin="16,0,8,0" Data="{StaticResource Icon.SubTree}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Prefix}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
<!-- Splitter -->
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace SourceGit.Views.Widgets {
|
|||
UpdateStashes();
|
||||
UpdateTags();
|
||||
UpdateSubmodules();
|
||||
UpdateSubTrees();
|
||||
|
||||
var watcher = Models.Watcher.Get(repo.Path);
|
||||
watcher.Navigate += NavigateTo;
|
||||
|
@ -68,6 +69,7 @@ namespace SourceGit.Views.Widgets {
|
|||
watcher.StashChanged += UpdateStashes;
|
||||
watcher.TagChanged += UpdateTags;
|
||||
watcher.SubmoduleChanged += UpdateSubmodules;
|
||||
watcher.SubTreeChanged += UpdateSubTrees;
|
||||
|
||||
Unloaded += (o, e) => {
|
||||
localBranches.Clear();
|
||||
|
@ -257,6 +259,14 @@ namespace SourceGit.Views.Widgets {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateSubTrees() {
|
||||
Dispatcher.Invoke(() => {
|
||||
txtSubTreeCount.Text = $"({repo.SubTrees.Count})";
|
||||
subTreeList.ItemsSource = null;
|
||||
subTreeList.ItemsSource = repo.SubTrees;
|
||||
});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TOOLBAR_COMMANDS
|
||||
|
@ -909,6 +919,55 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region SUBTREES
|
||||
private void OpenAddSubTree(object sender, RoutedEventArgs e) {
|
||||
new Popups.AddSubTree(repo).Show();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnSubTreeContextMenuOpening(object sender, ContextMenuEventArgs e) {
|
||||
var subtree = subTreeList.SelectedItem as Models.SubTree;
|
||||
if (subtree == null) return;
|
||||
|
||||
var edit = new MenuItem();
|
||||
edit.Header = App.Text("SubTree.Edit");
|
||||
edit.Click += (o, ev) => {
|
||||
new Popups.EditSubTree(repo, subtree.Prefix).Show();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var unlink = new MenuItem();
|
||||
unlink.Header = App.Text("SubTree.Unlink");
|
||||
unlink.Click += (o, ev) => {
|
||||
new Popups.UnlinkSubTree(repo, subtree.Prefix).Show();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var pull = new MenuItem();
|
||||
pull.Header = App.Text("SubTree.Pull");
|
||||
pull.Click += (o, ev) => {
|
||||
new Popups.SubTreePull(repo.Path, subtree).Show();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var push = new MenuItem();
|
||||
push.Header = App.Text("SubTree.Push");
|
||||
push.Click += (o, ev) => {
|
||||
new Popups.SubTreePush(repo.Path, subtree).Show();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(edit);
|
||||
menu.Items.Add(unlink);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(pull);
|
||||
menu.Items.Add(push);
|
||||
menu.IsOpen = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region FILTERS
|
||||
private void OnFilterChanged(object sender, RoutedEventArgs e) {
|
||||
var toggle = sender as ToggleButton;
|
||||
|
|
Loading…
Reference in a new issue