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.17.0 (2026-12-02)

Features

  • Drop support for Python < 3.11 (#165)

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.17.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.17.0
File Size Uploaded Provenance Actions
giturlparse-0.17.0.tar.gz 17.0 kB Without provenance Details for giturlparse-0.17.0.tar.gz

Built distribution (wheel)

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

Total release size: 34.2 kB

Release files / giturlparse-0.17.0.tar.gz

Download URL giturlparse-0.17.0.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e45b6f7e5b011bfcab0834b8fd708a311c915eeabe9cdfd66f9af9bf9178aa85
BLAKE2b-256 checksum
How to use checksums
2c206d21c81a9d629533fe05d0e1e80251bbb517990915af564d05ffe25199a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

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

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

Security for giturlparse 0.17.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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