Git repository plugin for Daimyo - provides Git context for templates
Project description
bugyo-git
Git repository plugin for Daimyo - provides Git context, filters, and tests for Jinja2 templates.
Installation
pip install bugyo-git
Requirements
- Python >= 3.11
- daimyo >= 1.4.0
- GitPython ~= 3.1
Note: This plugin requires GitPython and only works inside Git repositories.
Features
Context Variables
The git.context plugin provides:
| Variable | Type | Description |
|---|---|---|
git_branch |
str | Current branch name |
git_commit |
str | Current commit SHA (short, 7 chars) |
git_commit_full |
str | Full commit SHA (40 chars) |
git_author |
str | Commit author name |
git_author_email |
str | Commit author email |
git_remote |
str|None | Remote URL (if configured) |
git_remote_name |
str|None | Remote name (e.g., "origin") |
git_remote_domain |
str|None | Remote URL domain with port (if any) |
git_remote_domain_no_port |
str|None | Remote URL domain without port |
git_push_url |
str|None | Push URL (if configured, may differ from remote URL) |
git_push_domain |
str|None | Push URL domain with port (if any) |
git_push_domain_no_port |
str|None | Push URL domain without port |
git_is_clean |
bool | True if no uncommitted changes |
git_tag |
str|None | Tag name if current commit is tagged |
git_root |
str | Git repository root path |
Filters
The git.filters plugin provides:
| Filter | Description | Example |
|---|---|---|
git_short_sha |
Shorten SHA to N chars | commit | git_short_sha(10) |
git_branch_name |
Extract branch from ref | "refs/heads/main" | git_branch_name |
Tests
The git.filters plugin provides:
| Test | Description | Example |
|---|---|---|
is_git_repo |
Check if path is git repo | "." is is_git_repo |
is_clean |
Check if working dir is clean | git_is_clean is is_clean |
has_uncommitted |
Check for uncommitted changes | true is has_uncommitted |
on_branch |
Check if on specific branch | "main" is on_branch("main") |
has_remote |
Check if remote exists | "origin" is has_remote("origin") |
Configuration
Enable in .daimyo/config/settings.toml:
# Enable all Git plugins
enabled_plugins = ["git.*"]
# Or enable specific plugins
enabled_plugins = ["git.context", "git.filters"]
Usage Examples
Branch-Specific Rules
In your YAML rule files:
code.review:
when: Code review guidelines
ruleset:
- "{% if git_branch is on_branch('main') %}Code must pass all CI checks before merging{% endif %}"
- "{% if git_branch is on_branch('main') %}Require code review from at least 2 reviewers{% endif %}"
- "{% if git_branch is on_branch('develop') %}Code must pass unit tests{% endif %}"
- "{% if git_branch is on_branch('develop') %}Require code review from at least 1 reviewer{% endif %}"
Commit Information
git.info:
when: Git commit information
ruleset:
- "Current commit: {{ git_commit }}"
- "Author: {{ git_author }} <{{ git_author_email }}>"
- "{% if git_tag %}This is a tagged release: {{ git_tag }}{% endif %}"
Clean Repository Checks
git.status:
when: Repository status checks
ruleset:
- "{% if not (git_is_clean is is_clean) %}Warning: You have uncommitted changes{% endif %}"
- "{% if not (git_is_clean is is_clean) %}Please commit or stash your changes before proceeding{% endif %}"
Remote Configuration
git.remote:
when: Remote repository configuration
ruleset:
- "{% if git_remote %}Remote: {{ git_remote_name }} ({{ git_remote }}){% endif %}"
- "{% if not git_remote %}No remote configured - remember to push your changes{% endif %}"
CI Pipeline Rules Based on Repository Domain
ci.pipeline:
when: CI pipeline configuration
ruleset:
- "{% if git_push_domain_no_port == 'github.com' %}Use GitHub Actions workflow{% endif %}"
- "{% if git_push_domain_no_port == 'gitlab.com' %}Use GitLab CI/CD pipeline{% endif %}"
- "{% if git_remote_domain_no_port == 'gitlab.example.com' %}Use custom GitLab instance CI/CD{% endif %}"
- "{% if git_push_domain == 'gitlab.example.com:8443' %}Configure custom SSL port for CI{% endif %}"
Availability
This plugin is only available when:
- GitPython is installed
- Running inside a Git repository
If GitPython is not installed or not in a Git repository, the plugin will gracefully disable itself.
License
MIT License - see LICENSE file for details.
Support
For issues and questions, visit the Daimyo issue tracker.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bugyo_git-1.1.0.tar.gz.
File metadata
- Download URL: bugyo_git-1.1.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Rocky Linux","version":"9.6","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60de11e444754ff5e5eb8fc7f04d3639ea2028489a966d7dc839707efdb5df91
|
|
| MD5 |
7c6551d7de1a54c378c3b8ffa352aa84
|
|
| BLAKE2b-256 |
f8904d0dc02558c974a05906f7bbb75842eebe6329a55241f0436c4750ca279a
|
File details
Details for the file bugyo_git-1.1.0-py3-none-any.whl.
File metadata
- Download URL: bugyo_git-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Rocky Linux","version":"9.6","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c896ea59f52b5cbb29fcbbd25150cd892131a39115d4f82e3d882c80d9a411d3
|
|
| MD5 |
ecf9f798c374e1f585cbd4dd7db0cab4
|
|
| BLAKE2b-256 |
e80fc79f89f87eca9ddbb1b794785f492131517b205e1854920c7af8f25d05b3
|