Create your own plugins to add framework support or custom functionality to RedGit.
Place custom plugins in .redgit/plugins/:
.redgit/plugins/my-plugin/
├── __init__.py # Plugin class (required)
├── prompt.md # Custom prompt (optional)
└── commands.py # CLI commands (optional)
Framework plugins provide auto-detection and custom prompts for rg propose.
# .redgit/plugins/django/__init__.py
from pathlib import Path
class DjangoPlugin:
name = "django"
def match(self) -> bool:
"""Auto-detect Django project"""
return (
Path("manage.py").exists() and
Path("settings.py").exists()
)
def get_prompt(self) -> str:
"""Return Django-specific grouping prompt"""
return """
Group files by Django app and functionality:
- Models with their migrations
- Views with their templates and URLs
- Admin configurations
- Management commands
- Tests with their fixtures
"""# .redgit/plugins/django/__init__.py
from pathlib import Path
class DjangoPlugin:
name = "django"
prompt_file = "prompt.md" # Load from .redgit/plugins/django/prompt.md
def match(self) -> bool:
return Path("manage.py").exists()<!-- .redgit/plugins/django/prompt.md -->
# Django Project Commit Grouping
Group changes by Django application structure:
## Grouping Rules
1. Models + migrations = single commit
2. Views + templates + URLs = single commit
3. Admin configurations separately
4. Tests with related code changesAdd custom CLI commands to RedGit.
# .redgit/plugins/deploy/__init__.py
import typer
class DeployPlugin:
name = "deploy"
def get_commands(self):
"""Return typer app with commands"""
app = typer.Typer()
@app.command()
def staging():
"""Deploy to staging"""
typer.echo("Deploying to staging...")
# Your deployment logic
@app.command()
def production():
"""Deploy to production"""
typer.echo("Deploying to production...")
return appUsage:
rg deploy staging
rg deploy productionAccess plugin configuration from .redgit/config.yaml:
# .redgit/plugins/myframework/__init__.py
class MyFrameworkPlugin:
name = "myframework"
def setup(self, config: dict):
"""Called with plugin config from config.yaml"""
self.env = config.get("environment", "development")
self.debug = config.get("debug", False)
def match(self) -> bool:
return Path("myframework.config").exists()# .redgit/config.yaml
plugins:
enabled:
- myframework
myframework:
environment: production
debug: falsePlugins can hook into RedGit events:
class MyPlugin:
name = "myplugin"
def on_propose_start(self, files: list):
"""Called before propose analysis"""
pass
def on_propose_end(self, groups: list):
"""Called after grouping, before commits"""
pass
def on_commit(self, branch: str, message: str, files: list):
"""Called after each commit"""
pass
def on_push(self, branch: str, remote: str):
"""Called after push"""
passShare your plugin with the community:
- Create a repository with your plugin
- Add to RedGit Tap index.json:
{
"plugins": {
"django": {
"name": "Django",
"description": "Django framework support",
"version": "1.0.0",
"type": "framework",
"author": "your-name",
"repository": "https://github.com/you/redgit-plugin-django"
}
}
}- Submit a pull request
- Plugins Overview
- RedGit Tap - Browse available plugins
- Configuration