{"id":37080449,"url":"https://github.com/thearjun/git-commits","last_synced_at":"2026-01-14T09:46:00.105Z","repository":{"id":295644252,"uuid":"990658206","full_name":"theArjun/git-commits","owner":"theArjun","description":"A Python library for listing Git commits from local repositories with advanced filtering options.","archived":false,"fork":false,"pushed_at":"2025-05-26T16:20:29.000Z","size":67,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-25T07:47:39.130Z","etag":null,"topics":["commits","git","github","list"],"latest_commit_sha":null,"homepage":"http://adhikariarjun.com.np/git-commits/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theArjun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-26T12:45:02.000Z","updated_at":"2025-05-26T16:20:32.000Z","dependencies_parsed_at":"2025-05-26T17:01:13.606Z","dependency_job_id":"77f9a061-0498-4b9d-8ea3-fe855c9c2837","html_url":"https://github.com/theArjun/git-commits","commit_stats":null,"previous_names":["thearjun/git-commits"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/theArjun/git-commits","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theArjun%2Fgit-commits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theArjun%2Fgit-commits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theArjun%2Fgit-commits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theArjun%2Fgit-commits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theArjun","download_url":"https://codeload.github.com/theArjun/git-commits/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theArjun%2Fgit-commits/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28416120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commits","git","github","list"],"created_at":"2026-01-14T09:45:59.363Z","updated_at":"2026-01-14T09:46:00.100Z","avatar_url":"https://github.com/theArjun.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git Commits\n\nA Python library for listing Git commits from local repositories with advanced filtering options.\n\n## Features\n\n- 📝 List commits from any local Git repository\n- 👤 Filter commits by author (name or email, case-insensitive)\n- 📅 Filter commits by date range with flexible date parsing\n- 🌍 Timezone support for date filtering\n- 🌿 Support for searching across all branches\n- 🛡️ Robust error handling\n- 📦 Clean dataclass-based return objects\n- 👥 List unique authors in a repository\n\n## Installation\n\nInstall from PyPI:\n\n```bash\npip install git-commits\n```\n\nOr using uv:\n\n```bash\nuv add git-commits\n```\n\nFor development installation:\n\n```bash\ngit clone https://github.com/theArjun/git-commits.git\ncd git-commits\nuv install -e .\n```\n\n## Quick Start\n\n```python\nfrom git_commits import list_git_commits, get_repo_authors\n\n# List all commits from current repository\ncommits = list_git_commits(\".\")\n\n# Print first few commits\nfor commit in commits[:3]:\n    print(f\"{commit.short_sha} - {commit.author_name}: {commit.message}\")\n\n# List all unique authors in the repository\nauthors = get_repo_authors(\".\")\nfor author in authors:\n    print(f\"{author.name} \u003c{author.email}\u003e\")\n```\n\n## API Reference\n\n### `list_git_commits(repo_path, **kwargs)`\n\nList Git commits from a specified local repository with filtering options.\n\n#### Parameters\n\n- **`repo_path`** (str): The absolute or relative path to the local Git repository\n- **`author`** (str, optional): Filter commits by author's name or email (case-insensitive partial matching)\n- **`since`** (Union[str, datetime], optional): Filter commits authored after this date\n- **`until`** (Union[str, datetime], optional): Filter commits authored before this date  \n- **`timezone`** (str, optional): Timezone string for interpreting string dates (defaults to \"UTC\")\n- **`all_branches`** (bool, optional): If True, search across all branches (defaults to False)\n\n#### Returns\n\nList of `GitCommit` objects with the following attributes:\n\n- **`sha`** (str): Full SHA-1 hash of the commit\n- **`short_sha`** (str): First 7 characters of the SHA-1 hash\n- **`author_name`** (str): Name of the commit author\n- **`author_email`** (str): Email of the commit author\n- **`authored_datetime`** (datetime): Timezone-aware datetime when the commit was authored\n- **`message`** (str): Full commit message\n\n### `get_repo_authors(repo_path)`\n\nGet a list of unique authors from a Git repository.\n\n#### Parameters\n\n- **`repo_path`** (str): The absolute or relative path to the local Git repository\n\n#### Returns\n\nList of `RepoAuthor` objects with the following attributes:\n\n- **`name`** (str): Name of the author\n- **`email`** (str): Email of the author\n\n#### Example\n\n```python\nfrom git_commits import get_repo_authors\n\nauthors = get_repo_authors(\"/path/to/repo\")\nfor author in authors:\n    print(f\"{author.name} \u003c{author.email}\u003e\")\n```\n\n## Usage Examples\n\n### Basic Usage\n\n```python\nfrom git_commits import list_git_commits\n\n# List all commits\ncommits = list_git_commits(\"/path/to/repo\")\n\n# List commits from current directory\ncommits = list_git_commits(\".\")\n```\n\n### Filter by Author\n\n```python\n# Filter by author name (case-insensitive)\ncommits = list_git_commits(\".\", author=\"john\")\n\n# Filter by email\ncommits = list_git_commits(\".\", author=\"john@example.com\")\n```\n\n### Date Filtering\n\n#### Using String Dates\n\n```python\n# Commits since a specific date\ncommits = list_git_commits(\".\", since=\"2024-01-01\")\n\n# Commits in the last week\ncommits = list_git_commits(\".\", since=\"1 week ago\")\n\n# Commits between dates\ncommits = list_git_commits(\n    \".\", \n    since=\"2024-01-01\", \n    until=\"2024-12-31\"\n)\n\n# Relative dates\ncommits = list_git_commits(\".\", since=\"yesterday\")\ncommits = list_git_commits(\".\", since=\"2 months ago\")\n```\n\n#### Using Datetime Objects\n\n```python\nfrom datetime import datetime\nimport pytz\n\n# Using timezone-aware datetime objects\neastern = pytz.timezone('America/New_York')\nsince_dt = eastern.localize(datetime(2024, 1, 1))\nuntil_dt = datetime.now(eastern)\n\ncommits = list_git_commits(\n    \".\", \n    since=since_dt, \n    until=until_dt\n)\n```\n\n### Timezone Support\n\n```python\n# Interpret string dates in a specific timezone\ncommits = list_git_commits(\n    \".\",\n    since=\"2024-01-01 09:00:00\",\n    timezone=\"America/New_York\"\n)\n```\n\n### Search Across All Branches\n\n```python\n# Include commits from all branches (including remote-tracking)\ncommits = list_git_commits(\".\", all_branches=True)\n```\n\n### Combined Filters\n\n```python\n# Combine multiple filters\ncommits = list_git_commits(\n    \".\",\n    author=\"john\",\n    since=\"1 month ago\",\n    until=\"now\",\n    timezone=\"UTC\",\n    all_branches=True\n)\n```\n\n### Working with Results\n\n```python\ncommits = list_git_commits(\".\")\n\nfor commit in commits:\n    print(f\"SHA: {commit.sha}\")\n    print(f\"Short SHA: {commit.short_sha}\")\n    print(f\"Author: {commit.author_name} \u003c{commit.author_email}\u003e\")\n    print(f\"Date: {commit.authored_datetime}\")\n    print(f\"Message: {commit.message}\")\n    print(\"-\" * 50)\n```\n\n## Supported Date Formats\n\nThe library supports various date string formats:\n\n- **ISO dates**: `\"2024-01-01\"`, `\"2024-01-01 15:30:00\"`\n- **Relative dates**: `\"yesterday\"`, `\"today\"`, `\"now\"`\n- **Relative periods**: `\"1 week ago\"`, `\"2 months ago\"`, `\"3 days ago\"`\n- **Natural language**: Most date strings parseable by [`dateparser`](https://dateparser.readthedocs.io/en/latest/)\n\n## Error Handling\n\nThe library gracefully handles various error conditions:\n\n- Invalid repository paths\n- Non-Git repositories\n- Invalid date strings\n- Permission errors\n\nIn case of errors, an informative message is printed and an empty list is returned.\n\n```python\n# This will print an error message and return []\ncommits = list_git_commits(\"/invalid/path\")\n```\n\n## Requirements\n\n- Python 3.9+\n- GitPython \u003e= 3.1.40\n- dateparser \u003e= 1.2.1\n- pytz \u003e= 2024.1\n\n## Development\n\n### Setting up for Development\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/theArjun/git-commits.git\ncd git-commits\n```\n\n2. Install with development dependencies using uv:\n```bash\nuv install -e \".[dev]\"\n```\n\n3. Run the examples:\n```bash\npython main.py\n```\n\n4. Run tests (when available):\n```bash\npytest\n```\n\n5. Format code:\n```bash\nblack src/ tests/\nisort src/ tests/\n```\n\n6. Type checking:\n```bash\nmypy src/\n```\n\n### Publishing to PyPI\n\nThis project is configured to be published using `uv`. Here's how to publish:\n\n1. **Ensure you have the latest version of uv:**\n```bash\nuv --version  # Should be 1.0.1+\n```\n\n2. **Update the version in `pyproject.toml`:**\n```toml\n[project]\nversion = \"1.0.1\"  # Increment as needed\n```\n\n3. **Build the package:**\n```bash\nuv build\n```\n\n4. **Publish to PyPI:**\n```bash\nuv publish\n```\nMore on publishing can be found [here](https://docs.astral.sh/uv/guides/package/)\n\n5. **Test the installation:**\n```bash\nuv run --with git-commits --no-project -- python -c \"import git_commits\"\n```\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthearjun%2Fgit-commits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthearjun%2Fgit-commits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthearjun%2Fgit-commits/lists"}