mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-28 15:45:00 +00:00
feature<AssumeUnchanged>: supports update-index --[no]-assume-unchanged
This commit is contained in:
parent
79b5136a46
commit
f13b1ee9fe
9 changed files with 272 additions and 3 deletions
100
src/Views/AssumeUnchanged.xaml
Normal file
100
src/Views/AssumeUnchanged.xaml
Normal file
|
@ -0,0 +1,100 @@
|
|||
<controls:Window
|
||||
x:Class="SourceGit.Views.AssumeUnchanged"
|
||||
x:Name="me"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
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:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Title="{DynamicResource Text.AssumeUnchanged}"
|
||||
Width="600" MinHeight="200" SizeToContent="Height"
|
||||
ResizeMode="NoResize">
|
||||
<Window.Resources>
|
||||
<Style x:Key="Style.DataGridRow.Change" TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource Style.DataGridRow}">
|
||||
<EventSetter Event="RequestBringIntoView" Handler="OnRequestBringIntoView"/>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="1"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Title bar -->
|
||||
<Grid Grid.Row="0" Background="{DynamicResource Brush.TitleBar}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Icon -->
|
||||
<Path Grid.Column="0" Margin="6,0" Width="16" Height="16" Data="{StaticResource Icon.Ignores}"/>
|
||||
|
||||
<!-- Title -->
|
||||
<TextBlock Grid.Column="1" Text="{DynamicResource Text.AssumeUnchanged}"/>
|
||||
|
||||
<!-- Close -->
|
||||
<controls:IconButton
|
||||
Grid.Column="3"
|
||||
Click="OnQuit"
|
||||
Width="28"
|
||||
IconSize="10"
|
||||
Icon="{StaticResource Icon.Close}"
|
||||
HoverBackground="Red"
|
||||
WindowChrome.IsHitTestVisibleInChrome="True"/>
|
||||
</Grid>
|
||||
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
Height="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
Fill="{DynamicResource Brush.Border0}"/>
|
||||
|
||||
<DataGrid
|
||||
Grid.Row="2"
|
||||
x:Name="list"
|
||||
Margin="8,4"
|
||||
RowHeight="24"
|
||||
SelectionMode="Extended"
|
||||
SelectionUnit="FullRow"
|
||||
Background="{DynamicResource Brush.Contents}"
|
||||
ItemsSource="{Binding ElementName=me, Path=Files}"
|
||||
RowStyle="{StaticResource Style.DataGridRow.Change}"
|
||||
Visibility="Collapsed">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn IsReadOnly="True" Width="*">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Margin="8,0" Text="{Binding .}" FontSize="14"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Width="32">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<controls:IconButton
|
||||
Grid.Column="6"
|
||||
Click="Remove"
|
||||
Width="12" Height="12"
|
||||
Margin="4,0"
|
||||
Icon="{StaticResource Icon.Close}"
|
||||
ToolTip="{DynamicResource Text.AssumeUnchanged.Remove}"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<StackPanel Grid.Row="2" x:Name="mask" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed">
|
||||
<Path Width="48" Height="48" Margin="0,32,0,8" Data="{StaticResource Icon.Empty}" Fill="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock Margin="0,0,0,32" Text="{DynamicResource Text.AssumeUnchanged.Empty}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</controls:Window>
|
64
src/Views/AssumeUnchanged.xaml.cs
Normal file
64
src/Views/AssumeUnchanged.xaml.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using System.Collections.ObjectModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SourceGit.Views {
|
||||
/// <summary>
|
||||
/// 管理不跟踪变更的文件
|
||||
/// </summary>
|
||||
public partial class AssumeUnchanged : Controls.Window {
|
||||
private string repo = null;
|
||||
|
||||
public ObservableCollection<string> Files { get; set; }
|
||||
|
||||
public AssumeUnchanged(string repo) {
|
||||
this.repo = repo;
|
||||
this.Files = new ObservableCollection<string>();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
Task.Run(() => {
|
||||
var unchanged = new Commands.AssumeUnchanged(repo).View();
|
||||
Dispatcher.Invoke(() => {
|
||||
if (unchanged.Count > 0) {
|
||||
foreach (var file in unchanged) Files.Add(file);
|
||||
|
||||
mask.Visibility = Visibility.Collapsed;
|
||||
list.Visibility = Visibility.Visible;
|
||||
list.ItemsSource = Files;
|
||||
} else {
|
||||
list.Visibility = Visibility.Collapsed;
|
||||
mask.Visibility = Visibility.Visible;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void OnQuit(object sender, RoutedEventArgs e) {
|
||||
Close();
|
||||
}
|
||||
|
||||
private void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e) {
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void Remove(object sender, RoutedEventArgs e) {
|
||||
var btn = sender as Button;
|
||||
if (btn == null) return;
|
||||
|
||||
var file = btn.DataContext as string;
|
||||
if (file == null) return;
|
||||
|
||||
new Commands.AssumeUnchanged(repo).Remove(file);
|
||||
Files.Remove(file);
|
||||
|
||||
if (Files.Count == 0) {
|
||||
list.Visibility = Visibility.Collapsed;
|
||||
mask.Visibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -41,6 +41,7 @@
|
|||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:ChangeDisplaySwitcher
|
||||
|
@ -61,8 +62,15 @@
|
|||
x:Name="iconStaging"
|
||||
IsAnimating="{Binding ElementName=unstagedContainer, Path=IsStaging}"
|
||||
Visibility="{Binding ElementName=unstagedContainer, Path=IsStaging, Converter={StaticResource BoolToCollapsed}}"/>
|
||||
<ToggleButton
|
||||
<controls:IconButton
|
||||
Grid.Column="4"
|
||||
Click="ViewAssumeUnchanged"
|
||||
Width="14" Height="14"
|
||||
Margin="4,0"
|
||||
Icon="{StaticResource Icon.Ignores}"
|
||||
ToolTip="{DynamicResource Text.WorkingCopy.Unstaged.ViewAssumeUnchaged}"/>
|
||||
<ToggleButton
|
||||
Grid.Column="5"
|
||||
Width="14" Height="14"
|
||||
Margin="4,0"
|
||||
Style="{StaticResource Style.ToggleButton.Eye}"
|
||||
|
@ -70,14 +78,14 @@
|
|||
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Git.IncludeUntrackedInWC, Mode=TwoWay}"
|
||||
Checked="ToggleIncludeUntracked" Unchecked="ToggleIncludeUntracked"/>
|
||||
<controls:IconButton
|
||||
Grid.Column="5"
|
||||
Grid.Column="6"
|
||||
Click="StageSelected"
|
||||
Width="14" Height="14"
|
||||
Margin="4,0"
|
||||
Icon="{StaticResource Icon.Down}"
|
||||
ToolTip="{DynamicResource Text.WorkingCopy.Unstaged.Stage}"/>
|
||||
<controls:IconButton
|
||||
Grid.Column="6"
|
||||
Grid.Column="7"
|
||||
Click="StageAll"
|
||||
Width="14" Height="14"
|
||||
Margin="4,0"
|
||||
|
|
|
@ -98,6 +98,12 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
|
||||
#region STAGE_UNSTAGE
|
||||
private void ViewAssumeUnchanged(object sender, RoutedEventArgs e) {
|
||||
var dialog = new AssumeUnchanged(repo.Path);
|
||||
dialog.Owner = App.Current.MainWindow;
|
||||
dialog.ShowDialog();
|
||||
}
|
||||
|
||||
private void StageSelected(object sender, RoutedEventArgs e) {
|
||||
unstagedContainer.StageSelected();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.Win32;
|
||||
using SourceGit.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
@ -484,6 +485,14 @@ namespace SourceGit.Views.Widgets {
|
|||
menu.Items.Add(patch);
|
||||
menu.Items.Add(new Separator());
|
||||
if (node.Change != null) {
|
||||
var assumeUnchanged = new MenuItem();
|
||||
assumeUnchanged.Header = App.Text("FileCM.AssumeUnchanged");
|
||||
assumeUnchanged.Click += (o, e) => {
|
||||
new Commands.AssumeUnchanged(repo).Add(node.Path);
|
||||
e.Handled = true;
|
||||
};
|
||||
menu.Items.Add(assumeUnchanged);
|
||||
|
||||
var history = new MenuItem();
|
||||
history.Header = App.Text("FileHistory");
|
||||
history.Click += (o, e) => {
|
||||
|
@ -622,6 +631,13 @@ namespace SourceGit.Views.Widgets {
|
|||
e.Handled = true;
|
||||
};
|
||||
|
||||
var assumeUnchanged = new MenuItem();
|
||||
assumeUnchanged.Header = App.Text("FileCM.AssumeUnchanged");
|
||||
assumeUnchanged.Click += (o, e) => {
|
||||
new Commands.AssumeUnchanged(repo).Add(change.Path);
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(explore);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(stage);
|
||||
|
@ -629,6 +645,7 @@ namespace SourceGit.Views.Widgets {
|
|||
menu.Items.Add(stash);
|
||||
menu.Items.Add(patch);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(assumeUnchanged);
|
||||
menu.Items.Add(history);
|
||||
menu.Items.Add(new Separator());
|
||||
menu.Items.Add(copyPath);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue