Disable 'Commit&Push' when commit with --amend option

This commit is contained in:
leo 2020-07-08 09:34:15 +08:00
parent 02e45f2928
commit 270b07684c
2 changed files with 14 additions and 2 deletions

View file

@ -368,7 +368,7 @@
<Path Width="14" Height="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.List}"/>
</Button>
<CheckBox Grid.Column="1" x:Name="chkAmend" HorizontalAlignment="Left" Content="Amend" Checked="StartAmend"/>
<CheckBox Grid.Column="1" x:Name="chkAmend" HorizontalAlignment="Left" Content="Amend" Checked="StartAmend" Unchecked="EndAmend"/>
<Button Grid.Column="3" Height="26" Click="Commit" Style="{StaticResource Style.Button.AccentBordered}" Content="COMMIT"/>
<Button Grid.Column="4" x:Name="btnCommitAndPush" Height="26" Click="CommitAndPush" Style="{StaticResource Style.Button.Bordered}" Content="COMMIT &amp; PUSH" Margin="8,0,0,0"/>

View file

@ -79,7 +79,7 @@ namespace SourceGit.UI {
Dispatcher.Invoke(() => {
var current = Repo.CurrentBranch();
if (current != null && !string.IsNullOrEmpty(current.Upstream)) {
if (current != null && !string.IsNullOrEmpty(current.Upstream) && chkAmend.IsChecked != true) {
btnCommitAndPush.Visibility = Visibility.Visible;
} else {
btnCommitAndPush.Visibility = Visibility.Collapsed;
@ -750,6 +750,18 @@ namespace SourceGit.UI {
}
txtCommitMsg.Text = commits[0].Subject;
btnCommitAndPush.Visibility = Visibility.Collapsed;
}
private void EndAmend(object sender, RoutedEventArgs e) {
if (!IsLoaded) return;
var current = Repo.CurrentBranch();
if (current != null && !string.IsNullOrEmpty(current.Upstream)) {
btnCommitAndPush.Visibility = Visibility.Visible;
} else {
btnCommitAndPush.Visibility = Visibility.Collapsed;
}
}
private async void Commit(object sender, RoutedEventArgs e) {