Skip to content

Commit

Permalink
Update Src/AiCommitMessage/Services/GenerateCommitMessageService.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
gitauto-ai[bot] authored Dec 13, 2024
1 parent ce6d1df commit 7ea53ab
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Src/AiCommitMessage/Services/GenerateCommitMessageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,24 @@ public string GenerateCommitMessage(GenerateCommitMessageOptions options)
? GitHelper.GetBranchName()
: options.Branch;
var diff = string.IsNullOrEmpty(options.Diff) ? GitHelper.GetGitDiff() : options.Diff;
if (Encoding.UTF8.GetByteCount(diff) > 10240) // 10 KB limit
{
throw new InvalidOperationException("🚫 The staged changes are too large to process. Please reduce the number of files or size of changes and try again.");
}

var message = options.Message;

if (IsMergeConflictResolution(message))
{
return message;
}
try
{
// Existing code to call OpenAI API
}
catch (Exception ex) when (ex is HttpRequestException || ex is TaskCanceledException)

Check failure on line 68 in Src/AiCommitMessage/Services/GenerateCommitMessageService.cs

View workflow job for this annotation

GitHub Actions / Build

{ expected

Check failure on line 68 in Src/AiCommitMessage/Services/GenerateCommitMessageService.cs

View workflow job for this annotation

GitHub Actions / Build

{ expected

Check failure on line 68 in Src/AiCommitMessage/Services/GenerateCommitMessageService.cs

View workflow job for this annotation

GitHub Actions / Build

{ expected

Check failure on line 68 in Src/AiCommitMessage/Services/GenerateCommitMessageService.cs

View workflow job for this annotation

GitHub Actions / Build

{ expected

throw new InvalidOperationException("⚠️ OpenAI API is currently unavailable. Please try again later.");

if (string.IsNullOrEmpty(branch) && string.IsNullOrEmpty(diff))
{
Expand Down

0 comments on commit 7ea53ab

Please sign in to comment.