| Crates.io | trustfall_git_adapter |
| lib.rs | trustfall_git_adapter |
| version | 1.3.0 |
| created_at | 2025-12-26 11:09:47.018485+00 |
| updated_at | 2025-12-30 06:25:22.008931+00 |
| description | Trustfall adapter for querying Git repositories |
| homepage | https://github.com/starfy84/git-seek |
| repository | https://github.com/starfy84/git-seek |
| max_upload_size | |
| id | 2005586 |
| size | 51,453 |
A Trustfall adapter for querying Git repositories using GraphQL-like syntax.
This crate provides a Trustfall adapter that allows you to query Git repositories using Trustfall's GraphQL-like query language. It acts as a bridge between Trustfall queries and Git repository data via the git2 crate.
Add this to your Cargo.toml:
[dependencies]
trustfall_git_adapter = "0.1.0"
git2 = "0.20"
trustfall = "0.8"
use git2::Repository;
use trustfall_git_adapter::GitAdapter;
use std::sync::Arc;
use std::collections::BTreeMap;
// Open a Git repository
let repo = Repository::open(".")?;
// Create the adapter
let adapter = GitAdapter::new(&repo);
// Execute a query
let query = r#"{
repository {
name @output
branches {
name @output
}
}
}"#;
let variables = BTreeMap::new();
let results = trustfall::execute_query(
adapter.schema(),
Arc::new(&adapter),
query,
variables
)?;
// Process results
for result in results {
println!("{:?}", result);
}
Repository name:
let query = r#"{
repository {
name @output
}
}"#;
All branches:
let query = r#"{
repository {
branches {
name @output
}
}
}"#;
Commits with messages:
let query = r#"{
repository {
commits {
hash @output
message @output
}
}
}"#;
Limited commits (e.g., last 10):
let query = r#"{
repository {
commits(limit: 10) {
hash @output
message @output
author @output
}
}
}"#;
Branches with their latest commits:
let query = r#"{
repository {
branches {
name @output
commit {
hash @output
message @output
}
}
}
}"#;
The adapter implements the following GraphQL schema:
schema {
query: RootSchemaQuery
}
type RootSchemaQuery {
repository: Repository
}
type Repository {
name: String!
commits(limit: Int): [Commit!]!
branches: [Branch!]!
}
type Commit {
hash: String!
message: String
author: String
}
type Branch {
name: String!
commit: Commit!
}
The adapter is built using Trustfall's derive macros and implements:
Repository, Commit, BranchGitAdapter - Main adapter struct implementing the Trustfall adapter traitVertex - Enum representing different Git objects (Repository, Commit, Branch)The adapter handles common Git errors:
Errors are propagated through Trustfall's error handling mechanism.
cargo test -p trustfall_git_adapter
# Test in a specific repository
cd /path/to/your/git/repo
cargo test -p trustfall_git_adapter
To extend the schema:
schema.graphqlvertex.rsedges.rsproperties.rstests/git2 - Git repository accesstrustfall - Query execution enginetrustfall_core - Core Trustfall functionalitytrustfall_derive - Derive macros for adapter implementationSee the git-seek CLI tool for a complete example of how to use this adapter in a real application.
BSD-3-Clause