Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Changelog
1.0.0a9 (unreleased)
--------------------

- Nothing changed yet.

- Added autocorrection for pip urls, so that github or gitlab urls can be used as copied
in sources.ini .
[zworkb]

1.0.0a8 (2021-11-30)
--------------------
Expand Down
20 changes: 19 additions & 1 deletion mxdev.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,24 @@ def read(
return (requirements, constraints)


def autocorrect_pip_url(pip_url: str) -> str:
"""
do some autocorrection for pip urls, especially urls copy/pasted
from github as e.g. [email protected]:bluedynamics/mxdev.git
which should be git+ssh://[email protected]/bluedynamics/mxdev.git

when no correction necessary, return the original
"""
if pip_url.startswith("git@"):
return f"git+ssh://{pip_url.replace(':', '/')}"
elif pip_url.startswith("ssh://"):
return f"git+{pip_url}"
elif pip_url.startswith("https://"):
return f"git+{pip_url}"

return pip_url


def fetch(packages) -> None:
logger.info("#" * 79)
logger.info("# Fetch sources from VCS")
Expand All @@ -177,7 +195,7 @@ def fetch(packages) -> None:
logger.info(f"Fetch or update {name}")
package: dict = packages[name]
repo_dir: str = os.path.abspath(f"{package['target']}/{name}")
pip_url: str = f"{package['url']}@{package['branch']}"
pip_url: str = autocorrect_pip_url(f"{package['url']}@{package['branch']}")
logger.debug(f"pip_url={pip_url} -> repo_dir={repo_dir}")
repo = create_repo_from_pip_url(pip_url=pip_url, repo_dir=repo_dir)
repo.update_repo()
Expand Down