Skip to main content

giturlparse

Parse & rewrite git urls (supports GitHub, Bitbucket, FriendCode, Assembla, Gitlab …)

This is a fork of giturlparse.py with updated parsers.

Original project can be found at https://github.com/FriendCode/giturlparse.py

Installing

pip install giturlparse

Examples

Exposed attributes

  • platform: platform codename

  • host: server hostname

  • resource: same as host

  • port: URL port (only if explicitly defined in URL)

  • protocol: URL protocol (git, ssh, http/https)

  • protocols: list of protocols explicitly defined in URL

  • user: repository user

  • owner: repository owner (user or organization)

  • repo: repository name

  • name: same as repo

  • groups: list of groups - gitlab only

  • path: path to file or directory (includes the branch name) - gitlab / github only

  • path_raw: raw path starting from the repo name (might include platform keyword) - gitlab / github only

  • branch: branch name (when parseable) - gitlab / github only

  • username: username from <username>:<access_token>@<url> gitlab / github urls

  • access_token: access token from <username>:<access_token>@<url> gitlab / github urls

Parse

from giturlparse import parse

p = parse('git@bitbucket.org:AaronO/some-repo.git')

p.host, p.owner, p.repo

# => ('bitbucket.org', 'AaronO', 'some-repo')

Rewrite

from giturlparse import parse

url = 'git@github.com:Org/Private-repo.git'

p = parse(url)

p.url2ssh, p.url2https, p.url2git, p.url2http
# => ('git@github.com:Org/Private-repo.git', 'https://github.com/Org/Private-repo.git', 'git://github.com/Org/Private-repo.git', None)

URLS

Alternative URLs for same repo:

from giturlparse import parse

url = 'git@github.com:Org/Private-repo.git'

parse(url).urls
# => {
#     'ssh': 'git@github.com:Org/Private-repo.git',
#     'https': 'https://github.com/Org/Private-repo.git',
#     'git': 'git://github.com/Org/Private-repo.git'
# }

Validate

from giturlparse import parse, validate

url = 'git@github.com:Org/Private-repo.git'

parse(url).valid
# => True

# Or

validate(url)
# => True

Tests

python -munittest

License

Apache v2 (Check out LICENSE file)

History

0.16.0 (2026-10-13)

Bugfixes

  • Fix HTTP normalization and protocol rewrites for generic Git hosts. (#97)

  • Pin ruff version to 0.15.22 (#156)

0.15.0 (2026-06-16)

Bugfixes

  • Fix path and branch extraction removing every /blob/ and /tree/ occurrence instead of only the leading marker, which corrupted file paths and branch names containing those segments. (#150)

0.14.0 (2025-10-22)

Features

  • Allow rewriting repo and owner (#0)

0.13.0 (2025-10-22)

Features

  • Switch to Coveralls Github action (#88)

Bugfixes

  • Fix Bitbucket url parse and add bitbucket.com to recognized domains (#107)

  • Remove fix-encoding-pragma from pre-commit hooks as it is deprecated (#119)

0.12.0 (2023-09-24)

Features

  • Add github/gitlab username:access_token parse support (#21)

  • Migrate to bump-my-version (#79)

Bugfixes

  • Fix Gitlab URLs with branch (#42)

  • Align tox.ini with github actions (#71)

0.11.1 (2023-08-04)

Bugfixes

  • Remove debug print statements (#66)

0.11.0 (2023-08-03)

Features

  • Add parsing variable for user to gitlab parser (#47)

  • Add support for Python 3.8+ (#48)

Bugfixes

  • Update tests invocation method to avoid future breakages (#29)

  • Update linting tools and fix code style (#34)

  • Add more github use cases (#43)

  • Fix parsing generic git url (#46)

0.10.0 (2020-12-05)

Features

  • General matching improvements (#18)

  • Update tooling, drop python2 (#10213)

0.9.2 (2018-10-27)

  • Removed “s” from the base platform regex

  • Fix license classifier in setup.py

  • Update meta files

0.9.1 (2018-01-20)

  • First fork release

Metadata

Release files for giturlparse 0.16.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for giturlparse 0.16.0
File Size Uploaded
giturlparse-0.16.0.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for giturlparse 0.16.0
File Interpreter ABI Platform
giturlparse-0.16.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 33.9 kB

Release files / giturlparse-0.16.0.tar.gz

Download URL giturlparse-0.16.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d84b1cc1a211273af6f6e944555cdccd3468c2c14b9564758042bcdd4d44c5ef
BLAKE2b-256 checksum
How to use checksums
cbd3a9dcec71f16f8cac1ac64e6c764eec6bac848fe96ef5d9e362bd5201c5b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / giturlparse-0.16.0-py2.py3-none-any.whl

Download URL giturlparse-0.16.0-py2.py3-none-any.whl
Size 17.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c4812b7227991d23ada03bc06b34c001de74907a5ea6e293e087d881b348d4bc
BLAKE2b-256 checksum
How to use checksums
5970fe161143f513a7c2eb087d6b16d59f67f25df3be2f0e12e8e76d5af5da60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

This release

0.16.0 This release

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.9.2

2 release files

0.9.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page