Skip to content

sitedog-io/stack-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SiteDog Detection Go

A Go-based detection system for analyzing project dependencies and vulnerabilities.

Features

  • Dependency Analysis: Scans and analyzes project dependencies across multiple languages and package managers
  • AI-Powered Git Commit Messages: Automatically generates meaningful commit messages using OpenAI
  • Multi-language Support: Handles Go, Ruby, Node.js, Python, and other ecosystems
  • Fast Detection: Efficient scanning with minimal overhead

AI Commit Message Hook

This project includes an intelligent git hook that automatically generates commit messages using OpenAI's GPT models.

Setup

  1. Set your OpenAI API key:

    export OPENAI_API_KEY="your-api-key-here"
  2. The hook is already installed in .git/hooks/commit-msg (Go binary)

Usage

The hook supports two modes:

Quick Mode (..)

For fast commit message generation based on file list only:

git commit -m ".."
  • ✅ Fast and cost-effective
  • ✅ Good for simple changes
  • ✅ Lists modified files without showing content

Detailed Mode (...)

For detailed commit message generation based on actual code changes:

git commit -m "..."
  • ✅ Analyzes actual code differences
  • ✅ More accurate commit messages
  • ✅ Better for complex changes

Examples

# Quick mode - generates message from file list
git add . && git commit -m ".."
# → "Update Go modules and add new test files"

# Detailed mode - analyzes actual changes
git add . && git commit -m "..."
# → "Add error handling and fix nil pointer dereference"

Hook Features

  • Static File Detection: Automatically identifies CSS, HTML, images, etc.
  • Smart Diff Analysis: Excludes binary files and focuses on code changes
  • Error Handling: Graceful fallback if API is unavailable
  • Debug Logging: Detailed logs in .git/commit-msg-debug.log
  • No Dependencies: Single Go binary, no Ruby gems required

Customization

You can modify the hook behavior by editing commit-msg.go and recompiling:

go build -o .git/hooks/commit-msg commit-msg.go
chmod +x .git/hooks/commit-msg

Development

Requirements

  • Go 1.19+
  • OpenAI API key for commit message generation

Build

go build -o sitedog-detection main.go

Test

go test ./...

Dependencies

  • github.com/sashabaranov/go-openai - OpenAI API client

Project Structure

├── main.go                 # Main detection logic
├── commit-msg.go          # AI commit message generator
├── integration_test.go    # Integration tests
├── main_test.go          # Unit tests
├── data/                 # Detection data and patterns
├── testdata/            # Test fixtures
└── .git/hooks/          # Git hooks (includes compiled commit-msg)

Makefile Commands

make uncommit    # Soft reset last commit (useful for re-generating messages)
make push        # Push to origin
make pull        # Pull from origin
make trunk       # Switch to main/master branch

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published