@@ -25,6 +25,54 @@ $ pip install --user ptpython
2525$ ptpython
2626```
2727
28+ ## URL Parsing (experimental)
29+
30+ You can validate and parse git, Mercurial, and Subversion URLs through
31+ [ ` libvcs.parse ` ] ( https://libvcs.git-pull.com/parse/index.html ) :
32+
33+ Validate:
34+
35+ ``` python
36+ >> > from libvcs.parse.git import GitUrl
37+
38+ >> > GitURL.is_valid(url = ' https://github.com/vcs-python/libvcs.git' )
39+ True
40+ ```
41+
42+ Parse and adjust a git url:
43+
44+ ```
45+ from libvcs.parse.git import GitUrl
46+
47+ >>> git_location = GitURL(url='git@github.com:vcs-python/libvcs.git')
48+
49+ >>> git_location
50+ GitURL(url=git@github.com:vcs-python/libvcs.git,
51+ hostname=github.com,
52+ path=vcs-python/libvcs,
53+ user=git,
54+ suffix=.git,
55+ matcher=core-git-scp)
56+ ```
57+
58+ Switch repo libvcs -> vcspull:
59+
60+ ``` python
61+ >> > git_location.path = ' vcs-python/vcspull'
62+
63+ >> > git_location.to_url()
64+ ' git@github.com:vcs-python/vcspull.git'
65+
66+ # Switch them to gitlab:
67+ >> > git_location.hostname = ' gitlab.com'
68+
69+ # Export to a `git clone` compatible URL.
70+ >> > git_location.to_url()
71+ ' git@gitlab.com:vcs-python/vcspull.git'
72+ ```
73+
74+ See more in the [ parser document] ( https://libvcs.git-pull.com/parse/index.html ) .
75+
2876## Commands (experimental)
2977
3078Simple [ ` subprocess ` ] ( https://docs.python.org/3/library/subprocess.html ) wrappers around ` git(1) ` ,
0 commit comments