Skip to main content

Universal Git webhook data parser supporting GitHub, GitLab, and other SCM platforms

Project description

Universal Git Data Parser

Universal Git webhook data parser supporting GitHub, GitLab, and other SCM platforms.

Features

  • Multi-Platform Support: GitHub, GitLab, Bitbucket webhook parsing
  • Data Validation: Comprehensive validation of webhook payloads
  • Structured Output: Convert raw webhooks to structured data models
  • Error Handling: Robust error handling for malformed data
  • Type Safety: Complete type annotations with Pydantic models
  • Extensible: Easy to add support for new SCM platforms
  • Performance: Optimized parsing for high-throughput scenarios

Installation

# Basic installation
pip install universal-git-data-parser

# With GitHub support
pip install universal-git-data-parser[github]

# With GitLab support  
pip install universal-git-data-parser[gitlab]

# With validation features
pip install universal-git-data-parser[validation]

# With all features
pip install universal-git-data-parser[all]

Quick Start

GitHub Webhook Parsing

from universal_git_data_parser import GitDataParserService

# Initialize parser
parser = GitDataParserService()

# Parse GitHub push webhook
headers = {"X-GitHub-Event": "push"}
payload = {
    "repository": {"name": "my-repo", "full_name": "user/my-repo"},
    "ref": "refs/heads/main",
    "commits": [
        {
            "id": "abc123",
            "message": "Fix bug in parser",
            "author": {"name": "Developer", "email": "dev@example.com"},
            "timestamp": "2024-01-01T12:00:00Z",
            "added": ["file1.py"],
            "modified": ["file2.py"],
            "removed": []
        }
    ]
}

# Parse and validate
validated_event = parser.parse_github_push(headers, payload)

print(f"Repository: {validated_event.repository}")
print(f"Branch: {validated_event.ref}")
print(f"Commits: {len(validated_event.commits)}")

Advanced Usage

from universal_git_data_parser import (
    GitDataParserService, ValidatedEvent, CommitInfo
)

parser = GitDataParserService()

# Custom validation options
try:
    event = parser.parse_github_push(
        headers=headers,
        payload=payload,
        validate_signatures=True,
        strict_mode=True
    )
    
    # Access structured data
    for commit in event.commits:
        print(f"Commit: {commit.id}")
        print(f"Author: {commit.author}")
        print(f"Message: {commit.message}")
        print(f"Files changed: {len(commit.added + commit.modified + commit.removed)}")
        
except InvalidPayloadError as e:
    print(f"Invalid payload: {e}")
except UnsupportedPlatformError as e:
    print(f"Platform not supported: {e}")

Supported Platforms

Platform Push Events Pull Request Issues Tags
GitHub ✅ Full ✅ Full ⏳ Planned ⏳ Planned
GitLab ✅ Basic ⏳ Planned ⏳ Planned ⏳ Planned
Bitbucket ⏳ Planned ⏳ Planned ⏳ Planned ⏳ Planned

Data Models

The parser outputs structured Pydantic models:

  • ValidatedEvent: Main event container
  • CommitInfo: Individual commit information
  • DiffData: File change details
  • Author: Commit author information
  • FileChange: File modification details

Error Handling

Comprehensive exception hierarchy:

  • GitDataParserError: Base exception
  • InvalidPayloadError: Malformed webhook data
  • UnsupportedPlatformError: Platform not supported
  • DiffParsingError: Error parsing file changes
  • TimestampParsingError: Invalid timestamp format

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yeonjae_universal_git_data_parser-1.0.2.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file yeonjae_universal_git_data_parser-1.0.2.tar.gz.

File metadata

File hashes

Hashes for yeonjae_universal_git_data_parser-1.0.2.tar.gz
Algorithm Hash digest
SHA256 bd1dc76641ef4f1c6552c7ebbda6013bbdfabc7a8fce71d6291db189f6fa3a86
MD5 3caf4c156ebdb4a3c6aab385b0959e54
BLAKE2b-256 142cb2e903f6abe4d698169185d7bb4f737c050490ff456de3fa3c8bf4683783

See more details on using hashes here.

File details

Details for the file yeonjae_universal_git_data_parser-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for yeonjae_universal_git_data_parser-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7a6e61fb63113f64fd78643e2ebe2093d6f91843eba323c4422d44919ae0b036
MD5 361ae1a4a3e3f816672ba552c0a7f369
BLAKE2b-256 ef8985a8fd24b90624fef7b71ec78699d527684ef9f6f2bb279abe5a25333970

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page