Skip to content

Comments

feat: Get-AiMessageForCommit#1

Merged
rulasg merged 5 commits intomainfrom
Get-AiMessageForCommit
Aug 5, 2025
Merged

feat: Get-AiMessageForCommit#1
rulasg merged 5 commits intomainfrom
Get-AiMessageForCommit

Conversation

@rulasg
Copy link
Owner

@rulasg rulasg commented Aug 3, 2025

Get a commit message based on git staged changes and instructions

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@@ -0,0 +1,70 @@
function Get-AiMessageForCommit{

Check notice

Code scanning / PSScriptAnalyzer

The cmdlet 'Get-AiMessageForCommit' does not have a help comment. Note

The cmdlet 'Get-AiMessageForCommit' does not have a help comment.
$gitdifff = git diff --staged

if ([string]::IsNullOrWhiteSpace($gitdifff)) {
Write-Host "No staged changes found. Please stage your changes before generating a commit message." -ForegroundColor Yellow

Check warning

Code scanning / PSScriptAnalyzer

File 'getCommitPrompt.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information. Warning

File 'getCommitPrompt.ps1' uses Write-Host. Avoid using Write-Host because it might not work in all hosts, does not work when there is no host, and (prior to PS 5.0) cannot be suppressed, captured, or redirected. Instead, use Write-Output, Write-Verbose, or Write-Information.
$p = @()
$p += "Follow these instructions: [ $instructions ]"
$sysPrompt = $p -join "`n"

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace

$message = gh models run $Model "$usrprompt" --system-prompt $sysPrompt

$global:message = $message | Out-String

Check warning

Code scanning / PSScriptAnalyzer

Found global variable 'global:message'. Warning

Found global variable 'global:message'.

} Export-ModuleMember -Function Get-AiMessageForCommit -Alias aicm

function Get-Instructions{

Check warning

Code scanning / PSScriptAnalyzer

The cmdlet 'Get-Instructions' uses a plural noun. A singular noun should be used instead. Warning

The cmdlet 'Get-Instructions' uses a plural noun. A singular noun should be used instead.
$content = Get-Content -Path $instructionsPath -Raw
return $content
}

Check notice

Code scanning / PSScriptAnalyzer

Line has trailing whitespace Note

Line has trailing whitespace
@rulasg rulasg merged commit 795b99c into main Aug 5, 2025
3 checks passed
@rulasg rulasg deleted the Get-AiMessageForCommit branch August 5, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant