mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 04:04:59 +00:00
refactor: rewrite OpenAI integration
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
f6e1e65a53
commit
d21a8f2449
5 changed files with 52 additions and 53 deletions
|
@ -33,11 +33,6 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public class WorkingCopy : ObservableObject
|
||||
{
|
||||
public string RepoPath
|
||||
{
|
||||
get => _repo.FullPath;
|
||||
}
|
||||
|
||||
public bool IncludeUntracked
|
||||
{
|
||||
get => _repo.IncludeUntracked;
|
||||
|
@ -408,6 +403,25 @@ namespace SourceGit.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public void GenerateCommitMessageByAI()
|
||||
{
|
||||
if (!Models.OpenAI.IsValid)
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "Bad configuration for OpenAI");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_staged is { Count: > 0 })
|
||||
{
|
||||
var dialog = new Views.AIAssistant(_repo.FullPath, _staged, generated => CommitMessage = generated);
|
||||
App.OpenDialog(dialog);
|
||||
}
|
||||
else
|
||||
{
|
||||
App.RaiseException(_repo.FullPath, "No files added to commit!");
|
||||
}
|
||||
}
|
||||
|
||||
public void Commit()
|
||||
{
|
||||
DoCommit(false, false, false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue