A Rust workspace for querying Git repositories using Trustfall's GraphQL-like syntax.
This workspace contains two crates:
git-seek(cli/) - Command-line interface for querying Git repositoriestrustfall_git_adapter(trustfall_git_adapter/) - Trustfall adapter library for Git repositories
cargo install git-seekgit clone git@github.com:starfy84/git-seek.git
cd git-seek
cargo build --release# Query repository name
git-seek --query '{repository {name @output}}'
# Query branches with JSON output
git-seek --query '{repository {branches {name @output}}}' --format json
# Load query from file
git-seek --file query.graphql --format table
# Use variables in queries
git-seek --query '{repository {name @output}}' --var repo_name=my-repotable- Human-readable table (great for terminal use)json- JSON format (perfect for scripting)raw- Raw debug output
Repository information:
{
repository {
name @output
}
}
Branch listing:
{
repository {
branches {
name @output
}
}
}
Commit history:
{
repository {
commits {
hash @output
message @output
}
}
}
Recent commits (limited):
{
repository {
commits(limit: 10) {
hash @output
message @output
author @output
date @output
}
}
}
Commit author and committer details:
{
repository {
commits(limit: 5) {
hash @output
author @output
author_email @output
committer @output
committer_email @output
}
}
}
Branch with latest commit:
{
repository {
branches {
name @output
commit {
hash @output
message @output
}
}
}
}
Tag listing:
{
repository {
tags {
name @output
message @output
tagger_name @output
}
}
}
Tags with their commits:
{
repository {
tags {
name @output
commit {
hash @output
message @output
}
}
}
}
The Trustfall schema defines the structure for querying Git repositories:
type Repository {
name: String!
commits(limit: Int): [Commit!]!
branches: [Branch!]!
tags: [Tag!]!
}
type Commit {
hash: String!
message: String
author: String
author_email: String
committer: String
committer_email: String
date: String
}
type Branch {
name: String!
commit: Commit!
}
type Tag {
name: String!
message: String
tagger_name: String
tagger_email: String
commit: Commit!
}The trustfall_git_adapter crate can be used as a library in your own Rust projects:
use git2::Repository;
use trustfall_git_adapter::GitAdapter;
use std::sync::Arc;
let repo = Repository::open(".")?;
let adapter = GitAdapter::new(&repo);
let query = r#"{
repository {
name @output
}
}"#;
let results = trustfall::execute_query(
adapter.schema(),
Arc::new(&adapter),
query,
std::collections::BTreeMap::new()
)?;# Build the entire workspace
cargo build
# Run all tests
cargo test
# Build individual crates
cargo build -p git-seek
cargo build -p trustfall_git_adapter
# Run CLI tests
cargo test -p git-seek
# Run adapter tests
cargo test -p trustfall_git_adapterContributions are welcome! Please feel free to submit a Pull Request.
BSD-3-Clause