mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
enhance: forbid to reword or squash when there're local changes
This commit is contained in:
parent
3b7545e4fb
commit
2d4f8709ca
3 changed files with 43 additions and 33 deletions
|
@ -217,6 +217,12 @@ namespace SourceGit.ViewModels
|
|||
reword.Icon = App.CreateMenuIcon("Icons.Edit");
|
||||
reword.Click += (o, e) =>
|
||||
{
|
||||
if (_repo.WorkingCopyChangesCount > 0)
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (PopupHost.CanCreatePopup())
|
||||
PopupHost.ShowPopup(new Reword(_repo, commit));
|
||||
e.Handled = true;
|
||||
|
@ -229,6 +235,12 @@ namespace SourceGit.ViewModels
|
|||
squash.IsEnabled = commit.Parents.Count == 1;
|
||||
squash.Click += (o, e) =>
|
||||
{
|
||||
if (_repo.WorkingCopyChangesCount > 0)
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "You have local changes. Please run stash or discard first.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (commit.Parents.Count == 1)
|
||||
{
|
||||
var parent = _commits.Find(x => x.SHA == commit.Parents[0]);
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace SourceGit.ViewModels
|
|||
public Squash(Repository repo, Models.Commit head, Models.Commit parent)
|
||||
{
|
||||
_repo = repo;
|
||||
_message = new Commands.QueryCommitFullMessage(_repo.FullPath, parent.SHA).Result();
|
||||
_message = new Commands.QueryCommitFullMessage(_repo.FullPath, head.SHA).Result();
|
||||
|
||||
Head = head;
|
||||
Parent = parent;
|
||||
|
|
|
@ -12,40 +12,38 @@
|
|||
<TextBlock FontSize="18"
|
||||
Classes="bold"
|
||||
Text="{DynamicResource Text.Squash}"/>
|
||||
<Grid Margin="0,16,0,0" RowDefinitions="28,28,120,Auto" ColumnDefinitions="100,*">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.Squash.Head}"/>
|
||||
<Grid Grid.Row="0" Grid.Column="1" ColumnDefinitions="Auto,Auto,*" Height="20" VerticalAlignment="Center">
|
||||
<Path Grid.Column="0" Margin="0,6,8,0" Width="14" Height="14" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Commit}"/>
|
||||
<TextBlock Grid.Column="1" Classes="monospace" Text="{Binding Head.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Foreground="DarkOrange"/>
|
||||
<TextBlock Grid.Column="2" Text="{Binding Head.Subject}" Margin="8,0,0,0" TextTrimming="CharacterEllipsis"/>
|
||||
|
||||
<Grid Margin="0,18,0,0" ColumnDefinitions="Auto,Auto,Auto,Auto,*">
|
||||
<Border Grid.Column="0" Background="{DynamicResource Brush.Accent}" CornerRadius="4">
|
||||
<TextBlock Text="HEAD" Classes="monospace" Margin="4,0" Foreground="#FFDDDDDD"/>
|
||||
</Border>
|
||||
|
||||
<Path Grid.Column="1"
|
||||
Width="14" Height="14"
|
||||
Margin="12,0,0,0"
|
||||
Fill="{DynamicResource Brush.FG1}"
|
||||
Data="{StaticResource Icons.Down}"
|
||||
VerticalAlignment="Center"
|
||||
RenderTransformOrigin="50%,50%"
|
||||
RenderTransform="rotate(270deg)"/>
|
||||
|
||||
<Path Grid.Column="2"
|
||||
Margin="6,6,8,0"
|
||||
Width="14" Height="14"
|
||||
Fill="{DynamicResource Brush.FG1}"
|
||||
Data="{StaticResource Icons.Commit}"/>
|
||||
<TextBlock Grid.Column="3"
|
||||
Classes="monospace"
|
||||
Text="{Binding Parent.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||
Foreground="DarkOrange"/>
|
||||
<TextBlock Grid.Column="4" Margin="8,0,0,0" Text="{Binding Parent.Subject}" TextTrimming="CharacterEllipsis"/>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,8,0"
|
||||
Text="{DynamicResource Text.Squash.To}"/>
|
||||
<Grid Grid.Row="1" Grid.Column="1" ColumnDefinitions="Auto,Auto,*" Height="20" VerticalAlignment="Center">
|
||||
<Path Grid.Column="0" Margin="0,6,8,0" Width="14" Height="14" Fill="{DynamicResource Brush.FG1}" Data="{StaticResource Icons.Commit}"/>
|
||||
<TextBlock Grid.Column="1" Classes="monospace" Text="{Binding Parent.SHA, Converter={x:Static c:StringConverters.ToShortSHA}}" Foreground="DarkOrange"/>
|
||||
<TextBlock Grid.Column="2" Text="{Binding Parent.Subject}" Margin="8,0,0,0" TextTrimming="CharacterEllipsis"/>
|
||||
</Grid>
|
||||
<v:CommitMessageTextBox Height="120" Margin="0,4,0,0" Text="{Binding Message, Mode=TwoWay}"/>
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Top"
|
||||
Margin="0,5,8,0"
|
||||
Text="{DynamicResource Text.Squash.Message}"/>
|
||||
<v:CommitMessageTextBox Grid.Row="2" Grid.Column="1"
|
||||
Margin="0,4,0,0"
|
||||
Text="{Binding Message, Mode=TwoWay}"/>
|
||||
|
||||
<TextBlock Grid.Row="3" Grid.Column="1"
|
||||
Margin="0,4,0,0"
|
||||
<TextBlock Margin="0,6,0,0"
|
||||
Text="{DynamicResource Text.Reword.Tip}"
|
||||
TextWrapping="Wrap"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
|
Loading…
Reference in a new issue