enhance: notify user when try to generate commit message by OpenAI but not files are added to commit

This commit is contained in:
leo 2024-09-13 15:26:12 +08:00
parent cc6e486663
commit 5c2583db67
No known key found for this signature in database

View file

@ -125,15 +125,22 @@ namespace SourceGit.Views
{
if (!Models.OpenAI.IsValid)
{
App.RaiseException(null, $"Bad configuration for OpenAI");
App.RaiseException(null, "Bad configuration for OpenAI");
return;
}
if (DataContext is ViewModels.WorkingCopy vm && vm.Staged is { Count: > 0 })
if (DataContext is ViewModels.WorkingCopy vm)
{
var dialog = new AIAssistant() { DataContext = vm };
dialog.GenerateCommitMessage();
App.OpenDialog(dialog);
if (vm.Staged is { Count: > 0 })
{
var dialog = new AIAssistant() { DataContext = vm };
dialog.GenerateCommitMessage();
App.OpenDialog(dialog);
}
else
{
App.RaiseException(null, "No files added to commit!");
}
}
e.Handled = true;