Git URL Parse

1.2.2 · active · verified Thu Apr 16

git-url-parse is a Python library designed for robustly parsing Git repository URLs, extracting components such as the host, owner, repository name, and protocol. It supports various Git URL formats including HTTP/S, SSH, and Git protocol. The current version is 1.2.2. While the project repository shows active maintenance with commits, official PyPI releases occur infrequently.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to parse a common HTTPS Git URL and access its extracted components using the GitUrlParse class.

from git_url_parse import GitUrlParse

# Example 1: HTTPS URL
url = "https://github.com/retr0h/git-url-parse.git"
parsed_url = GitUrlParse().parse(url)

print(f"Host: {parsed_url.host}")
print(f"Owner: {parsed_url.owner}")
print(f"Repo: {parsed_url.repo}")
print(f"Protocol: {parsed_url.protocol}")
print(f"Name: {parsed_url.name}")
print(f"Token: {parsed_url.token}") # Empty for public URLs

view raw JSON →