githarbor


Namegitharbor JSON
Version 0.9.0 PyPI version JSON
download
home_pageNone
SummaryUnified client for GitHub, GitLab and BitBucket
upload_time2025-10-06 20:33:36
maintainerNone
docs_urlNone
authorPhilipp Temminghoff
requires_python>=3.12
licenseMIT License Copyright (c) 2024, Philipp Temminghoff Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GitHarbor

[![PyPI License](https://img.shields.io/pypi/l/githarbor.svg)](https://pypi.org/project/githarbor/)
[![Package status](https://img.shields.io/pypi/status/githarbor.svg)](https://pypi.org/project/githarbor/)
[![Monthly downloads](https://img.shields.io/pypi/dm/githarbor.svg)](https://pypi.org/project/githarbor/)
[![Distribution format](https://img.shields.io/pypi/format/githarbor.svg)](https://pypi.org/project/githarbor/)
[![Wheel availability](https://img.shields.io/pypi/wheel/githarbor.svg)](https://pypi.org/project/githarbor/)
[![Python version](https://img.shields.io/pypi/pyversions/githarbor.svg)](https://pypi.org/project/githarbor/)
[![Implementation](https://img.shields.io/pypi/implementation/githarbor.svg)](https://pypi.org/project/githarbor/)
[![Releases](https://img.shields.io/github/downloads/phil65/githarbor/total.svg)](https://github.com/phil65/githarbor/releases)
[![Github Contributors](https://img.shields.io/github/contributors/phil65/githarbor)](https://github.com/phil65/githarbor/graphs/contributors)
[![Github Discussions](https://img.shields.io/github/discussions/phil65/githarbor)](https://github.com/phil65/githarbor/discussions)
[![Github Forks](https://img.shields.io/github/forks/phil65/githarbor)](https://github.com/phil65/githarbor/forks)
[![Github Issues](https://img.shields.io/github/issues/phil65/githarbor)](https://github.com/phil65/githarbor/issues)
[![Github Issues](https://img.shields.io/github/issues-pr/phil65/githarbor)](https://github.com/phil65/githarbor/pulls)
[![Github Watchers](https://img.shields.io/github/watchers/phil65/githarbor)](https://github.com/phil65/githarbor/watchers)
[![Github Stars](https://img.shields.io/github/stars/phil65/githarbor)](https://github.com/phil65/githarbor/stars)
[![Github Repository size](https://img.shields.io/github/repo-size/phil65/githarbor)](https://github.com/phil65/githarbor)
[![Github last commit](https://img.shields.io/github/last-commit/phil65/githarbor)](https://github.com/phil65/githarbor/commits)
[![Github release date](https://img.shields.io/github/release-date/phil65/githarbor)](https://github.com/phil65/githarbor/releases)
[![Github language count](https://img.shields.io/github/languages/count/phil65/githarbor)](https://github.com/phil65/githarbor)
[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/githarbor)](https://github.com/phil65/githarbor)
[![Package status](https://codecov.io/gh/phil65/githarbor/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/githarbor/)
[![PyUp](https://pyup.io/repos/github/phil65/githarbor/shield.svg)](https://pyup.io/repos/github/phil65/githarbor/)

[Read the documentation!](https://phil65.github.io/githarbor/)

# GitHarbor User Guide

GitHarbor is a unified interface for interacting with Git hosting platforms. It provides a consistent API to work with repositories hosted on [GitHub](https://github.com), [GitLab](https://gitlab.com), [Azure DevOps](https://azure.microsoft.com/products/devops), [Gitea](https://gitea.io), [CodeBerg](https://codeberg.org) and [Bitbucket](https://bitbucket.org).

## Getting Started

The main entry point is the `create_repository()` function which accepts a repository URL and platform-specific credentials:

```python
from githarbor import create_repository

# GitHub repository
repo = create_repository("https://github.com/owner/repo", token="github_pat_...")

# GitLab repository
repo = create_repository("https://gitlab.com/owner/repo", token="glpat-...")

# Azure DevOps repository
repo = create_repository(
    "https://dev.azure.com/org/project/_git/repo",
    token="azure_pat"
)
```

> [!TIP]
> Always use personal access tokens (PATs) for authentication. Never hardcode tokens in your source code.

## Working with Repositories

### Basic Repository Information

```python
# Get repository name and default branch
print(repo.name)
print(repo.default_branch)

# Get language statistics
languages = repo.get_languages()
# Returns: {"Python": 10000, "JavaScript": 5000}

# Get recent activity statistics
activity = repo.get_recent_activity(
    days=30,
    include_commits=True,
    include_prs=True,
    include_issues=True
)
```

### Branches and Tags

```python
# List all branches
branches = repo.list_branches()

# Get specific branch
main_branch = repo.get_branch("main")

# List all tags
tags = repo.list_tags()

# Get specific tag
tag = repo.get_tag("v1.0.0")

# Compare branches
diff = repo.compare_branches(
    base="main",
    head="feature",
    include_commits=True,
    include_files=True,
    include_stats=True
)
```

### Commits

```python
# Get specific commit
commit = repo.get_commit("abcd1234")

# List commits with filters
commits = repo.list_commits(
    branch="main",
    since=datetime(2024, 1, 1),
    until=datetime(2024, 2, 1),
    author="username",
    path="src/",
    max_results=100
)

# Search commits
results = repo.search_commits(
    query="fix bug",
    branch="main",
    path="src/",
    max_results=10
)
```

### Issues and Pull Requests

```python
# List open issues
open_issues = repo.list_issues(state="open")

# Get specific issue
issue = repo.get_issue(123)

# List pull requests
prs = repo.list_pull_requests(state="open")  # or "closed" or "all"

# Get specific pull request
pr = repo.get_pull_request(456)
```

### Releases

```python
# Get latest release
latest = repo.get_latest_release(
    include_drafts=False,
    include_prereleases=False
)

# List all releases
releases = repo.list_releases(
    include_drafts=False,
    include_prereleases=True,
    limit=10
)

# Get specific release
release = repo.get_release("v1.0.0")
```

### Repository Content

```python
# Download single file
repo.download(
    path="README.md",
    destination="local/README.md"
)

# Download directory recursively
repo.download(
    path="src/",
    destination="local/src",
    recursive=True
)

# Iterate through files
for file_path in repo.iter_files(
    path="src/",
    ref="main",
    pattern="*.py"
):
    print(file_path)
```

### CI/CD Workflows

```python
# List all workflows
workflows = repo.list_workflows()

# Get specific workflow
workflow = repo.get_workflow("workflow_id")

# Get specific workflow run
run = repo.get_workflow_run("run_id")
```

### Contributors

```python
# Get repository contributors
contributors = repo.get_contributors(
    sort_by="commits",  # or "name" or "date"
    limit=10
)
```

## Error Handling

GitHarbor provides specific exceptions for different error cases:

```python
from githarbor.exceptions import (
    RepositoryNotFoundError,
    ResourceNotFoundError,
    FeatureNotSupportedError
)

try:
    repo = create_repository("https://github.com/nonexistent/repo")
except RepositoryNotFoundError:
    print("Repository does not exist")

try:
    issue = repo.get_issue(999999)
except ResourceNotFoundError:
    print("Issue does not exist")

try:
    repo.some_unsupported_method()
except FeatureNotSupportedError:
    print("This feature is not supported by this repository provider")
```

> [!NOTE]
> Not all features are supported by all platforms. Operations that aren't supported will raise `FeatureNotSupportedError`.

> [!IMPORTANT]
> Be mindful of API rate limits when making many requests. Consider implementing retries and delays in your code.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "githarbor",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": null,
    "author": "Philipp Temminghoff",
    "author_email": "Philipp Temminghoff <philipptemminghoff@googlemail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c5/00/3090ca84f872b1b64394a8cc0f00349611e9a3fea3b2e7a39f7da561a372/githarbor-0.9.0.tar.gz",
    "platform": null,
    "description": "# GitHarbor\n\n[![PyPI License](https://img.shields.io/pypi/l/githarbor.svg)](https://pypi.org/project/githarbor/)\n[![Package status](https://img.shields.io/pypi/status/githarbor.svg)](https://pypi.org/project/githarbor/)\n[![Monthly downloads](https://img.shields.io/pypi/dm/githarbor.svg)](https://pypi.org/project/githarbor/)\n[![Distribution format](https://img.shields.io/pypi/format/githarbor.svg)](https://pypi.org/project/githarbor/)\n[![Wheel availability](https://img.shields.io/pypi/wheel/githarbor.svg)](https://pypi.org/project/githarbor/)\n[![Python version](https://img.shields.io/pypi/pyversions/githarbor.svg)](https://pypi.org/project/githarbor/)\n[![Implementation](https://img.shields.io/pypi/implementation/githarbor.svg)](https://pypi.org/project/githarbor/)\n[![Releases](https://img.shields.io/github/downloads/phil65/githarbor/total.svg)](https://github.com/phil65/githarbor/releases)\n[![Github Contributors](https://img.shields.io/github/contributors/phil65/githarbor)](https://github.com/phil65/githarbor/graphs/contributors)\n[![Github Discussions](https://img.shields.io/github/discussions/phil65/githarbor)](https://github.com/phil65/githarbor/discussions)\n[![Github Forks](https://img.shields.io/github/forks/phil65/githarbor)](https://github.com/phil65/githarbor/forks)\n[![Github Issues](https://img.shields.io/github/issues/phil65/githarbor)](https://github.com/phil65/githarbor/issues)\n[![Github Issues](https://img.shields.io/github/issues-pr/phil65/githarbor)](https://github.com/phil65/githarbor/pulls)\n[![Github Watchers](https://img.shields.io/github/watchers/phil65/githarbor)](https://github.com/phil65/githarbor/watchers)\n[![Github Stars](https://img.shields.io/github/stars/phil65/githarbor)](https://github.com/phil65/githarbor/stars)\n[![Github Repository size](https://img.shields.io/github/repo-size/phil65/githarbor)](https://github.com/phil65/githarbor)\n[![Github last commit](https://img.shields.io/github/last-commit/phil65/githarbor)](https://github.com/phil65/githarbor/commits)\n[![Github release date](https://img.shields.io/github/release-date/phil65/githarbor)](https://github.com/phil65/githarbor/releases)\n[![Github language count](https://img.shields.io/github/languages/count/phil65/githarbor)](https://github.com/phil65/githarbor)\n[![Github commits this month](https://img.shields.io/github/commit-activity/m/phil65/githarbor)](https://github.com/phil65/githarbor)\n[![Package status](https://codecov.io/gh/phil65/githarbor/branch/main/graph/badge.svg)](https://codecov.io/gh/phil65/githarbor/)\n[![PyUp](https://pyup.io/repos/github/phil65/githarbor/shield.svg)](https://pyup.io/repos/github/phil65/githarbor/)\n\n[Read the documentation!](https://phil65.github.io/githarbor/)\n\n# GitHarbor User Guide\n\nGitHarbor is a unified interface for interacting with Git hosting platforms. It provides a consistent API to work with repositories hosted on [GitHub](https://github.com), [GitLab](https://gitlab.com), [Azure DevOps](https://azure.microsoft.com/products/devops), [Gitea](https://gitea.io), [CodeBerg](https://codeberg.org) and [Bitbucket](https://bitbucket.org).\n\n## Getting Started\n\nThe main entry point is the `create_repository()` function which accepts a repository URL and platform-specific credentials:\n\n```python\nfrom githarbor import create_repository\n\n# GitHub repository\nrepo = create_repository(\"https://github.com/owner/repo\", token=\"github_pat_...\")\n\n# GitLab repository\nrepo = create_repository(\"https://gitlab.com/owner/repo\", token=\"glpat-...\")\n\n# Azure DevOps repository\nrepo = create_repository(\n    \"https://dev.azure.com/org/project/_git/repo\",\n    token=\"azure_pat\"\n)\n```\n\n> [!TIP]\n> Always use personal access tokens (PATs) for authentication. Never hardcode tokens in your source code.\n\n## Working with Repositories\n\n### Basic Repository Information\n\n```python\n# Get repository name and default branch\nprint(repo.name)\nprint(repo.default_branch)\n\n# Get language statistics\nlanguages = repo.get_languages()\n# Returns: {\"Python\": 10000, \"JavaScript\": 5000}\n\n# Get recent activity statistics\nactivity = repo.get_recent_activity(\n    days=30,\n    include_commits=True,\n    include_prs=True,\n    include_issues=True\n)\n```\n\n### Branches and Tags\n\n```python\n# List all branches\nbranches = repo.list_branches()\n\n# Get specific branch\nmain_branch = repo.get_branch(\"main\")\n\n# List all tags\ntags = repo.list_tags()\n\n# Get specific tag\ntag = repo.get_tag(\"v1.0.0\")\n\n# Compare branches\ndiff = repo.compare_branches(\n    base=\"main\",\n    head=\"feature\",\n    include_commits=True,\n    include_files=True,\n    include_stats=True\n)\n```\n\n### Commits\n\n```python\n# Get specific commit\ncommit = repo.get_commit(\"abcd1234\")\n\n# List commits with filters\ncommits = repo.list_commits(\n    branch=\"main\",\n    since=datetime(2024, 1, 1),\n    until=datetime(2024, 2, 1),\n    author=\"username\",\n    path=\"src/\",\n    max_results=100\n)\n\n# Search commits\nresults = repo.search_commits(\n    query=\"fix bug\",\n    branch=\"main\",\n    path=\"src/\",\n    max_results=10\n)\n```\n\n### Issues and Pull Requests\n\n```python\n# List open issues\nopen_issues = repo.list_issues(state=\"open\")\n\n# Get specific issue\nissue = repo.get_issue(123)\n\n# List pull requests\nprs = repo.list_pull_requests(state=\"open\")  # or \"closed\" or \"all\"\n\n# Get specific pull request\npr = repo.get_pull_request(456)\n```\n\n### Releases\n\n```python\n# Get latest release\nlatest = repo.get_latest_release(\n    include_drafts=False,\n    include_prereleases=False\n)\n\n# List all releases\nreleases = repo.list_releases(\n    include_drafts=False,\n    include_prereleases=True,\n    limit=10\n)\n\n# Get specific release\nrelease = repo.get_release(\"v1.0.0\")\n```\n\n### Repository Content\n\n```python\n# Download single file\nrepo.download(\n    path=\"README.md\",\n    destination=\"local/README.md\"\n)\n\n# Download directory recursively\nrepo.download(\n    path=\"src/\",\n    destination=\"local/src\",\n    recursive=True\n)\n\n# Iterate through files\nfor file_path in repo.iter_files(\n    path=\"src/\",\n    ref=\"main\",\n    pattern=\"*.py\"\n):\n    print(file_path)\n```\n\n### CI/CD Workflows\n\n```python\n# List all workflows\nworkflows = repo.list_workflows()\n\n# Get specific workflow\nworkflow = repo.get_workflow(\"workflow_id\")\n\n# Get specific workflow run\nrun = repo.get_workflow_run(\"run_id\")\n```\n\n### Contributors\n\n```python\n# Get repository contributors\ncontributors = repo.get_contributors(\n    sort_by=\"commits\",  # or \"name\" or \"date\"\n    limit=10\n)\n```\n\n## Error Handling\n\nGitHarbor provides specific exceptions for different error cases:\n\n```python\nfrom githarbor.exceptions import (\n    RepositoryNotFoundError,\n    ResourceNotFoundError,\n    FeatureNotSupportedError\n)\n\ntry:\n    repo = create_repository(\"https://github.com/nonexistent/repo\")\nexcept RepositoryNotFoundError:\n    print(\"Repository does not exist\")\n\ntry:\n    issue = repo.get_issue(999999)\nexcept ResourceNotFoundError:\n    print(\"Issue does not exist\")\n\ntry:\n    repo.some_unsupported_method()\nexcept FeatureNotSupportedError:\n    print(\"This feature is not supported by this repository provider\")\n```\n\n> [!NOTE]\n> Not all features are supported by all platforms. Operations that aren't supported will raise `FeatureNotSupportedError`.\n\n> [!IMPORTANT]\n> Be mindful of API rate limits when making many requests. Consider implementing retries and delays in your code.\n",
    "bugtrack_url": null,
    "license": "MIT License\n         \n         Copyright (c) 2024, Philipp Temminghoff\n         \n         Permission is hereby granted, free of charge, to any person obtaining a copy\n         of this software and associated documentation files (the \"Software\"), to deal\n         in the Software without restriction, including without limitation the rights\n         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n         copies of the Software, and to permit persons to whom the Software is\n         furnished to do so, subject to the following conditions:\n         \n         The above copyright notice and this permission notice shall be included in all\n         copies or substantial portions of the Software.\n         \n         THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n         SOFTWARE.\n         ",
    "summary": "Unified client for GitHub, GitLab and BitBucket",
    "version": "0.9.0",
    "project_urls": {
        "Code coverage": "https://app.codecov.io/gh/phil65/githarbor",
        "Discussions": "https://github.com/phil65/githarbor/discussions",
        "Documentation": "https://phil65.github.io/githarbor/",
        "Issues": "https://github.com/phil65/githarbor/issues",
        "Source": "https://github.com/phil65/githarbor"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "15af56590e5adf53d46461a68f029c5aa1cc15f4f602f797e126a0ac13bc3cfa",
                "md5": "f65cd6e197e334b393eecdf49eec0dcd",
                "sha256": "0b7c1351599b2dd3cb63f1d6c7a19381259798d79efef1712f7a627e9b3c93cf"
            },
            "downloads": -1,
            "filename": "githarbor-0.9.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f65cd6e197e334b393eecdf49eec0dcd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 83135,
            "upload_time": "2025-10-06T20:33:35",
            "upload_time_iso_8601": "2025-10-06T20:33:35.204583Z",
            "url": "https://files.pythonhosted.org/packages/15/af/56590e5adf53d46461a68f029c5aa1cc15f4f602f797e126a0ac13bc3cfa/githarbor-0.9.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c5003090ca84f872b1b64394a8cc0f00349611e9a3fea3b2e7a39f7da561a372",
                "md5": "a601ddb30068fe0453356deac729b2a4",
                "sha256": "dd618bb18307c2fb8a5295b95bd1fcc412d14327735c7c7353107ee752b76829"
            },
            "downloads": -1,
            "filename": "githarbor-0.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a601ddb30068fe0453356deac729b2a4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 60208,
            "upload_time": "2025-10-06T20:33:36",
            "upload_time_iso_8601": "2025-10-06T20:33:36.331924Z",
            "url": "https://files.pythonhosted.org/packages/c5/00/3090ca84f872b1b64394a8cc0f00349611e9a3fea3b2e7a39f7da561a372/githarbor-0.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-06 20:33:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "phil65",
    "github_project": "githarbor",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "githarbor"
}
        
Elapsed time: 6.82550s