Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/betarixm/repoql
A Python library designed for querying git repositories
https://github.com/betarixm/repoql
git
Last synced: about 15 hours ago
JSON representation
A Python library designed for querying git repositories
- Host: GitHub
- URL: https://github.com/betarixm/repoql
- Owner: betarixm
- Created: 2024-03-06T15:14:34.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-03-13T10:26:18.000Z (8 months ago)
- Last Synced: 2024-03-13T11:39:28.070Z (8 months ago)
- Topics: git
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RepoQL
> A Python library designed for querying git repositories
RepoQL is a Python library designed for querying git repositories. It provides a minimalistic interface wrapping around [`pygit2`](https://www.pygit2.org/), allowing you to perform various queries on git repositories.
## Features
- Provides functional programming style for querying git repositories.
- Fully type hinted for improved code readability and maintainability.
- Minimalistic design focused on simplicity and ease of use.## Usage
```py
from pathlib import Path
from typing import Any, Callable, Iteratorfrom pygit2 import Repository
from repoql import BlobRelation
from repoql import Query as Q
from repoql import Queryable, blob_relation, composeblobs_by_relative_path: Callable[
[Path], Callable[[Queryable[BlobRelation, Any]], Iterator[BlobRelation]]
] = lambda path: compose(
Q.select(
where=lambda blob: str(blob.path) == str(path),
limit=None,
),
Q.group_by(
key=lambda blob: blob.id,
),
Q.sorted(key=lambda blob: blob.commit.commit_time),
Q.select(limit=1),
Q.ungroup,
)repo = Repository("[path to your git repository]")
result = blobs_by_relative_path(Path(".gitignore"))(blob_relation.from_repository(repo))
```Check out `repoql/recipes.py` for more examples.
## Disclaimer
RepoQL is provided as-is and without warranty. Please note that RepoQL is not intended for production use as it is not battle-tested. It's best suited for experimental or educational purposes. Use it at your own risk.